Skip to main content

supports github releases

Project description

setuptools-github

PyPI version Python versions Build Black Coverage

Quick start

setuptools-github helps to implement a simple project life cycle aimed at delivering packages into PyPI.

Install it with:

pip install setuptools-github
 or
conda install -c conda-forge setuptools-github

Add secrets

First you need to install the secrets for the package-name repository here

  • TWINE_PASSWORD
  • TWINE_USERNAME
  • CODECOV_TOKEN

Setup the master branch

Create a new src/package_name/__init__.py file to store the package information:

__version__ = "N.M.O"  # replace N, M and O with numerical values (eg. 0.0.0)
__hash__ = ""  # leave this empty

Fix the setup.py file:

from setuptools_github import tools
initfile = pathlib.Path(__file__).parent / "package_name/__init__.py"
setup(
  name="package-name",
  version=tools.update_version(initfile, os.getenv("GITHUB_DUMP")),
  ...

Copy over the github workflow files:

Most likely you might need to change tests/requirements.txt file.

THAT IS ALL! Now when commiting to the master branch, this will trigger the github action to run tests and quality checks on the code (see the Rationale section below).

Setup the beta/N.M.O branch

You must create a beta branch using the little script:

python -m setuptools_github.script make-beta 
or
setuptools-github make-beta

This will generate the beta/N.M.O branch out of the master branch.

Adds the secrets in https://github.com///settings/secrets/actions:

  • TWINE_PASSWORD
  • TWINE_USERNAME

Then for each commit into beta/N.M.O a package will be generated as package-N.M.O.bX on PyPI (if all tests pass!).

Rationale

setuptools-github helps to implement a simple project life cycle aimed at delivering packages into PyPI: there are three important components, the master branch, the beta branch and the release tags.

/master branch this is the branch where all commit go (as well the PR from feature branches). On each commit the CI will run code quality checks as:

  • running flake8
  • running mypy
  • running all pytest + coverage

(see github/workflows/master.yml for an example)

/beta/N.M.O branch branch is where code is merged to release the beta packages to PyPI.
On each commit into this branch, the CI will:

  • run flake8
  • run mypy
  • run pytest + coverage (see .github/workflows/master.yml)
  • create wheel such as package-N.M.O.bX
  • (optional) publish the wheel to PyPI

(see github/workflows/beta.yml for an example)

NOTE: the X in the package-name-N.M.O.bX is a unique increasing build number taken from GITHUB build environment.

/release/N.M.O is a release tag. Once the code is stable enough on the /beta/N.M.O branch that is the time to release a formal package-N.M.O.

So tagging on /beta/N.M.O with a /release/N.M.O tag will direct the CI to:

  • create wheel such as package-name-N.M.O
  • (optional) publish the wheel to PyPI

(see github/workflows/tags.yml for an example)

WARNING: there won't be any check/test run on the tagged code, so it it important the tagging happen on /beta/N.M.O branch

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

setuptools-github-0.3.0b60.tar.gz (18.9 kB view hashes)

Uploaded Source

Built Distribution

setuptools_github-0.3.0b60-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page