CI friendly setuptools-scm hooks
Project description
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.
pyproject.tomlIntegration: All custom versioning logic and configurations are managed declaratively in yourpyproject.tomlfile, leveragingpyprojectrfor robust parsing.
This allows for consistent and predictable versioning across different development stages and CI environments, making it easier to track builds and releases.
How to Use it as a Developer
To integrate setuptools-scmx into your project, follow these steps:
1. Installation
First, ensure setuptools-scmx and its dependencies are installed. You typically add it to your build-system.requires in pyproject.toml.
# pyproject.toml
[build-system]
requires = [
"setuptools>=80",
"setuptools-scmx", # Add setuptools-scmx here
]
build-backend = "setuptools.build_meta"
[project]
name = "your-project-name"
dynamic = ["version"]
# ... other project metadata
2. Configure setuptools-scm
In your pyproject.toml, configure setuptools-scm to use a custom version_scheme and local_scheme. You will point version_scheme to the entry point provided by setuptools-scmx.
# pyproject.toml
[tool.setuptools_scm]
version_scheme = "setuptools_scmx.version_scheme" # Use the custom scheme
local_scheme = "no-local-version" # Or 'node-and-date' as per your preference
3. Configure setuptools-scmx
Define your custom branch-aware versioning rules under [tool.setuptools-scmx].
# pyproject.toml
[tool.setuptools-scmx]
scheme = "branch-scheme" # This tells setuptools-scmx to use the branch-aware logic
[tool.setuptools-scmx.branch-scheme]
labels = [
# Branches 'main' and 'master' will get a '.rc' label
{ name = "rc", branches = ["main", "master"] },
# The 'develop' branch will get a '.dev' label
{ name = "dev", branches = ["develop"] },
# Branches starting with 'feature/' will get an '.alpha' label
{ name = "alpha", branches = ["feature/"] }, # Example: feature/new-feature -> 1.2.3.alpha.4
# The 'hotfix' branch will get a '.post' label
{ name = "post", branches = ["hotfix"] },
]
Explanation of [tool.setuptools-scmx.branch-scheme.labels]
Each entry in the labels list defines a rule:
name: The string to append to the version number (e.g.,rc,dev,alpha,post). This should generally conform to PEP 440 pre-release identifiers.branches: A list of branch names. If the current Git branch matches any of these, the correspondinglabelwill be used.
Versioning Behavior Examples:
Assuming the last tag is 1.0.0 and there are 5 commits since the tag (distance=5):
-
On a Tag (
git checkout 1.0.0):- Version:
1.0.0(exact)
- Version:
-
On
mainbranch:- Version:
1.0.1.rc.5(next version1.0.1, labelrc, distance5)
- Version:
-
On
developbranch:- Version:
1.0.1.dev.5(next version1.0.1, labeldev, distance5)
- Version:
-
On
feature/my-new-featurebranch:- Version:
1.0.1.alpha.5(next version1.0.1, labelalpha, distance5)
- Version:
-
On
hotfixbranch:- Version:
1.0.1.post.5(next version1.0.1, labelpost, distance5)
- Version:
-
On an unmapped branch (e.g.,
bugfix/issue-123):- Version:
1.0.1.bugfix-issue-123.5(next version1.0.1, normalized branch name as label, distance5)
- Version:
This setup provides a powerful and flexible way to manage your project's versioning in a CI/CD environment.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file setuptools_scmx-0.1.1.tar.gz.
File metadata
- Download URL: setuptools_scmx-0.1.1.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c365aec4735acd6f451b89846d09c454dfc6e5623872e3409d73c1f7993ace9
|
|
| MD5 |
ed19a6a12a55ab35e966809998217bfc
|
|
| BLAKE2b-256 |
59ebe499ed04956ba99c67ab804719e7c5256333abd23c246d6a758e52094ca0
|
File details
Details for the file setuptools_scmx-0.1.1-py3-none-any.whl.
File metadata
- Download URL: setuptools_scmx-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
119d5ab1d227eeb1c8bdd85c02800c8339d0672d563e8650b5142d6664ca4823
|
|
| MD5 |
cf15f9d8f81e4c34f7818dc8fb15b056
|
|
| BLAKE2b-256 |
f6d0d72b6d8fc4382787737246d41e26956d52af6c6fe78eacff0e7d67b70aee
|