Skip to content

Commit 30c0e48

Browse files
Drop setuptools-scm, use uv version + uv build for PyPI publishing
setuptools-scm PRETEND_VERSION env var does not propagate through build isolation. Use uv version to write the tag version directly into pyproject.toml before uv build. Read version at runtime via importlib.metadata.
1 parent df357ea commit 30c0e48

4 files changed

Lines changed: 7 additions & 16 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ jobs:
1515
id-token: write
1616
steps:
1717
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
2018

2119
- uses: astral-sh/setup-uv@v4
2220

2321
- name: Set version from tag
24-
run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
25-
26-
- name: Install dependencies
27-
run: uv sync
22+
run: uv version "${GITHUB_REF_NAME#v}"
2823

2924
- name: Build package
30-
run: uv run python -m build
25+
run: uv build
3126

3227
- name: Publish to PyPI
3328
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ dist/
1212
models/*
1313
.pytest_cache/
1414

15-
# auto-generated version file
16-
mamba_ssm/_version.py
17-
1815
# uv package manager
1916
.venv/
2017
.uv/

mamba_ssm/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from importlib.metadata import PackageNotFoundError, version
2+
13
try:
2-
from mamba_ssm._version import version as __version__
3-
except ImportError:
4+
__version__ = version("mamba-ssm-macos")
5+
except PackageNotFoundError:
46
__version__ = "0.0.0"
57

68
import platform

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=61", "wheel", "setuptools-scm>=8"]
2+
requires = ["setuptools>=61", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.uv]
@@ -59,9 +59,6 @@ dev = [
5959
"build>=1.4.0",
6060
]
6161

62-
[tool.setuptools_scm]
63-
version_file = "mamba_ssm/_version.py"
64-
6562
[tool.setuptools]
6663
packages = [
6764
"mamba_ssm",

0 commit comments

Comments
 (0)