From a7d71d9a3cc5aa15faf7e7282fa3782c7e6b0e5b Mon Sep 17 00:00:00 2001 From: Per-Arne Andersen Date: Sat, 19 Oct 2024 14:56:21 +0200 Subject: [PATCH] Updated dynamic versioning to a compatible pypi format --- .github/workflows/wheels.yml | 9 +++++++++ jsp/__version_scheme.py | 16 ++++++++++++++++ pyproject.toml | 5 +++++ setup.py | 5 +++++ 4 files changed, 35 insertions(+) create mode 100644 jsp/__version_scheme.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0cbae5f..7f3f969 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -11,13 +11,22 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all tags and branches - uses: actions/setup-python@v5 + - name: Generate BUILD_NUMBER + id: build_number + run: | + echo "BUILD_NUMBER=$(git rev-list --count HEAD)" >> $GITHUB_ENV + - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.21.3 - name: Build wheels + env: + BUILD_NUMBER: ${{ env.BUILD_NUMBER }} run: python -m cibuildwheel --output-dir wheelhouse - uses: actions/upload-artifact@v4 diff --git a/jsp/__version_scheme.py b/jsp/__version_scheme.py new file mode 100644 index 0000000..4f17e20 --- /dev/null +++ b/jsp/__version_scheme.py @@ -0,0 +1,16 @@ +import os +from setuptools_scm import get_version + +def version_scheme(version): + if version.exact: + return version.format_with("{tag}") + else: + patch = int(os.environ.get("BUILD_NUMBER", 0)) + return version.format_with(f"{{tag}}.dev{{distance}}+{patch}") + +def get_version_scheme(root=".", relative_to=None, version_scheme=version_scheme): + return get_version( + root=root, + relative_to=relative_to, + version_scheme=version_scheme, + ) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5f98486..7cca95a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,11 @@ packages = ["jsp"] [tool.setuptools_scm] write_to = "jsp/_version.py" +version_scheme = "python-simplified-semver" +local_scheme = "no-local-version" + +[tool.setuptools_scm.version_scheme] +callable = "jsp._version_scheme:version_scheme" [tool.pytest.ini_options] pythonpath = ["."] diff --git a/setup.py b/setup.py index 86ca126..5aa3791 100644 --- a/setup.py +++ b/setup.py @@ -83,6 +83,11 @@ def build_extension(self, ext): setup( name="jobshop", author="Per-Arne Andersen", + use_scm_version={ + "write_to": "jsp/_version.py", + "version_scheme": "jsp._version_scheme:version_scheme", + }, + setup_requires=['setuptools_scm'], author_email="per@sysx.no", description="Job Shop Scheduling Algorithms", long_description=Path("README.md").read_text(),