Skip to content

Commit 70c5f9e

Browse files
committed
Apply cookiecutter
1 parent 0a4a43c commit 70c5f9e

24 files changed

+390
-127
lines changed

.ci/gen_certs.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "trustme>=1.2.1,<1.3.0",
5+
# ]
6+
# ///
7+
18
import argparse
29
import os
310
import sys
4-
import typing as t
511

612
import trustme
713

814

9-
def main(argv: t.Optional[t.List[str]] = None) -> None:
10-
if argv is None:
11-
argv = sys.argv[1:]
12-
15+
def main() -> None:
1316
parser = argparse.ArgumentParser(prog="gen_certs")
1417
parser.add_argument(
1518
"-d",
@@ -18,7 +21,7 @@ def main(argv: t.Optional[t.List[str]] = None) -> None:
1821
help="Directory where certificates and keys are written to. Defaults to cwd.",
1922
)
2023

21-
args = parser.parse_args(argv)
24+
args = parser.parse_args(sys.argv[1:])
2225
cert_dir = args.dir
2326

2427
if not os.path.isdir(cert_dir):

.ci/run_container.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export PULP_CONTENT_ORIGIN
7676
${PULP_HTTPS:+--env PULP_HTTPS} \
7777
${PULP_OAUTH2:+--env PULP_OAUTH2} \
7878
${PULP_API_ROOT:+--env PULP_API_ROOT} \
79+
${PULP_DOMAIN_ENABLED:+--env PULP_DOMAIN_ENABLED} \
80+
${PULP_ENABLED_PLUGINS:+--env PULP_ENABLED_PLUGINS} \
7981
--env PULP_CONTENT_ORIGIN \
8082
--detach \
8183
--name "pulp-ephemeral" \

.ci/scripts/calc_constraints.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/python3
2+
# /// script
3+
# requires-python = ">=3.10"
4+
# dependencies = [
5+
# "packaging>=25.0,<25.1",
6+
# "tomli>=2.3.0,<2.4.0;python_version<'3.11'",
7+
# ]
8+
# ///
9+
10+
import argparse
11+
import fileinput
12+
import sys
13+
14+
from packaging.requirements import Requirement
15+
from packaging.version import Version
16+
17+
try:
18+
import tomllib
19+
except ImportError:
20+
import tomli as tomllib
21+
22+
23+
def split_comment(line):
24+
split_line = line.split("#", maxsplit=1)
25+
try:
26+
comment = " # " + split_line[1].strip()
27+
except IndexError:
28+
comment = ""
29+
return split_line[0].strip(), comment
30+
31+
32+
def to_upper_bound(req):
33+
try:
34+
requirement = Requirement(req)
35+
except ValueError:
36+
return f"# UNPARSABLE: {req}"
37+
else:
38+
for spec in requirement.specifier:
39+
if spec.operator == "~=":
40+
return f"# NO BETTER CONSTRAINT: {req}"
41+
if spec.operator == "<=":
42+
operator = "=="
43+
max_version = spec.version
44+
return f"{requirement.name}{operator}{max_version}"
45+
if spec.operator == "<":
46+
operator = "~="
47+
version = Version(spec.version)
48+
if version.micro != 0:
49+
max_version = f"{version.major}.{version.minor}.{version.micro - 1}"
50+
elif version.minor != 0:
51+
max_version = f"{version.major}.{version.minor - 1}"
52+
elif version.major != 0:
53+
max_version = f"{version.major - 1}.0"
54+
else:
55+
return f"# NO BETTER CONSTRAINT: {req}"
56+
return f"{requirement.name}{operator}{max_version}"
57+
return f"# NO UPPER BOUND: {req}"
58+
59+
60+
def to_lower_bound(req):
61+
try:
62+
requirement = Requirement(req)
63+
except ValueError:
64+
return f"# UNPARSABLE: {req}"
65+
else:
66+
for spec in requirement.specifier:
67+
if spec.operator == ">=":
68+
if requirement.name == "pulpcore":
69+
# Currently an exception to allow for pulpcore bugfix releases.
70+
# TODO Semver libraries should be allowed too.
71+
operator = "~="
72+
else:
73+
operator = "=="
74+
min_version = spec.version
75+
return f"{requirement.name}{operator}{min_version}"
76+
return f"# NO LOWER BOUND: {req}"
77+
78+
79+
def main():
80+
"""Calculate constraints for the lower bound of dependencies where possible."""
81+
parser = argparse.ArgumentParser(
82+
prog=sys.argv[0],
83+
description="Calculate constraints for the lower or upper bound of dependencies where "
84+
"possible.",
85+
)
86+
parser.add_argument("-u", "--upper", action="store_true")
87+
parser.add_argument("filename", nargs="*")
88+
args = parser.parse_args()
89+
90+
modifier = to_upper_bound if args.upper else to_lower_bound
91+
92+
req_files = [filename for filename in args.filename if not filename.endswith("pyproject.toml")]
93+
pyp_files = [filename for filename in args.filename if filename.endswith("pyproject.toml")]
94+
if req_files:
95+
with fileinput.input(files=req_files) as req_file:
96+
for line in req_file:
97+
if line.strip().startswith("#"):
98+
# Shortcut comment only lines
99+
print(line.strip())
100+
else:
101+
req, comment = split_comment(line)
102+
new_req = modifier(req)
103+
print(new_req + comment)
104+
for filename in pyp_files:
105+
with open(filename, "rb") as fp:
106+
pyproject = tomllib.load(fp)
107+
for req in pyproject["project"]["dependencies"]:
108+
new_req = modifier(req)
109+
print(new_req)
110+
optional_dependencies = pyproject["project"].get("optional-dependencies")
111+
if optional_dependencies:
112+
for opt in optional_dependencies.values():
113+
for req in opt:
114+
new_req = modifier(req)
115+
print(new_req)
116+
117+
118+
if __name__ == "__main__":
119+
main()

