Skip to content

Commit dfcac93

Browse files
committed
fixing version tracking
1 parent 8d418fe commit dfcac93

File tree

4 files changed

+27
-52
lines changed

4 files changed

+27
-52
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.PHONY : clean build upload release
22

3+
4+
35
clean:
46
rm -rf build
57
rm -rf dist
@@ -20,15 +22,15 @@ upload:
2022

2123
# Get current version
2224
version:
23-
@uv run python -c "import setuptools_scm; print(setuptools_scm.get_version())"
25+
@uv run python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_bytes().decode()).get('project',{}).get('version','unknown'))"
2426

2527
# Create a new release
2628
release:
2729
@if [ "$$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then echo "Switch to main before releasing"; exit 1; fi
2830
@if [ -n "$$(git status --porcelain)" ]; then echo "Working tree not clean"; git status; exit 1; fi
2931
@git pull --ff-only
30-
@uv run pytest || { echo "Tests failed"; exit 1; }
31-
@read -p "Enter version (e.g., 0.3.2): " version; \
32+
@version=$$(uv run python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_bytes().decode())['project']['version'])"); \
33+
uv run pytest || { echo "Tests failed"; exit 1; }; \
3234
git tag -a "v$$version" -m "Release v$$version"; \
3335
git push origin main && git push origin --tags; \
3436
make clean build upload

docs/DEV_GUIDE.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ authors:
3535
source .venv/bin/activate
3636
uv pip install ".[dev]"
3737

38-
# 4. Sanity-check version resolution
39-
make version
38+
# 4. Set the release version in pyproject.toml
39+
# - Edit [project] version = "X.Y.Z"
40+
# - Commit the change on main
41+
uv run python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_bytes().decode())['project']['version'])" # verify
4042

4143
# 5. Create the release
4244
make release
4345
# This will:
4446
# - Verify you are on main and working tree is clean
4547
# - Pull with --ff-only
48+
# - Read version from pyproject.toml and tag vX.Y.Z
4649
# - Run tests (uv run pytest)
47-
# - Prompt for version number
48-
# - Create and push git tag
4950
# - Build sdist+wheel (uv run python -m build)
5051
# - Upload to PyPI (uvx twine upload)
5152

@@ -75,14 +76,13 @@ Follow semantic versioning:
7576
2. **Always release from `main` branch**
7677

7778
- Makefile enforces releasing from `main` with a clean tree
78-
- Ensures PyPI version matches `main`
79+
- Version is stored in `pyproject.toml` and tags are derived from it
7980
- Git tags point to correct code
8081
- Tests are run automatically during release
8182

82-
3. **Development versions**
83-
- During development: `0.3.1.dev123+gabc123`
84-
- After release: `0.3.2`
85-
- Handled automatically by setuptools_scm
83+
3. **Version management**
84+
- Bump `[project].version` in `pyproject.toml` before releases
85+
- Example: 0.3.1 → 0.4.0 for new features
8686

8787
## Using uv for Development
8888

@@ -238,4 +238,9 @@ All dependencies are managed in `pyproject.toml`:
238238
- Runtime dependencies under `[project]`
239239
- Development dependencies under `[project.optional-dependencies]` (includes `twine` for uploads)
240240

241+
Versioning is manual (single source of truth):
242+
243+
- Set `[project].version` in `pyproject.toml` (e.g., `0.4.0`)
244+
- `seqspec/__init__.py` reads the installed distribution version via `importlib.metadata`
245+
241246
No separate `requirements.txt` or `dev-requirements.txt` files are needed.

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "setuptools_scm>=7.0"]
2+
requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "seqspec"
7-
dynamic = ["version"]
7+
version = "0.4.0"
88
description = "A tool for working with sequencing specifications"
99
readme = "README.md"
1010
requires-python = ">=3.12"
@@ -45,7 +45,6 @@ dev = [
4545
"pytest-mock",
4646
"pre-commit",
4747
"build",
48-
"setuptools_scm>=7.0",
4948
"ruff",
5049
"twine",
5150
]
@@ -64,10 +63,7 @@ package-dir = { "" = "." }
6463
[tool.setuptools.package-data]
6564
"seqspec" = ["schema/*"]
6665

67-
[tool.setuptools_scm]
68-
write_to = "seqspec/__init__.py"
69-
version_scheme = "python-simplified-semver"
70-
local_scheme = "node-and-date"
66+
7167

7268
[tool.pytest.ini_options]
7369
testpaths = ["tests"]
@@ -104,7 +100,6 @@ dev = [
104100
"pytest-mock>=3.14.0",
105101
"pre-commit>=4.2.0",
106102
"build>=1.0.0",
107-
"setuptools_scm>=7.0",
108103
"ruff>=0.9.0",
109104
]
110105

seqspec/__init__.py

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
1-
# file generated by setuptools-scm
2-
# don't change, don't track in version control
1+
from importlib.metadata import version as _pkg_version
32

4-
__all__ = [
5-
"__version__",
6-
"__version_tuple__",
7-
"version",
8-
"version_tuple",
9-
"__commit_id__",
10-
"commit_id",
11-
]
12-
13-
TYPE_CHECKING = False
14-
if TYPE_CHECKING:
15-
from typing import Tuple, Union
16-
17-
VERSION_TUPLE = Tuple[Union[int, str], ...]
18-
COMMIT_ID = Union[str, None]
19-
else:
20-
VERSION_TUPLE = object
21-
COMMIT_ID = object
22-
23-
version: str
24-
__version__: str
25-
__version_tuple__: VERSION_TUPLE
26-
version_tuple: VERSION_TUPLE
27-
commit_id: COMMIT_ID
28-
__commit_id__: COMMIT_ID
29-
30-
__version__ = version = "0.3.2.dev43+gf8b27c338.d20250821"
31-
__version_tuple__ = version_tuple = (0, 3, 2, "dev43", "gf8b27c338.d20250821")
32-
33-
__commit_id__ = commit_id = "gf8b27c338"
3+
try:
4+
__version__ = _pkg_version("seqspec")
5+
except Exception:
6+
__version__ = "@+unknown"

0 commit comments

Comments
 (0)