Skip to content

Instantly share code, notes, and snippets.

@deeTEEcee
Last active July 16, 2026 21:26
Show Gist options
  • Select an option

  • Save deeTEEcee/43decea339a83bfa7d3a7093e117ff79 to your computer and use it in GitHub Desktop.

Select an option

Save deeTEEcee/43decea339a83bfa7d3a7093e117ff79 to your computer and use it in GitHub Desktop.
Basic guide for uplaoding to pypi

One-time setups

1. Create a pypi account at https://pypi.org/. (If you need a separate repo for testing, you can also create it at test.pypi.org
2. Setup 2-auth and get your API key information. Save your token somewhere if needed (only accessible once)
3. Setup auth locally in ~/.pypirc

    [distutils]
    index-servers =
        pypi
        testpypi
    
    [pypi]
    username = __token__
    password = pypi-xxxxxxxxxxxx
    
    [testpypi]
    username = __token__
    password = pypi-xxxxxxxxxxxx
 
# If pip not installed yet locally
4. pip install build twine

Every new project

1. SETUPTOOLS_SCM_PRETEND_VERSION=<version> python -m build
2. twine upload --repository pypi dist/*

Caveats

  • With pypi, cannot do a version deployment like 1.5.0+custom1 because it doesn't follow their naming scheme. I've found this to be useful when forking projects and following a convention to track what the state of the fork is while still following the original project.
  • Get a 400 when trying to upload to twine due to project existing.
    • Project already exist so we should upload a new version.
    • Even if we manually delete the project, we'll still get a 400.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment