Skip to main content

Get info on how a package should be built on CI

Project description

ci-helper

Output information to help build a Python package in CI

Motivation

This tool exists to address certain issues of bit-rot and deployment of GitHub Actions workflows (though the problem exists for CI generally) that build Python packages.

It looks up what current Python versions are supported so you can target them in your builds without having to maintain a curated list. It determines whether building on multiple OSs or Python versions is needed for a Python package, allowing you to deploy a generic CI configuration for different types of packages without having to modify it for each one specifically when they only vary in this way.

Specifically:

  • It lists all stable and supported Python versions so your CI can target all supported versions of Python without having to curate a manual list.

  • It tells you what the second-most-recent minor version of Python is, so you can use that as a sensible default for tools that require a recent-ish Python but are likely not to work immediately after a new Python is released.

  • It tells you whether a Python package is pure Python or not, so that your CI knows whether it needs to build on multiple OSs/Python versions.

  • It tells you whether a Python package's dependencies have environment markers or not, so that your CI knows whether it needs to build on multiple OSs/Python versions, for package formats that don't support environment markers in dependencies (e.g. conda packages).

These functions are all serving the goals of:

  • Minimising how often you need to modify your CI configs just because a new version of Python came our or an old version reached end-of-life
  • Minimising (ideally to zero) how much you need to customise an otherwise generic CI config when you re-use it for different types of Python packages (e.g. pure vs impure)

Installation

This package is available on PyPI, install it to your current Python environemnt with

pip install ci-helper

Usage:

# All stable, non-end-of-life Python versions:
$ ci-helper pythons
3.9,3.10,3.11,3.12,3.13

# Same but in the format used by `cibuildwheel`'s `CIBW_BUILD` environment variable (cpython-only for now):
$ ci-helper pythons --cibw
cp39-* cp310-* cp311-* cp312-* cp313-*

# The second-most recent minor Python release, a good choice for the version to run
# tools from:
$ ci-helper defaultpython
3.12

# Info about the source Python project in the current working directory - name, version,
# whether it's a pure Python package, and whether its build or run requirements contain
# any # environment markers (that is, whether its requirements vary by platform or
# Python version):
$ ci-helper distinfo .
{
    "name": "ci-helper",
    "version": "0.1.dev1+g5043fb5.d20241202",
    "is_pure": true,
    "has_env_markers": false
}

# Same but one field at a time, more convenient for assigning to environment variables:
$ ci-helper distinfo name .
ci-helper
$ ci-helper distinfo version .
0.1.0
$ ci-helper distinfo is_pure .
true
$ ci-helper distinfo has_env_markers .
false 

Full help text

$ ci-helper -h
usage: ci-helper [-h] [--version] {pythons,defaultpython,distinfo} ...

positional arguments:
  {pythons,defaultpython,distinfo}
                        Action to perform
    pythons             Output list of stable Python versions that have not yet reached end of life, see `ci-helper pythons -h`
    defaultpython       Output the second-latest stable Python version in X.Y format, useful as a good choice for a default python version
    distinfo            Output info about the distribution, see `ci-helper distinfo -h`

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
$ ci-helper pythons -h
usage: ci-helper pythons [-h] [--cibw]

options:
  -h, --help  show this help message and exit
  --cibw      Output as a space-separated list in the format `cpXY-* cpXY-*` as appropriate for the CIBW_BUILD environment variable to build for all
              stable CPython versions, otherwise versions are output as a comma-separated list in the format X.Y,X.Y
$ ci-helper default_python -h
usage: ci-helper defaultpython [-h]

options:
  -h, --help  show this help message and exit
$ ci-helper distinfo -h
usage: ci-helper distinfo [-h]
                          [{name,version,is_pure,has_env_markers}]
                          project_directory

positional arguments:
  {name,version,is_pure,has_env_markers}
                        Name of field to output as a single json value, if not
                        given, all info is output as json
  project_directory     Directory of Python project

options:
  -h, --help            show this help message and exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ci_helper-0.2.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ci_helper-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file ci_helper-0.2.0.tar.gz.

File metadata

  • Download URL: ci_helper-0.2.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for ci_helper-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e5448b8b33df54c0df743e7454ce1453d55cc811b3e1c557c887b036d21ddf74
MD5 3b82e394a112678d3ca74234937f4c4c
BLAKE2b-256 1652e114e4f23d6eedc1117d9ed65ea9397aa8a8aef2a8bc191d0e4277f85b31

See more details on using hashes here.

File details

Details for the file ci_helper-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ci_helper-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for ci_helper-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5fc47ad2e6263bd499b793eb7ae780fe5de7487fe70808b11cfd4fae2b16a8d
MD5 e718c42359dcaf96c8fedd84570c4dec
BLAKE2b-256 c1c2609faef36a5ae3b5832b1509413dcaddfea7b85853926ae0d80713600067

See more details on using hashes here.

Supported by

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