Skip to content

Commit c2805c7

Browse files
committed
chore: rework versioning
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 091357e commit c2805c7

File tree

9 files changed

+72
-58
lines changed

9 files changed

+72
-58
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.6)
1+
cmake_minimum_required(VERSION 3.15)
22

33
#
44
# For more details, see docs/building.rst
@@ -33,7 +33,13 @@ if(CMakePythonDistributions_SUPERBUILD)
3333

3434
option(BUILD_VERBOSE "Build reporting additional information (e.g download progress, ...)" ON)
3535

36-
option(RUN_CMAKE_TEST "Run CMake test suite when built from sources" ON)
36+
if("$env{CIBUILDWHEEL}")
37+
set(CIBW ON)
38+
else()
39+
set(CIBW OFF)
40+
endif()
41+
42+
option(RUN_CMAKE_TEST "Run CMake test suite when built from sources" "${CIBW}")
3743

3844
set(RUN_CMAKE_TEST_EXCLUDE "BootstrapTest" CACHE STRING "CMake test suite exclusion regex")
3945

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The following platforms are supported with binary wheels:
6969
| macOS 11+ | Apple Silicon |
7070
+---------------+--------------------------+
7171

72-
The last version to provide ``manylinux1`` wheels was ``3.22.x``.
72+
The last version to provide ``manylinux1`` wheels was ``3.22.x``. The last version to provide Python 2 to Python 3.6 support was ``3.28.x``.
7373

7474
Maintainers
7575
-----------

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# CMake Python Distributions documentation build configuration file, created by
43
# sphinx-quickstart on Wed Nov 9 02:28:46 2016.

noxfile.py

Lines changed: 14 additions & 0 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
@@ -157,3 +158,16 @@ def bump_openssl(session: nox.Session) -> None:
157158
"scripts/manylinux-build-and-install-openssl.sh",
158159
)
159160
_bump(session, "OpenSSL", "openssl/openssl", "3.0", "scripts/update_openssl_version.py", files)
161+
162+
163+
@nox.session(venv_backend="none")
164+
def tag_release(session: nox.Session) -> None:
165+
"""
166+
Print instructions for tagging a release and pushing it to GitHub.
167+
"""
168+
169+
session.log("Run the following commands to make a release:")
170+
txt = Path("pyproject.toml").read_text()
171+
current_version = next(iter(re.finditer(r'version = "([\d\.]+)"', txt))).group(1)
172+
print(f"git tag --sign -m 'cmake-python-distributions {current_version}' {current_version} main")
173+
print(f"git push origin {current_version}")

pyproject.toml

Lines changed: 27 additions & 28 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,7 +25,6 @@ classifiers = [
2425
"Topic :: Software Development :: Build Tools",
2526
"Typing :: Typed"
2627
]
27-
dynamic = ["version"]
2828
requires-python = ">=3.7"
2929

3030
[project.urls]
@@ -50,73 +50,72 @@ ctest = "cmake:ctest"
5050
[tool.scikit-build]
5151
minimum-version = "0.8"
5252
build-dir = "build/{wheel_tag}"
53-
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
5453
ninja.make-fallback = false
55-
sdist.include = ["src/cmake/_version.py"]
5654
wheel.py-api = "py3"
5755
wheel.expand-macos-universal-tags = true
5856
wheel.install-dir = "cmake/data"
5957

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

6565
[tool.cibuildwheel]
6666
build = "cp39-*"
6767
test-extras = "test"
6868
test-command = "pytest {project}/tests"
6969
build-verbosity = 1
7070

71+
[tool.cibuildwheel.macos.environment]
72+
MACOSX_DEPLOYMENT_TARGET = "10.10"
73+
7174
[tool.cibuildwheel.linux]
72-
before-all = [
73-
'./scripts/manylinux-build-and-install-openssl.sh',
74-
]
75-
environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=4;link=1 -DCMAKE_CXX_STANDARD:STRING=11" }
75+
before-all = "./scripts/manylinux-build-and-install-openssl.sh"
7676

77-
[[tool.cibuildwheel.overrides]]
78-
select = ["*-manylinux_aarch64", "*-manylinux_ppc64le", "*-manylinux_s390x"]
79-
# disable tests on those platforms, QEMU is taking to long for jobs to pass on GHA
80-
environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=4;link=1 -DCMAKE_CXX_STANDARD:STRING=11 -DRUN_CMAKE_TEST:BOOL=OFF" }
77+
[tool.cibuildwheel.linux.config-settings]
78+
"cmake.define.OPENSSL_ROOT_DIR" = "/usr/local/ssl"
79+
"cmake.define.CMAKE_JOB_POOL_COMPILE" = "compile"
80+
"cmake.define.CMAKE_JOB_POOL_LINK" = "link"
81+
"cmake.define.CMAKE_JOB_POOLS" = "compile=4;link=1"
8182

