Web
    Analytics
Skip to main content

Uploading a package on PyPI

These are some simple notes to remind myself how to upload a python package to PyPI. The full description on how to upload a package to PyPI can be found here.

These notes assume that you have already set up the proper folder structure, a working setup.py and all the requirements (setuptools, wheel, and useraccounts at PyPI and TestPyPI) for uploading to PyPI installed.

Make sure you have the latest versions of setuptools and wheel

python3 -m pip install --user --upgrade setuptools wheel

Run this command from the same location as setup.py

python3 setup.py sdist bdist_wheel

This creates several files in the dist/ directory:

dist/
  example_pkg_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
  example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz

If this runs without warnings you can upload to TestPyPI.

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

After the command completes you can see the package on https://test.pypi.org/project/example-pkg-YOUR-USERNAME-HERE.

If everything looks as it should you can upload to PyPI.

twine upload dist/*

Note

This procedure works well for pure python packages. Once platform dependencies creep in, it is advicable to take that into account. I recommend checking out the python packaging tutorial (SciPy 2018).

Comments

Comments powered by Disqus