From 2a5859ac45334407ed61cf855711443ac14a764a Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 31 Dec 2025 16:13:49 +0100 Subject: [PATCH 1/2] added automatic git based versioning --- .github/workflows/ci.yml | 15 +++++++++++++++ pyproject.toml | 14 ++++++++++++-- src/copapy/__init__.py | 2 ++ src/copapy/_version.py | 2 ++ tools/get_tag.sh | 18 +++--------------- 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 src/copapy/_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f38a85..0a33b96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: @@ -87,6 +89,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: @@ -140,6 +144,8 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: name: stencil-object-files @@ -169,6 +175,8 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: name: stencil-object-files @@ -198,6 +206,8 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: name: stencil-object-files @@ -232,6 +242,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: @@ -279,6 +291,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 + fetch-tags: true sparse-checkout: | pyproject.toml tools/get_tag.sh @@ -325,6 +338,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/download-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index d08a40e..2f888f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "copapy" -version = "0.0.3" +dynamic = ["version"] authors = [ { name="Nicolas Kruse", email="nicolas.kruse@nonan.net" }, ] @@ -20,7 +20,7 @@ Homepage = "https://github.com/nonannet/copapy" Issues = "https://github.com/nonannet/copapy/issues" [build-system] -requires = ["setuptools>=61.0", "wheel"] +requires = ["setuptools>=61.0", "setuptools-scm>=8", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] @@ -29,6 +29,16 @@ where = ["src"] [tool.setuptools.package-data] copapy = ["obj/*.o", "py.typed"] +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "node-and-date" +tag_regex = "^v(?P\\d+\\.\\d+\\.\\d+(?:-beta)?)$" +write_to = "src/copapy/_version.py" +write_to_template = ''' +# generated by setuptools_scm - do not edit +__version__ = "{version}" +''' + [project.optional-dependencies] dev = [ "ruff", diff --git a/src/copapy/__init__.py b/src/copapy/__init__.py index d29c01a..b432306 100644 --- a/src/copapy/__init__.py +++ b/src/copapy/__init__.py @@ -40,9 +40,11 @@ from ._tensors import tensor, zeros, ones, arange, eye, identity, diagonal from ._math import sqrt, abs, sign, sin, cos, tan, asin, acos, atan, atan2, log, exp, pow, get_42, clamp, min, max, relu from ._autograd import grad from ._tensors import tensor as matrix +from ._version import __version__ __all__ = [ + "__version__", "Target", "NumLike", "value", diff --git a/src/copapy/_version.py b/src/copapy/_version.py new file mode 100644 index 0000000..869cfb0 --- /dev/null +++ b/src/copapy/_version.py @@ -0,0 +1,2 @@ +# generated by setuptools_scm - do not edit +__version__ = "0.0.0" diff --git a/tools/get_tag.sh b/tools/get_tag.sh index 76f060c..dcd61c0 100644 --- a/tools/get_tag.sh +++ b/tools/get_tag.sh @@ -10,18 +10,6 @@ if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then exit 0 fi -# Otherwise, extract version from pyproject.toml -if [[ -f pyproject.toml ]]; then - VERSION=$(grep -E '^version\s*=' pyproject.toml \ - | sed -E 's/version\s*=\s*"([^"]+)"/\1/' \ - | tr -d '\r\n') - if [[ -z "$VERSION" ]]; then - echo "! Could not find version in pyproject.toml" >&2 - exit 1 - fi - echo "Detected version from pyproject.toml: v$VERSION-beta" - echo "version=v$VERSION-beta" >> "${GITHUB_OUTPUT:-/dev/stdout}" -else - echo "! pyproject.toml not found" >&2 - exit 1 -fi +# Detected version from Git +TAG_NAME=$(git describe --tags --abbrev=0) +echo "version=$TAG_NAME" >> "${GITHUB_OUTPUT:-/dev/stdout}" From bb2c0ee548147deac5eb270966f4069eb9392ef6 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 31 Dec 2025 16:29:41 +0100 Subject: [PATCH 2/2] added fallback_version for tool.setuptools_scm in container based ARM runners --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 2f888f4..a6a5401 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ copapy = ["obj/*.o", "py.typed"] version_scheme = "post-release" local_scheme = "node-and-date" tag_regex = "^v(?P\\d+\\.\\d+\\.\\d+(?:-beta)?)$" +fallback_version = "0.0.0" write_to = "src/copapy/_version.py" write_to_template = ''' # generated by setuptools_scm - do not edit