Skip to content

Upload to pypi

Yuyi Guo edited this page Sep 29, 2021 · 7 revisions

setup.py

The first thing to do before building and uploading to pypi, you will need to change package version. To do so you will need to open the setup.py in the root directory. Once open search the following line and change it's version:

package_version = "3.17.0"

Import needed package

You will need 2 libraries to build and install your package:

  • build
  • twine

To install them run the following commands:

python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine

Build

Now that everything is installed, you are able to build your package. To do so run the followings:

python3 setupPypi.py sdist
python3 setupPypi.py bdist_wheel

This will create a new dist directory (if it does not exists) and put your build in it. The first command will create a tar.gz file with the source file in it and the second command will create the wheel file.

Upload the build to pypi

Finaly you can upload your build to pypi with the next command:

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

It will then ask your pypi username and password. Congratulation your package is now on pypi.

*Note : More details to upload package to pypi here.

Clone this wiki locally