Skip to content

Commit

Permalink
Updated dynamic versioning to a compatible pypi format
Browse files Browse the repository at this point in the history
  • Loading branch information
perara committed Oct 19, 2024
1 parent f7a19f8 commit a7d71d9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions jsp/__version_scheme.py
Original file line number Diff line number Diff line change
@@ -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,
)
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["."]
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit a7d71d9

Please sign in to comment.