Skip to content

Maintainers Build Test and Distribute

Sumio Kiyooka edited this page May 3, 2021 · 3 revisions

Build

You should be using virtualenv, virtrualenvwrapper to make things easy on yourself.

Ref: Packaging Python Projects Tutorial

Prepare for release

Final steps:

  • Update and commit blackduck/__version__.py
  • Tag the release e.g. git tag -a 1.0.2 -m "Release 1.0.2"
  • git push
  • git push --tags

Build the blackduck packages

To build both the source distribution package and the wheel package:

pip3 install -r requirements.txt
python3 setup.py sdist bdist_wheel

Test

Using pytest

git clone https://github.com/blackducksoftware/hub-rest-api-python.git
cd hub-rest-api-python
# optional but advisable: create/use virtualenv
# you should have 3.x+, e.g. Python 3.7.0

pip3 install -r requirements.txt
pip3 install .
cd test
pytest

Distribute the package

Requires you have an account on either/both PyPi and Test PyPi AND you must be a package maintainer.

Send a request to [email protected] or [email protected] if you want to be listed as a package maintainer.

To Test PyPI

Upload to Test PyPI:

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

Then try installing it from Test PyPI

Uninstall all packages:

pip freeze > req.txt
pip uninstall -r req.txt -y
rm req.txt
pip list  (ensure just pip and setuptools are installed)

Install:

pip install --index-url https://test.pypi.org/simple blackduck

To PyPI

Upload to PyPI:

twine upload dist/*

Then try installing it from PyPI

pip3 install blackduck

Install package locally

Do this when testing a new version.

git clone https://github.com/blackducksoftware/hub-rest-api-python.git
cd hub-rest-api-python
pip3 install -r requirements.txt
pip3 install .

To uninstall:

pip3 uninstall blackduck