Skip to content

Commit 52c8413

Browse files
authored
Merge pull request #239 from mdellweg/patchback/backports/0.4/89646819e938d442dcb093b202c1cd15d859e166/pr-238
Patchback/backports/0.4/89646819e938d442dcb093b202c1cd15d859e166/pr 238
2 parents ea60bb6 + ef6a754 commit 52c8413

22 files changed

+257
-88
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/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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/bin/env python3
2-
import tomllib
2+
# /// script
3+
# requires-python = ">=3.11"
4+
# dependencies = [
5+
# "packaging>=25.0,<25.1",
6+
# ]
7+
# ///
8+
39
import typing as t
410
from pathlib import Path
511

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

815
GLUE_DIR = "pulp-glue-deb"

.ci/scripts/check_click_for_mypy.py

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

39
from importlib import metadata
410

.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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/collect_changes.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
with:
1313
ref: "main"
1414
fetch-depth: 0
15-
- uses: "actions/setup-python@v5"
15+
- uses: "actions/setup-python@v6"
1616
with:
17-
python-version: "3.11"
17+
python-version: "3.x"
1818
- name: "Setup git"
1919
run: |
2020
git config user.name pulpbot

0 commit comments

Comments
 (0)