Skip to content

Commit ca9ecbd

Browse files
ko3n1gclaude
andauthored
build: add dynamic git-versioning, drop rc0, migrate to setuptools (#485)
* build: add dynamic git-versioning, drop rc0, migrate to setuptools - nemo_run/package_info.py: replace packaging.version.Version with MAJOR/MINOR/PATCH/PRE_RELEASE pattern; append +<short-sha> to __version__ at import time via git binary (NO_VCS_VERSION=1 to opt out) - pyproject.toml: switch build backend from hatchling to setuptools, use dynamic version from nemo_run.package_info.__version__, remove packaging runtime dep (no longer needed) - build-test-publish-wheel.yml: pin FW-CI-templates to commit with NO_VCS_VERSION=1 support; switch packaging input to setuptools Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> * fix: suppress I001 import-sorting false positive in package_info.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> * fix: suppress E402 and I001 lint false positives in package_info.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> * chore: update uv.lock for setuptools backend and bump ibm-cloud-sdk-core Regenerate lock file after build backend switch (hatchling → setuptools); bump ibm-cloud-sdk-core 3.18.0 → 3.24.1 to get a pre-built wheel and avoid sdist build failure in fresh CI environments. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> * fix: include all nemo_run subpackages in setuptools build packages = ["nemo_run"] only includes the top-level package; use find with include = ["nemo_run*"] to capture all subpackages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> * ci: pin FW-CI-templates to v0.88.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com> --------- Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 70ed989 commit ca9ecbd

4 files changed

Lines changed: 43 additions & 29 deletions

File tree

.github/workflows/build-test-publish-wheel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ defaults:
2828

2929
jobs:
3030
build-test-publish-wheel:
31-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_build_test_publish_wheel.yml@v0.77.1
31+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_build_test_publish_wheel.yml@v0.88.1
3232
with:
3333
dry-run: true
3434
python-package: nemo_run
3535
python-version: "3.10"
36-
packaging: hatch
36+
packaging: setuptools
3737
secrets:
3838
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
3939
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}

nemo_run/package_info.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,35 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from packaging.version import Version
1514

16-
__version__ = "0.10.0rc0.dev0"
15+
MAJOR = 0
16+
MINOR = 10
17+
PATCH = 0
18+
PRE_RELEASE = ""
1719

18-
MAJOR = Version(__version__).major
19-
MINOR = Version(__version__).minor
20-
PATCH = Version(__version__).micro
21-
if pre := Version(__version__).pre:
22-
_PRE_RELEASE = "".join(map(str, pre))
23-
else:
24-
_PRE_RELEASE = ""
25-
PRE_RELEASE = _PRE_RELEASE
26-
DEV = Version(__version__).dev
20+
# Use the following formatting: (major, minor, patch, pre-release)
21+
VERSION = (MAJOR, MINOR, PATCH, PRE_RELEASE)
22+
23+
__shortversion__ = ".".join(map(str, VERSION[:3]))
24+
__version__ = ".".join(map(str, VERSION[:3])) + "".join(VERSION[3:])
25+
26+
import os as _os # noqa: E402, I001
27+
import subprocess as _subprocess # noqa: E402
28+
29+
30+
if not int(_os.getenv("NO_VCS_VERSION", "0")):
31+
try:
32+
_git = _subprocess.run(
33+
["git", "rev-parse", "--short", "HEAD"],
34+
capture_output=True,
35+
cwd=_os.path.dirname(_os.path.abspath(__file__)),
36+
check=True,
37+
universal_newlines=True,
38+
)
39+
except (_subprocess.CalledProcessError, OSError):
40+
pass
41+
else:
42+
__version__ += f"+{_git.stdout.strip()}"
2743

2844
__package_name__ = "nemo_run"
2945
__contact_names__ = "NVIDIA"

pyproject.toml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ dependencies = [
3030
"networkx >= 3.3",
3131
"omegaconf>=2.3.0",
3232
"leptonai>=0.26.6",
33-
"packaging",
3433
"toml",
3534
]
3635
readme = "README.md"
@@ -96,8 +95,14 @@ docs = [
9695
]
9796

9897
[build-system]
99-
requires = ["hatchling", "hatch-vcs"]
100-
build-backend = "hatchling.build"
98+
requires = ["setuptools>=61.0", "wheel"]
99+
build-backend = "setuptools.build_meta"
100+
101+
[tool.setuptools.packages.find]
102+
include = ["nemo_run*"]
103+
104+
[tool.setuptools.dynamic]
105+
version = { attr = "nemo_run.package_info.__version__" }
101106

102107
[tool.uv]
103108
managed = true
@@ -150,14 +155,6 @@ ignore_errors = true
150155
[tool.coverage.html]
151156
directory = "coverage_html_report"
152157

153-
[tool.hatch.metadata]
154-
allow-direct-references = true
155-
156-
[tool.hatch.build.targets.wheel]
157-
packages = ["nemo_run"]
158-
159-
[tool.hatch.version]
160-
path = "nemo_run/package_info.py"
161158

162159
[tool.ruff]
163160
line-length = 100

uv.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)