Skip to content

Creating a PyPI Package

Ludovico Bianchi edited this page Jul 1, 2021 · 2 revisions

Note that pypi will not allow you to replace a package with the same version number (even if you delete the old one). So keep that in mind before uploading a package to either the main or test site.

Starting from an entirely clean state

conda remove --name proteuslib-rel --all --yes  # remove any old conda env
conda create -n proteuslib-rel python=3.8 --yes # create an entirely new conda env
conda activate proteuslib-rel
pip install --upgrade setuptools wheel twine

Get clean clone of proteuslib

git clone [email protected]:nawi-hub/proteuslib.git
cd proteuslib
git checkout 0.1_rel           # Get onto the appropriate branch for the given release
git clean -dfx                 # If using an existing repo clone
pip install .                  # build and install proteuslib in-place (no -e, or -r requirements.txt or setup.py)
pip list   
pip show proteuslib idaes-pse  # confirm that proteuslib and idaes-pse are the expected versions

Prep for PyPI build and push

python setup.py sdist bdist_wheel  # create proteuslib package
# Remove old builds in ./dist/
twine upload --repository-url https://test.pypi.org/legacy/ dist/*  # Upload to test pypi

Verify that the package is working

Note that if this is a release candidate, you'll need specify that in the package name here, i.e. proteuslib==0.1.0rc0

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple proteuslib
# TODO update once we have a proper way of displaying the current version
python -c "import proteuslib; print(proteuslib.__version__)"

Push the package to the non-test (real) PyPi

twine upload dist/*