Skip to content

Commit 099bfe2

Browse files
committed
chore: rework versioning
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 18d6a6e commit 099bfe2

File tree

6 files changed

+54
-35
lines changed

6 files changed

+54
-35
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ The following platforms are supported with binary wheels:
7070
+---------------+--------------------------+
7171

7272
The last version to provide ``manylinux1`` wheels was ``3.22.x``.
73+
The last version to provide Python 2 to Python 3.6 support was ``3.28.x``.
7374

7475
Maintainers
7576
-----------

docs/conf.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
# documentation root, use os.path.abspath to make it absolute, like shown here.
1717
#
1818
import sys
19+
from pathlib import Path
1920

20-
if sys.version_info < (3, 8):
21-
import importlib_metadata as metadata
21+
if sys.version_info < (3, 11):
22+
from tomli import tomllib
2223
else:
23-
from importlib import metadata
24+
import tomllib
25+
26+
DIR = Path(__file__).parent.resolve()
27+
pyproject = DIR.parent / "pyproject.toml"
2428

2529
# -- Options for blockdiag extension --------------------------------------
2630

@@ -61,11 +65,11 @@
6165
# The version info for the project you're documenting, acts as replacement for
6266
# |version| and |release|, also used in various other places throughout the
6367
# built documents.
64-
#
65-
# The short X.Y version.
66-
version = metadata.version("cmake")
67-
# The full version, including alpha/beta/rc tags.
68-
release = version
68+
with pyproject.open('rb') as f:
69+
release = tomllib.load(f)["project"]["version"]
70+
71+
# A shorter version
72+
version = ".".join(release.split(".")[:2])
6973

7074
# The language for content autogenerated by Sphinx. Refer to documentation
7175
# for a list of supported languages.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
docutils
22
funcparserlib>=1.0.0
33
furo
4-
importlib_metadata; python_version<"3.8"
54
pillow<10
65
pygments
7-
scikit-build
86
sphinx
97
sphinxcontrib-blockdiag # old, not compatible with pillow 10+
8+
tomli; python_version<"3.11"

noxfile.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import re
23
from pathlib import Path
34

45
import nox
@@ -57,7 +58,7 @@ def tests(session: nox.Session) -> str:
5758
@nox.session(reuse_venv=True)
5859
def docs(session: nox.Session) -> None:
5960
"""
60-
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.
61+
Build the docs. Pass "--non-interactive" to avoid serve. Pass "-- -b linkcheck" to check links.
6162
"""
6263

6364
parser = argparse.ArgumentParser()
@@ -66,16 +67,10 @@ def docs(session: nox.Session) -> None:
6667
"-b", dest="builder", default="html", help="Build target (default: html)"
6768
)
6869
args, posargs = parser.parse_known_args(session.posargs)
70+
serve = args.builder == "html" and session.interactive
6971

70-
if args.builder != "html" and args.serve:
71-
session.error("Must not specify non-HTML builder with --serve")
72-
73-
extra_installs = ["sphinx-autobuild"] if args.serve else []
74-
75-
wheel = build(session)
76-
session.install("-r", "docs/requirements-docs.txt", *extra_installs)
77-
session.install(f"./dist/{wheel}")
78-
72+
extra_installs = ["sphinx-autobuild"] if serve else []
73+
session.install("-r", "docs/requirements.txt", *extra_installs)
7974
session.chdir("docs")
8075

8176
if args.builder == "linkcheck":
@@ -93,12 +88,13 @@ def docs(session: nox.Session) -> None:
9388
*posargs,
9489
)
9590

96-
if args.serve:
97-
session.run("sphinx-autobuild", *shared_args)
91+
if serve:
92+
session.run(
93+
"sphinx-autobuild", "--open-browser", "--ignore=.build", *shared_args
94+
)
9895
else:
9996
session.run("sphinx-build", "--keep-going", *shared_args)
10097