8283
[[tool.cibuildwheel.overrides]]
83-
select = ["*-musllinux_x86_64", "*-musllinux_i686"]
84+
select = ["*-musllinux_*",]
85+
inherit.config-settings = "append"
8486
# disable some tests
8587
# - BootstrapTest fails with custom OpenSSL and probably does not make much sense for this project
8688
# - ExportImport|RunCMake.install|RunCMake.file-GET_RUNTIME_DEPENDENCIES: c.f. https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064
87-
environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=4;link=1 -DRUN_CMAKE_TEST_EXCLUDE:STRING='BootstrapTest|ExportImport|RunCMake.install|RunCMake.RuntimePath|RunCMake.file-GET_RUNTIME_DEPENDENCIES'" }
89+
config-settings."cmake.define.RUN_CMAKE_TEST_EXCLUDE" = "BootstrapTest|ExportImport|RunCMake.install|RunCMake.RuntimePath|RunCMake.file-GET_RUNTIME_DEPENDENCIES"
8890

8991
[[tool.cibuildwheel.overrides]]
90-
select = ["*-musllinux_aarch64", "*-musllinux_ppc64le", "*-musllinux_s390x"]
92+
select = ["*linux_aarch64", "*linux_ppc64le", "*linux_s390x"]
93+
inherit.config-settings = "append"
9194
# disable tests on those platforms, QEMU is taking to long for jobs to pass on GHA
92-
environment = { CMAKE_ARGS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=4;link=1 -DRUN_CMAKE_TEST:BOOL=OFF" }
93-
94-
[tool.cibuildwheel.macos.environment]
95-
MACOSX_DEPLOYMENT_TARGET = "10.10"
95+
config-settings."cmake.define.RUN_CMAKE_TEST" = "OFF"
9696

9797

9898
[tool.ruff]
9999
src = ["src"]
100100

101101
[tool.ruff.lint]
102102
extend-select = [
103-
"B", # flake8-bugbear
104-
"I", # isort
105103
"ARG", # flake8-unused-arguments
104+
"B", # flake8-bugbear
106105
"C4", # flake8-comprehensions
106+
"EXE", # flake8-executable
107+
"G", # flake8-logging-format
108+
"I", # isort
107109
"ICN", # flake8-import-conventions
108110
"ISC", # flake8-implicit-str-concat
109-
"G", # flake8-logging-format
110111
"PGH", # pygrep-hooks
111112
"PIE", # flake8-pie
112113
"PL", # pylint
113114
"PT", # flake8-pytest-style
114115
"RET", # flake8-return
115116
"RUF", # Ruff-specific
116117
"SIM", # flake8-simplify
117-
"EXE", # flake8-executable
118-
"NPY", # NumPy specific rules
119-
"PD", # pandas-vet
118+
"UP", # pyupgrade
120119
]
121120
ignore = [
122121
"PLR09", # Too many X

scripts/update_cmake_version.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
"""
43
Command line executable allowing to update CMakeUrls.cmake given a CMake
54
version.
@@ -68,9 +67,7 @@ def get_cmake_archive_urls_and_sha256s(version, verbose=False):
6867
sha256 = line.split()[0].strip()
6968
identifier = expected_files[file]
7069
shas[identifier] = sha256
71-
assert len(shas) == len(expected_files), "{} != {}".format(
72-
len(shas), len(expected_files)
73-
)
70+
assert len(shas) == len(expected_files), f"{len(shas)} != {len(expected_files)}"
7471

7572
# Get download URLs for each asset
7673
urls = {}
@@ -86,19 +83,19 @@ def get_cmake_archive_urls_and_sha256s(version, verbose=False):
8683
for identifier in set(expected_files.values()) - set(urls.keys()):
8784
missing_files.append(expected_files_by_identifier[identifier])
8885
raise RuntimeError(
89-
"Couldn't find {} at {}".format(missing_files, files_base_url)
86+
f"Couldn't find {missing_files} at {files_base_url}"
9087
)
9188

9289
# combine the URLs and SHA256s into a single dictionary
9390
zipped = {}
9491
for value in expected_files.values():
95-
print("[{}]\n{}\n{}\n".format(value, urls[value], shas[value]))
92+
print(f"[{value}]\n{urls[value]}\n{shas[value]}\n")
9693
zipped[value] = (urls[value], shas[value])
9794
assert len(zipped) == len(expected_files)
9895

9996
if verbose:
10097
for identifier, (url, sha256) in zipped.items():
101-
print("[{}]\n{}\n{}\n".format(identifier, url, sha256))
98+
print(f"[{identifier}]\n{url}\n{sha256}\n")
10299

103100
return zipped
104101

@@ -150,7 +147,7 @@ def update_cmake_urls_script(version):
150147
cmake_urls_filename = "CMakeUrls.cmake"
151148
cmake_urls_filepath = os.path.join(ROOT_DIR, cmake_urls_filename)
152149

153-
msg = "Updating '{}' with CMake version {}".format(cmake_urls_filename, version)
150+
msg = f"Updating '{cmake_urls_filename}' with CMake version {version}"
154151
with _log(msg), open(cmake_urls_filepath, "w") as cmake_file:
155152
cmake_file.write(content)
156153

@@ -159,7 +156,7 @@ def _update_file(filepath, regex, replacement):
159156
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR)
160157
with _log(msg):
161158
pattern = re.compile(regex)
162-
with open(filepath, "r") as doc_file:
159+
with open(filepath) as doc_file:
163160
lines = doc_file.readlines()
164161
updated_content = []
165162
for line in lines:
@@ -172,24 +169,29 @@ def update_docs(version):
172169
pattern = re.compile(
173170
r"CMake \d.(\d)+.\d <https://cmake.org/cmake/help/v\d.(\d)+/index.html>"
174171
)
175-
replacement = "CMake {} <https://cmake.org/cmake/help/v{}/index.html>".format(
176-
version,
177-
_major_minor(version),
178-
)
172+
replacement = f"CMake {version} <https://cmake.org/cmake/help/v{_major_minor(version)}/index.html>"
179173
for filename in ["docs/index.rst", "README.rst"]:
180174
_update_file(os.path.join(ROOT_DIR, filename), pattern, replacement)
181175

182176

183177
def update_tests(version):
184-
pattern = re.compile(r'expected_version = "\d.(\d)+.\d"')
178+
pattern = re.compile(r'expected_version = "\d.\d+.\d"')
185179
replacement = 'expected_version = "%s"' % version
186180
_update_file(
187181
os.path.join(ROOT_DIR, "tests/test_cmake.py"), pattern, replacement
188182
)
189183

190184

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, "tests/test_cmake.py"), pattern, replacement
190+
)
191+
192+
191193
def update_raw_versions(version):
192-
pattern = re.compile(r"\d\.(\d)+\.\d")
194+
pattern = re.compile(r"\d\.\d+\.\d")
193195
replacement = version
194196
_update_file(
195197
os.path.join(ROOT_DIR, "docs/update_cmake_version.rst"), pattern, replacement
@@ -222,6 +224,7 @@ def main():
222224
update_docs(args.cmake_version)
223225
update_tests(args.cmake_version)
224226
update_raw_versions(args.cmake_version)
227+
update_pyproject_toml(args.cmake_version)
225228

226229
if not args.quiet:
227230
msg = """\

scripts/update_openssl_version.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
"""
43
Command line executable allowing to update OpenSSL version.
54
"""
@@ -37,15 +36,15 @@ def get_openssl_sha256(version, verbose=False):
3736
with _log("Collecting SHA256 from '%s'" % files_base_url):
3837
sha256 = requests.get(files_base_url).content.decode("ascii").strip()
3938
if verbose:
40-
print("got sha256: {}".format(sha256))
39+
print(f"got sha256: {sha256}")
4140
return sha256
4241

4342

4443
def _update_file(filepath, regex, replacement):
4544
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR)
4645
with _log(msg):
4746
pattern = re.compile(regex)
48-
with open(filepath, "r") as doc_file:
47+
with open(filepath) as doc_file:
4948
lines = doc_file.readlines()
5049
updated_content = []
5150
for line in lines:

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import sys
32
from contextlib import contextmanager
43

tests/test_cmake.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import os
32
import subprocess
43
import sys
@@ -61,11 +60,7 @@ def _get_scripts():
6160
scripts = []
6261
for file in dist.files:
6362
if os.path.abspath(str(file.locate().parent)) in scripts_paths:
64-
if sys.version_info < (3, 6):
65-
# pre-3.6 behavior is strict
66-
scripts.append(file.locate().resolve())
67-
else:
68-
scripts.append(file.locate().resolve(strict=True))
63+
scripts.append(file.locate().resolve(strict=True))
6964
return scripts
7065

7166

@@ -75,4 +70,4 @@ def test_cmake_script(tool):
7570
scripts = [script for script in _get_scripts() if script.stem == tool]
7671
assert len(scripts) == 1
7772
output = subprocess.check_output([str(scripts[0]), "--version"]).decode("ascii")
78-
assert output.splitlines()[0] == "{} version {}".format(tool, expected_version)
73+
assert output.splitlines()[0] == f"{tool} version {expected_version}"

0 commit comments

Comments
 (0)