Skip to content

Instantly share code, notes, and snippets.

@TheMatjaz
Last active April 29, 2022 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheMatjaz/bc6175b245cf7c519517b2f32df5ca94 to your computer and use it in GitHub Desktop.
Save TheMatjaz/bc6175b245cf7c519517b2f32df5ca94 to your computer and use it in GitHub Desktop.
Commands to build and deploy a Python package to PyPi

Deploying a Python package to PyPi

.pypirc

if ~/.pypirc does not exists, create it with the content (alter the username):

[distutils]
index-servers=
    pypi
    testpypi

[testpypi]
repository: https://test.pypi.org/legacy/
username: TheMatjaz

[pypi]
username: TheMatjaz

Build and upload to test repo

pip3 install --upgrade pip setuptools wheel twine

python3 setup.py sdist bdist_wheel --universal

python3 -m twine upload --repository testpypi dist/*

(enter password)

Test the package

pip3 install --index-url https://test.pypi.org/simple/ --no-deps your-package

import your-package in the python shell within the same venv

Upload to main PyPi repo

python3 -m twine upload --repository pypi dist/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment