Skip to content

Deploy a new release in PyPi

EAR_MNHN edited this page Nov 24, 2022 · 3 revisions

Basic info for configuring setup.py and uploading the package to Pypi

First, be sure that the name of your package does not exist on Pypi. You have to choose a unique name otherwise, you won't be able to upload your package on Pypi.

You can find help here

1. Prepare account user and password and update tools

Create a Pypi account and TestPyPi account. If other collaborators want to build a Pypi package, you will need to add them as contributors on this project in TestPyPi and Pypi.

Update the tools needed: setuptools and twine

pip install setuptools --upgrade
pip install twine --upgrade

2. Edit files setup.py and bambird/version.py

  • New version name
  • Update dependencies
  • Update contact information

3. Remove old distributions and compile the packaging

Go to directory where you package is (could be bambird or something else like bambird.git)

python setup.py clean
python setup.py sdist bdist_wheel

more info -> https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives

4. Upload and try on testPyPI

python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

5. check if module can be installed in a virtual environment

The easiest option is to open a new notebook on a Google Colab session. Then, install bambird from the TestPyPi using this command Don't forget to add the argument --extra-index-url https://pypi.org/simple/ in order to be able to install the other packages that are required to run scikit-maad

!pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bambird==<version>

or create a new virtual environment. For instance, with conda:

conda create --name test_bambird
conda activate test_bambird
conda install pip
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bambird==<version>
conda list

For those using Spyder, it might be necessary to install the package spyder-kernels

conda install spyder-kernels=2.3

You can delete the test environment when everything is correct with the command

conda deactivate
conda env remove -n test_bambird

6. Make all the necessary tests and check that the information is correctly displayed in TestPyPi.

Take your time to verify the examples and make tests to be sure that the new version is running correctly.

7. Once everything is correct, upload to PyPi.

twine upload dist/*