.ci/scripts/check_cli_dependencies.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
#!/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.11"
4+
# dependencies = [
5+
# "packaging>=25.0,<25.1",
6+
# ]
7+
# ///
28

3-
import tomllib
9+
import typing as t
410
from pathlib import Path
511

12+
import tomllib
613
from packaging.requirements import Requirement
714

15+
GLUE_DIR = "pulp-glue-gem"
16+
17+
18+
def dependencies(path: Path) -> t.Iterator[Requirement]:
19+
with (path / "pyproject.toml").open("rb") as fp:
20+
pyproject = tomllib.load(fp)
21+
22+
return (Requirement(r) for r in pyproject["project"]["dependencies"])
23+
24+
825
if __name__ == "__main__":
926
base_path = Path(__file__).parent.parent.parent
10-
glue_path = "pulp-glue-gem"
11-
with (base_path / "pyproject.toml").open("rb") as fp:
12-
cli_pyproject = tomllib.load(fp)
13-
14-
cli_dependency = next(
15-
(
16-
Requirement(r)
17-
for r in cli_pyproject["project"]["dependencies"]
18-
if r.startswith("pulp-cli")
19-
)
20-
)
21-
22-
with (base_path / glue_path / "pyproject.toml").open("rb") as fp:
23-
glue_pyproject = tomllib.load(fp)
24-
25-
glue_dependency = next(
26-
(
27-
Requirement(r)
28-
for r in glue_pyproject["project"]["dependencies"]
29-
if r.startswith("pulp-glue")
30-
)
31-
)
27+
glue_path = base_path / GLUE_DIR
28+
29+
cli_dependency = next((r for r in dependencies(base_path) if r.name == "pulp-cli"))
30+
glue_dependency = next((r for r in dependencies(glue_path) if r.name == "pulp-glue"))
3231

3332
if cli_dependency.specifier != glue_dependency.specifier:
3433
print("🪢 CLI and GLUE dependencies mismatch:")
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
#!/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.11"
4+
# dependencies = [
5+
# "packaging>=25.0,<25.1",
6+
# ]
7+
# ///
28

3-
import click
4-
from packaging.version import parse
9+
from importlib import metadata
510

6-
if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"):
7-
print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧")
8-
print("🔧 Please run `pip install click~=8.1.1` first. 🔨")
9-
exit(1)
11+
from packaging.version import Version
12+
13+
if __name__ == "__main__":
14+
click_version = Version(metadata.version("click"))
15+
if click_version < Version("8.1.1"):
16+
print("🚧 Linting with mypy is currently only supported with click>=8.1.1. 🚧")
17+
print("🔧 Please run `pip install click>=8.1.1` first. 🔨")
18+
exit(1)

.ci/scripts/collect_changes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.11"
4+
# dependencies = [
5+
# "gitpython>=3.1.46,<3.2.0",
6+
# "packaging>=25.0,<25.1",
7+
# ]
8+
# ///
29

310
import itertools
411
import os
512
import re
6-
import tomllib
713

14+
import tomllib
815
from git import GitCommandError, Repo
916
from packaging.version import parse as parse_version
1017

.ci/scripts/pr_labels.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.11"
4+
# dependencies = [
5+
# "gitpython>=3.1.46,<3.2.0",
6+
# ]
7+
# ///
28

39
# This script is running with elevated privileges from the main branch against pull requests.
410

511
import re
612
import sys
7-
import tomllib
813
from pathlib import Path
914

15+
import tomllib
1016
from git import Repo
1117

1218

.ci/scripts/validate_commit_message.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
# /// script
2+
# requires-python = ">=3.11"
3+
# dependencies = [
4+
# "gitpython>=3.1.46,<3.2.0",
5+
# ]
6+
# ///
7+
18
import os
29
import re
310
import subprocess
411
import sys
5-
import tomllib
612
from pathlib import Path
713

14+
import tomllib
815
from github import Github
916

1017
with open("pyproject.toml", "rb") as fp:

.github/dependabot.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
build:
99
runs-on: "ubuntu-latest"
1010
steps:
11-
- uses: "actions/checkout@v4"
11+
- uses: "actions/checkout@v5"
1212
- uses: "actions/cache@v4"
1313
with:
1414
path: "~/.cache/pip"
@@ -17,9 +17,9 @@ jobs:
1717
${{ runner.os }}-pip-
1818
1919
- name: "Set up Python"
20-
uses: "actions/setup-python@v5"
20+
uses: "actions/setup-python@v6"
2121
with:
22-
python-version: "3.11"
22+
python-version: "3.14"
2323
- name: "Install python dependencies"
2424
run: |
2525
pip install build setuptools wheel

0 commit comments

Comments
 (0)