Skip to content

Commit 31a1761

Browse files
rtibblesbotclaude
andcommitted
fix: stabilize npm version and rebuild-from-specs hook for CI
- Convert setuptools-scm version to base semver (X.Y.Z) for npm compatibility. Dev/local suffixes change with every commit, causing the rebuild-from-specs hook to perpetually modify js/package.json. - Remove pyproject.toml from rebuild-from-specs trigger pattern since the version is now determined by git tags, not pyproject.toml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 06c8056 commit 31a1761

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
entry: make build
99
language: system
1010
pass_filenames: false
11-
files: (spec/.*\.json|pyproject\.toml)$
11+
files: (spec/.*\.json)$
1212
- repo: https://github.com/pre-commit/pre-commit-hooks
1313
rev: v5.0.0
1414
hooks:

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
"scripts": {
2828
"test": "echo \"Error: no test specified\" && exit 1"
2929
},
30-
"version": "0.2.17.dev7+g16d8ee641.d20260401"
30+
"version": "0.2.17"
3131
}

scripts/generate_from_specs.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,29 @@ def write_constants_src_files(constants_outputs, schemas):
258258
return output_files
259259

260260

261+
def pep440_to_npm_semver(version):
262+
"""Convert a PEP 440 version to npm-compatible semver.
263+
264+
Extracts just the base version (X.Y.Z) to ensure the version is
265+
stable across commits and valid npm semver. Dev/local suffixes from
266+
setuptools-scm change with every commit, which would cause the
267+
rebuild-from-specs pre-commit hook to perpetually modify this file.
268+
On tagged releases, setuptools-scm returns the clean version directly.
269+
"""
270+
match = re.match(r"(\d+\.\d+\.\d+)", version)
271+
return match.group(1) if match else version
272+
273+
261274
def set_package_json_version():
262275
python_version = get_version("le-utils")
276+
npm_version = pep440_to_npm_semver(python_version)
263277

264278
package_json = os.path.join(js_output_dir, "package.json")
265279

266280
with open(package_json, "r") as f:
267281
package = json.load(f)
268282

269-
package["version"] = python_version
283+
package["version"] = npm_version
270284

271285
with open(package_json, "w") as f:
272286
output = json.dumps(package, indent=2, sort_keys=True)

0 commit comments

Comments
 (0)