An example Python project
Project description
Sample PyPI package + GitHub Actions + Versioneer
This template aims to automate the tedious and error-prone steps of tagging/versioning, building and publishing new package versions. This is achieved by syncing git tags and versions with Versioneer, and automating the build and release with GitHub Actions, so that publishing a new version is as painless as:
$ git tag vX.Y.Z && git push --tags
The following guide assumes familiarity with setuptools
and PyPI. For an introduction to Python packaging, see the references at the bottom.
How to use this template
-
Click on the Use this template button to get a copy of this repository.
-
Rename src/sample_package folder to your package name — src/ is where your package must reside.
-
Go through each of the following files and rename all instances of sample-package or sample_package to your package name. Also update the package information such as author names, URLs, etc.
- setup.py
- pyproject.toml
- __init__.py
-
Install
versioneer
andtomli
, and runversioneer
:$ pip install tomli $ pip install versioneer $ versioneer install
Then commit the changes produced by
versioneer
. See here to learn more. -
Setup your PyPI credentials. See the section Saving credentials on Github of this guide. You should use the variable names
TEST_PYPI_API_TOKEN
andPYPI_API_TOKEN
for the TestPyPI and PyPI tokens, respectively. See .github/workflows/release.yaml.
You are all set! It should now be possible to run git tag vX.Y.Z && git push --tags
to automatically version, build and publish a new release to PyPI.
References
- Python packaging guide: https://packaging.python.org/en/latest/tutorials/packaging-projects/
- ...and how things are changing: https://snarky.ca/what-the-heck-is-pyproject-toml/ — in particular, note that while pyproject.toml seems to be the future, currently Versioneer still depends on setup.py.
- Versioneer: https://github.com/python-versioneer/python-versioneer
- GitHub Actions: https://docs.github.com/en/actions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sample-package-chanshing-0.0.0.post0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913e3ca0473e809f5bac198b06bbdb11c33e40f2348be34e8376d22725c3c506 |
|
MD5 | e4cc967a0e07e6320f248e4162747bf6 |
|
BLAKE2b-256 | e7c7de033aaab45f75f83b54970bfd2c04a6027f4ad987ed9b724224dc438346 |
Hashes for sample_package_chanshing-0.0.0.post0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 800eaa9291c0aa22e163ef552b070736bb3ce0dbc94333d62e5150d7202e9f77 |
|
MD5 | c8d59d85626b1c5f798fe8da959588f4 |
|
BLAKE2b-256 | d16b93094189458b6c9fbbc1b2483110d130e45b448aec41dd27d08ff7d11c4d |