Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# CMake Python Distributions documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 9 02:28:46 2016.
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,22 @@ src = ["src"]

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
"UP", # pyupgrade
]
ignore = [
"PLR09", # Too many X
Expand Down
20 changes: 7 additions & 13 deletions scripts/update_cmake_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Command line executable allowing to update CMakeUrls.cmake given a CMake
version.
Expand Down Expand Up @@ -68,9 +67,7 @@ def get_cmake_archive_urls_and_sha256s(version, verbose=False):
sha256 = line.split()[0].strip()
identifier = expected_files[file]
shas[identifier] = sha256
assert len(shas) == len(expected_files), "{} != {}".format(
len(shas), len(expected_files)
)
assert len(shas) == len(expected_files), f"{len(shas)} != {len(expected_files)}"

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

# combine the URLs and SHA256s into a single dictionary
zipped = {}
for value in expected_files.values():
print("[{}]\n{}\n{}\n".format(value, urls[value], shas[value]))
print(f"[{value}]\n{urls[value]}\n{shas[value]}\n")
zipped[value] = (urls[value], shas[value])
assert len(zipped) == len(expected_files)

if verbose:
for identifier, (url, sha256) in zipped.items():
print("[{}]\n{}\n{}\n".format(identifier, url, sha256))
print(f"[{identifier}]\n{url}\n{sha256}\n")

return zipped

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

msg = "Updating '{}' with CMake version {}".format(cmake_urls_filename, version)
msg = f"Updating '{cmake_urls_filename}' with CMake version {version}"
with _log(msg), open(cmake_urls_filepath, "w") as cmake_file:
cmake_file.write(content)

Expand All @@ -159,7 +156,7 @@ def _update_file(filepath, regex, replacement):
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR)
with _log(msg):
pattern = re.compile(regex)
with open(filepath, "r") as doc_file:
with open(filepath) as doc_file:
lines = doc_file.readlines()
updated_content = []
for line in lines:
Expand All @@ -172,10 +169,7 @@ def update_docs(version):
pattern = re.compile(
r"CMake \d.(\d)+.\d <https://cmake.org/cmake/help/v\d.(\d)+/index.html>"
)
replacement = "CMake {} <https://cmake.org/cmake/help/v{}/index.html>".format(
version,
_major_minor(version),
)
replacement = f"CMake {version} <https://cmake.org/cmake/help/v{_major_minor(version)}/index.html>"
for filename in ["docs/index.rst", "README.rst"]:
_update_file(os.path.join(ROOT_DIR, filename), pattern, replacement)

Expand Down
5 changes: 2 additions & 3 deletions scripts/update_openssl_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Command line executable allowing to update OpenSSL version.
"""
Expand Down Expand Up @@ -37,15 +36,15 @@ def get_openssl_sha256(version, verbose=False):
with _log("Collecting SHA256 from '%s'" % files_base_url):
sha256 = requests.get(files_base_url).content.decode("ascii").strip()
if verbose:
print("got sha256: {}".format(sha256))
print(f"got sha256: {sha256}")
return sha256


def _update_file(filepath, regex, replacement):
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR)
with _log(msg):
pattern = re.compile(regex)
with open(filepath, "r") as doc_file:
with open(filepath) as doc_file:
lines = doc_file.readlines()
updated_content = []
for line in lines:
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys
from contextlib import contextmanager

Expand Down
9 changes: 2 additions & 7 deletions tests/test_cmake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import subprocess
import sys
Expand Down Expand Up @@ -61,11 +60,7 @@ def _get_scripts():
scripts = []
for file in dist.files:
if os.path.abspath(str(file.locate().parent)) in scripts_paths:
if sys.version_info < (3, 6):
# pre-3.6 behavior is strict
scripts.append(file.locate().resolve())
else:
scripts.append(file.locate().resolve(strict=True))
scripts.append(file.locate().resolve(strict=True))
return scripts


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