Skip to content

Commit ec3f26d

Browse files
committed
Switch scons build to use setuptools version hook [skip appveyor]
The stanza we used, still published in the Python packaging docs, is now considered the least desirable of the alternatives for keeping a "single package version", so update to a better one. Note there's what's considered a "better" one than this, but it requires Python 3.8 ("provisional" until 3.10) or a backport of importlib.metadata. Signed-off-by: Mats Wichmann <mats@linux.com>
1 parent 9736620 commit ec3f26d

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2929
- Add a timeout to test/ninja/default_targets.py - it's gotten stuck on
3030
the GitHub Windows action and taken the run to the full six hour timeout.
3131
Usually runs in a few second, so set the timeout to 3min (120).
32+
- Switch SCons build to use setuptools' supported version fetcher from
33+
the old homegrown one.
3234

3335

3436
RELEASE 4.8.0 - Sun, 07 Jul 2024 17:22:20 -0700

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ zip-safe = false
5252
include-package-data = true
5353
license-files = ["LICENSE"]
5454

55+
[tool.setuptools.dynamic]
56+
version = {attr = "SCons.__version__"}
57+
5558
[tool.setuptools.packages.find]
5659
exclude = ["template"]
5760
namespaces = false

setup.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,16 @@ def read(rel_path):
1414
return fp.read()
1515

1616

17-
def get_version(rel_path):
18-
for line in read(rel_path).splitlines():
19-
if line.startswith('__version__'):
20-
delim = '"' if '"' in line else "'"
21-
return line.split(delim)[1]
22-
else:
23-
raise RuntimeError("Unable to find version string.")
24-
25-
2617
exclude = ['*Tests']
2718

2819

2920
class build_py(build_py_orig):
3021

3122
def find_package_modules(self, package, package_dir):
32-
"""
33-
Custom module to find package modules.
34-
It will strip out any modules which match the glob patters in exclude above
23+
"""Custom module to find package modules.
24+
25+
Will strip out any modules which match the glob patters in
26+
*exclude* above
3527
"""
3628
modules = super().find_package_modules(package, package_dir)
3729
return [(pkg, mod, file, ) for (pkg, mod, file, ) in modules
@@ -42,5 +34,4 @@ def find_package_modules(self, package, package_dir):
4234
cmdclass={
4335
'build_py': build_py,
4436
},
45-
version=get_version('SCons/__init__.py'),
46-
)
37+
)

0 commit comments

Comments
 (0)