setuptools-scmx
Project Description
setuptools-scmx is a Python package designed to extend setuptools-scm with CI-friendly versioning schemes. It provides flexible, configuration-driven version management tailored for continuous integration and delivery workflows, allowing developers to define custom versioning logic based on Git branch names and tags directly within pyproject.toml.
What it Does
This package enhances the standard setuptools-scm functionality by introducing:
- Custom Versioning Schemes: Define how your project's version is determined based on its Git state.
- Branch-Aware Versioning: Differentiate version numbers based on the current Git branch (e.g.,
main,develop,feature/xyz). - Exact Tag Versions: Ensures that builds from Git tags always result in the exact tag version, without any additional suffixes.
- CI Platform Integration: Built-in support for GitHub Actions, GitLab CI, and Jenkins environment variables.
- Environment Variable Overrides: Allows specifying a version directly via an environment variable, with support for regex-based extraction.
pyproject.tomlIntegration: All custom versioning logic and configurations are managed declaratively in yourpyproject.tomlfile, leveragingpyprojectrfor robust parsing.
How to Use it as a Developer
1. Installation
Add setuptools-scmx to your build-system.requires in pyproject.toml.
# pyproject.toml
[build-system]
requires = [
"setuptools>=80",
"setuptools-scm[toml]",
"setuptools-scmx",
]
build-backend = "setuptools.build_meta"
[project]
name = "your-project-name"
dynamic = ["version"]
2. Configure setuptools-scm
Configure setuptools-scm to use the setuptools_scmx entry point.
# pyproject.toml
[tool.setuptools_scm]
version_scheme = "setuptools_scmx:version_scheme"
local_scheme = "no-local-version"
3. Configure setuptools-scmx
Define your rules under [tool.setuptools-scmx].
# pyproject.toml
[tool.setuptools-scmx]
scheme = "branch-scheme" # Required to enable branch-aware logic
env_scheme = "github" # Optional: 'custom' (default), 'github', 'gitlab', 'jenkins'
[tool.setuptools-scmx.branch-scheme]
labels = [
{ name = "rc", branches = ["main", "master"] },
{ name = "dev", branches = ["develop"] },
{ name = "alpha", branches = ["feature/.*"] },
{ name = "post", branches = ["hotfix"] },
]
Supported Labels
The name field in labels supports standard PEP 440 pre-release identifiers:
rc,beta,alpha,dev,post
CI & Environment Schemes
setuptools-scmx can automatically detect branch and build information from CI environments.
env_scheme |
Source Platform | Automatic Branch Detection | Automatic Build Number |
|---|---|---|---|
github |
GitHub Actions | GITHUB_REF_NAME |
GITHUB_RUN_ID |
gitlab |
GitLab CI | CI_COMMIT_REF_NAME |
CI_JOB_ID |
jenkins |
Jenkins | BRANCH_NAME |
BUILD_NUMBER |
custom |
Any | Manual via env-schemes.custom |
Manual via env-schemes.custom |
Advanced Environment Configuration
You can customize how versions are extracted from environment variables.
[tool.setuptools-scmx.env-schemes.custom]
version = "SCMX_VERSION_OVERRIDE"
# If true (default), extracts version using the regex below
extract_version_with_regex = true
# Default regex extracts digits and dots (e.g., "1.2.3" from "v1.2.3-beta")
version_regex = "([\\d.]+)"
Environment Variables
SCMX_PYPROJECT_PATH: Path to thepyproject.tomlfile (defaults topyproject.tomlin the current directory). Useful for monorepos.SCMX_VERSION_OVERRIDE: Default variable used by thecustomscheme to force a specific version.
Versioning Behavior Examples
Assuming the last tag is 1.0.0 and there are 5 commits since (distance=5):
- On a Tag:
1.0.0 - On
mainbranch:1.0.1.rc.5 - On
developbranch:1.0.1.dev.5 - On
feature/xyz:1.0.1.alpha.5 - On
hotfixbranch:1.0.1.post.5 - On an unmapped branch (
bugfix/123):1.0.1+bugfix-123.5 - With
SCMX_VERSION_OVERRIDE="2.0.0":2.0.0(overrides Git state)
Metadata
Release files for setuptools-scmx 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| setuptools_scmx-0.1.5.tar.gz | 56.9 kB | Without provenance | Details for setuptools_scmx-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| setuptools_scmx-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for setuptools_scmx-0.1.5-py3-none-any.whl |
Total release size: 62.6 kB
Release files / setuptools_scmx-0.1.5.tar.gz
| Download URL | setuptools_scmx-0.1.5.tar.gz |
|---|---|
| Size | 56.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f07d23f1295d6e9f838783693838c4c025a563f5ca670481ca4ee123a895eb1
|
|
BLAKE2b-256 checksum How to use checksums |
eea2a9295fa629a3b51a6e3b276ab2b2b24e5e619bbc41c35c2f3d4e8733a6f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / setuptools_scmx-0.1.5-py3-none-any.whl
| Download URL | setuptools_scmx-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
502d05f8a34860e34cc21859b6eb223a4f922482595c4ccb56f4ba10ccd383cf
|
|
BLAKE2b-256 checksum How to use checksums |
8520560f6b4ef7913073bbcf4487f01605542d7d53b49af20a155196a05e3c2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Security for setuptools-scmx 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.