Skip to content

Commit e59dad9

Browse files
committed
hatchling versioning; ci updates
1 parent 774174b commit e59dad9

File tree

6 files changed

+116
-4
lines changed

6 files changed

+116
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ubuntu-latest, macos-latest]
18-
python-version: ["3.10", "3.11", "3.12", "3.13"]
18+
python-version: ["3.11", "3.12", "3.13"]
1919

2020
steps:
2121
- name: Checkout code

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ venv.bak/
7979
*.tar.gz
8080
*.zip
8181

82+
# Auto-generated version file
83+
src/data_designer/_version.py
84+
8285
# Local scratch space
8386
.scratch/
8487

VERSIONING.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Versioning Guide
2+
3+
DataDesigner uses **semantic versioning** with automated version management via `hatch-vcs`.
4+
5+
## How It Works
6+
7+
Versions are automatically derived from git tags:
8+
9+
- **No tag**: `0.1.0.dev<N>+g<commit-hash>` (development version)
10+
- **Tagged commit**: `1.2.3` (release version)
11+
- **After tag**: `1.2.4.dev<N>+g<commit-hash>` (next development version)
12+
13+
## Version Format
14+
15+
```
16+
MAJOR.MINOR.PATCH
17+
```
18+
19+
- **MAJOR**: Breaking changes (incompatible API changes)
20+
- **MINOR**: New features (backward-compatible)
21+
- **PATCH**: Bug fixes (backward-compatible)
22+
23+
## Creating a Release
24+
25+
When ready to release version `X.Y.Z`:
26+
27+
```bash
28+
# Tag the release
29+
git tag vX.Y.Z
30+
31+
# Push the tag
32+
git push origin vX.Y.Z
33+
34+
# Build and publish
35+
uv build
36+
uv publish
37+
```
38+
39+
Example:
40+
```bash
41+
git tag v0.1.0
42+
git push origin v0.1.0
43+
```
44+
45+
## Accessing Version in Code
46+
47+
Users can access the version:
48+
49+
```python
50+
import data_designer
51+
52+
print(data_designer.__version__)
53+
# Output: 0.1.0 (or 0.1.0.dev18+ga7496d01a if between releases)
54+
```
55+
56+
## Technical Details
57+
58+
- Version source: Git tags via `hatch-vcs`
59+
- Version file: `src/data_designer/_version.py` (auto-generated, not tracked in git)
60+
- Fallback strategy:
61+
1. Try to import from `_version.py` (generated during build)
62+
2. Fall back to `importlib.metadata.version()` (works for editable installs)
63+
3. Final fallback: `0.0.0.dev0+unknown` (if package not installed)
64+
- Configuration: [pyproject.toml](pyproject.toml)
65+
66+
## For Collaborators
67+
68+
When you clone the repository and run `uv sync`, you won't have `_version.py` in your local directory. This is expected! The version system has a fallback:
69+
70+
```bash
71+
git clone <repo>
72+
uv sync
73+
uv run python -c "from data_designer import __version__; print(__version__)"
74+
# Works! Uses importlib.metadata fallback
75+
```
76+
77+
The `_version.py` file is auto-generated during:
78+
- Editable installs (`uv pip install -e .`)
79+
- Package builds (`uv build`)
80+
- CI/CD builds
81+
82+
You don't need to commit or manually create this file.
83+
84+
## Development Workflow
85+
86+
1. **During development**: Commit normally, version auto-increments as dev versions
87+
2. **Ready to release**: Create and push a git tag (e.g., `v0.1.0`)
88+
3. **After release**: Continue development, version becomes next dev version (e.g., `0.1.1.dev1`)
89+
90+
No manual version bumping required!

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "data-designer"
3-
version = "0.0.1"
3+
dynamic = ["version"]
44
description = "General framework for synthetic data generation"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -63,9 +63,16 @@ dev = [
6363
]
6464

6565
[build-system]
66-
requires = ["hatchling"]
66+
requires = ["hatchling", "hatch-vcs"]
6767
build-backend = "hatchling.build"
6868

69+
[tool.hatch.version]
70+
source = "vcs"
71+
fallback-version = "0.1.0.dev0"
72+
73+
[tool.hatch.build.hooks.vcs]
74+
version-file = "src/data_designer/_version.py"
75+
6976
[tool.pytest.ini_options]
7077
testpaths = ["tests"]
7178
asyncio_default_fixture_loop_scope = "session"

src/data_designer/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
4+
try:
5+
from data_designer._version import __version__
6+
except ImportError:
7+
# Fallback for editable installs without build
8+
try:
9+
from importlib.metadata import version
10+
11+
__version__ = version("data-designer")
12+
except Exception:
13+
__version__ = "0.0.0.dev0+unknown"
14+
15+
__all__ = ["__version__"]

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)