diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index acab66d0b..541fdbe41 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,7 @@ on: - main paths: - 'codeflash/version.py' - - 'codeflash-benchmark/codeflash_benchmark/__init__.py' + - 'codeflash-benchmark/codeflash_benchmark/version.py' jobs: detect-changes: @@ -28,7 +28,7 @@ jobs: else echo "codeflash=false" >> $GITHUB_OUTPUT fi - if git diff --name-only HEAD~1 HEAD | grep -q '^codeflash-benchmark/codeflash_benchmark/__init__.py$'; then + if git diff --name-only HEAD~1 HEAD | grep -q '^codeflash-benchmark/codeflash_benchmark/version.py$'; then echo "benchmark=true" >> $GITHUB_OUTPUT else echo "benchmark=false" >> $GITHUB_OUTPUT @@ -121,23 +121,14 @@ jobs: with: fetch-depth: 0 - - name: Extract version from __init__.py + - name: Extract version from version.py id: extract_version run: | - VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash-benchmark/codeflash_benchmark/__init__.py) + VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash-benchmark/codeflash_benchmark/version.py) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "tag=benchmark-v$VERSION" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION" - - name: Verify version matches pyproject.toml - run: | - INIT_VERSION=${{ steps.extract_version.outputs.version }} - TOML_VERSION=$(grep -oP '^version = "\K[^"]+' codeflash-benchmark/pyproject.toml) - if [ "$INIT_VERSION" != "$TOML_VERSION" ]; then - echo "::error::Version mismatch: __init__.py=$INIT_VERSION, pyproject.toml=$TOML_VERSION" - exit 1 - fi - - name: Check if tag already exists id: check_tag run: | diff --git a/codeflash-benchmark/codeflash_benchmark/__init__.py b/codeflash-benchmark/codeflash_benchmark/__init__.py index 7b85a2cc5..5b9dba851 100644 --- a/codeflash-benchmark/codeflash_benchmark/__init__.py +++ b/codeflash-benchmark/codeflash_benchmark/__init__.py @@ -1,3 +1,3 @@ """CodeFlash Benchmark - Pytest benchmarking plugin for codeflash.ai.""" -__version__ = "0.2.0" +from codeflash_benchmark.version import __version__ as __version__ diff --git a/codeflash-benchmark/codeflash_benchmark/version.py b/codeflash-benchmark/codeflash_benchmark/version.py new file mode 100644 index 000000000..18606e8d2 --- /dev/null +++ b/codeflash-benchmark/codeflash_benchmark/version.py @@ -0,0 +1,2 @@ +# These version placeholders will be replaced by uv-dynamic-versioning during build. +__version__ = "0.3.0" diff --git a/codeflash-benchmark/pyproject.toml b/codeflash-benchmark/pyproject.toml index e0ea5cf70..61f5bc3b7 100644 --- a/codeflash-benchmark/pyproject.toml +++ b/codeflash-benchmark/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "codeflash-benchmark" -version = "0.3.0" +dynamic = ["version"] description = "Pytest benchmarking plugin for codeflash.ai - automatic code performance optimization" authors = [{ name = "CodeFlash Inc.", email = "contact@codeflash.ai" }] requires-python = ">=3.9" @@ -25,8 +25,19 @@ Repository = "https://github.com/codeflash-ai/codeflash-benchmark" codeflash-benchmark = "codeflash_benchmark.plugin" [build-system] -requires = ["setuptools>=45", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "uv-dynamic-versioning"] +build-backend = "hatchling.build" -[tool.setuptools] -packages = ["codeflash_benchmark"] +[tool.hatch.version] +source = "uv-dynamic-versioning" + +[tool.uv-dynamic-versioning] +enable = true +style = "pep440" +vcs = "git" + +[tool.hatch.build.hooks.version] +path = "codeflash_benchmark/version.py" +template = """# These version placeholders will be replaced by uv-dynamic-versioning during build. +__version__ = "{version}" +"""