101-
10298
def _bump(session: nox.Session, name: str, repository: str, branch: str, script: str, files) -> None:
10399
parser = argparse.ArgumentParser()
104100
parser.add_argument(
@@ -157,3 +153,16 @@ def bump_openssl(session: nox.Session) -> None:
157153
"scripts/manylinux-build-and-install-openssl.sh",
158154
)
159155
_bump(session, "OpenSSL", "openssl/openssl", "3.0", "scripts/update_openssl_version.py", files)
156+
157+
158+
@nox.session(venv_backend="none")
159+
def tag_release(session: nox.Session) -> None:
160+
"""
161+
Print instructions for tagging a release and pushing it to GitHub.
162+
"""
163+
164+
session.log("Run the following commands to make a release:")
165+
txt = Path("pyproject.toml").read_text()
166+
current_version = next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)
167+
print(f"git tag --sign -m 'cmake-python-distributions {current_version}' {current_version} main")
168+
print(f"git push origin {current_version}")

pyproject.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "cmake"
7+
version = "3.29.0"
78
description = "CMake is an open-source, cross-platform family of tools designed to build, test and package software"
89
keywords = ["CMake", "build", "c++", "fortran", "cross-platform", "cross-compilation"]
910
readme = "README.rst"
@@ -24,10 +25,6 @@ classifiers = [
2425
"Topic :: Software Development :: Build Tools",
2526
"Typing :: Typed"
2627
]
27-
dependencies = [
28-
"importlib_metadata>=1.4; python_version<'3.8'",
29-
]
30-
dynamic = ["version"]
3128
requires-python = ">=3.7"
3229

3330
[project.urls]
@@ -52,17 +49,17 @@ ctest = "cmake:ctest"
5249
[tool.scikit-build]
5350
minimum-version = "0.8"
5451
build-dir = "build/{wheel_tag}"
55-
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
5652
ninja.make-fallback = false
57-
sdist.include = ["src/cmake/_version.py"]
5853
wheel.py-api = "py3"
5954
wheel.expand-macos-universal-tags = true
6055
wheel.install-dir = "cmake/data"
6156

62-
[tool.setuptools_scm]
63-
write_to = "src/cmake/_version.py"
64-
# Setuptools-scm includes type annotations in the default template
65-
write_to_template = "version = '{version}'"
57+
[[tool.scikit-build.generate]]
58+
path = "cmake/_version.py"
59+
template = '''
60+
version = "${version}"
61+
'''
62+
6663

6764
[tool.cibuildwheel]
6865
build = "cp39-*"

scripts/update_cmake_version.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,23 @@ def update_docs(version):
175175

176176

177177
def update_tests(version):
178-
pattern = re.compile(r'expected_version = "\d.(\d)+.\d"')
178+
pattern = re.compile(r'expected_version = "\d.\d+.\d"')
179179
replacement = 'expected_version = "%s"' % version
180180
_update_file(
181181
os.path.join(ROOT_DIR, "tests/test_cmake.py"), pattern, replacement
182182
)
183183

184184

185+
def update_pyproject_toml(version):
186+
pattern = re.compile(r'^version = "[\w\.]+"$')
187+
replacement = 'version = "%s"' % version
188+
_update_file(
189+
os.path.join(ROOT_DIR, "pyproject.toml"), pattern, replacement
190+
)
191+
192+
185193
def update_raw_versions(version):
186-
pattern = re.compile(r"\d\.(\d)+\.\d")
194+
pattern = re.compile(r"\d\.\d+\.\d")
187195
replacement = version
188196
_update_file(
189197
os.path.join(ROOT_DIR, "docs/update_cmake_version.rst"), pattern, replacement
@@ -216,6 +224,7 @@ def main():
216224
update_docs(args.cmake_version)
217225
update_tests(args.cmake_version)
218226
update_raw_versions(args.cmake_version)
227+
update_pyproject_toml(args.cmake_version)
219228

220229
if not args.quiet:
221230
msg = """\

0 commit comments

Comments
 (0)