Skip to content

Commit 9115905

Browse files
authored
fix: setuptools_scm 8 change (#509)
Fixing #507. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 2ea7392 commit 9115905

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/configuration.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,18 @@ dynamic = ["version"]
402402
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
403403
sdist.include = ["src/package/_version.py"]
404404

405-
[tool.setuptools_scm]
405+
[tool.setuptools_scm] # Section required
406406
write_to = "src/package/_version.py"
407407
```
408408

409409
This sets the python project version according to
410410
[git tags](https://github.com/pypa/setuptools_scm/blob/fb261332d9b46aa5a258042d85baa5aa7b9f4fa2/README.rst#default-versioning-scheme)
411411
or a
412412
[`.git_archival.txt`](https://github.com/pypa/setuptools_scm/blob/fb261332d9b46aa5a258042d85baa5aa7b9f4fa2/README.rst#git-archives)
413-
file, or equivalents for other VCS systems. With this, you may also to set the
414-
cmake project version equivalently, e.g. using
413+
file, or equivalents for other VCS systems.
414+
415+
If you need to set the CMake project version without scikit-build-core (which
416+
provides `${SKBUILD_PROJECT_VERSION}`), you can use something like
415417
[`DynamicVersion` module](https://github.com/LecrisUT/CMakeExtraUtils/blob/180604da50a3c3588f9d04e4ebc6abb4e5a0d234/cmake/DynamicVersion.md)
416418
from
417419
[github.com/LecrisUT/CMakeExtraUtils](https://github.com/LecrisUT/CMakeExtraUtils):

src/scikit_build_core/metadata/setuptools_scm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ def dynamic_metadata(
2525
from setuptools_scm import Configuration, _get_version
2626

2727
config = Configuration.from_file("pyproject.toml")
28-
version: str = _get_version(config)
28+
version: str
29+
try:
30+
version = _get_version(config, force_write_version_files=True)
31+
except TypeError: # setuptools_scm < 8
32+
version = _get_version(config)
2933

3034
return version
3135

0 commit comments

Comments
 (0)