Skip to content

Commit 312cf15

Browse files
authored
chore: use uv pip compile (#1778)
1 parent 6537b8f commit 312cf15

9 files changed

+60
-130
lines changed

cibuildwheel/options.py

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def _resolve_cascade(
215215
return result
216216

217217

218+
# pylint: disable-next=inconsistent-return-statements
218219
def _merge_values(before: str | None, after: str, rule: InheritRule, merge_sep: str | None) -> str:
219220
if rule == InheritRule.NONE:
220221
return after
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.10
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.10
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
148
# via virtualenv
9+
importlib-metadata==7.1.0
10+
# via build
1511
packaging==24.0
1612
# via
1713
# build
1814
# delocate
15+
pip==24.0
1916
platformdirs==4.2.0
2017
# via virtualenv
2118
pyproject-hooks==1.0.0
@@ -27,8 +24,5 @@ tomli==2.0.1
2724
typing-extensions==4.10.0
2825
# via delocate
2926
virtualenv==20.25.1
30-
# via -r cibuildwheel/resources/constraints.in
31-
32-
# The following packages are considered to be unsafe in a requirements file:
33-
pip==24.0
34-
# via -r cibuildwheel/resources/constraints.in
27+
zipp==3.18.1
28+
# via importlib-metadata
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.11
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
@@ -16,15 +10,11 @@ packaging==24.0
1610
# via
1711
# build
1812
# delocate
13+
pip==24.0
1914
platformdirs==4.2.0
2015
# via virtualenv
2116
pyproject-hooks==1.0.0
2217
# via build
2318
typing-extensions==4.10.0
2419
# via delocate
2520
virtualenv==20.25.1
26-
# via -r cibuildwheel/resources/constraints.in
27-
28-
# The following packages are considered to be unsafe in a requirements file:
29-
pip==24.0
30-
# via -r cibuildwheel/resources/constraints.in
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.12
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.12
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
@@ -16,15 +10,11 @@ packaging==24.0
1610
# via
1711
# build
1812
# delocate
13+
pip==24.0
1914
platformdirs==4.2.0
2015
# via virtualenv
2116
pyproject-hooks==1.0.0
2217
# via build
2318
typing-extensions==4.10.0
2419
# via delocate
2520
virtualenv==20.25.1
26-
# via -r cibuildwheel/resources/constraints.in
27-
28-
# The following packages are considered to be unsafe in a requirements file:
29-
pip==24.0
30-
# via -r cibuildwheel/resources/constraints.in
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.7
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.7
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.12.2
@@ -20,6 +14,7 @@ packaging==24.0
2014
# via
2115
# build
2216
# delocate
17+
pip==24.0
2318
platformdirs==4.0.0
2419
# via virtualenv
2520
pyproject-hooks==1.0.0
@@ -34,10 +29,5 @@ typing-extensions==4.7.1
3429
# importlib-metadata
3530
# platformdirs
3631
virtualenv==20.25.1
37-
# via -r cibuildwheel/resources/constraints.in
3832
zipp==3.15.0
3933
# via importlib-metadata
40-
41-
# The following packages are considered to be unsafe in a requirements file:
42-
pip==24.0
43-
# via -r cibuildwheel/resources/constraints.in
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.8
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.8
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
148
# via virtualenv
15-
importlib-metadata==7.0.2
9+
importlib-metadata==7.1.0
1610
# via build
1711
packaging==24.0
1812
# via
1913
# build
2014
# delocate
15+
pip==24.0
2116
platformdirs==4.2.0
2217
# via virtualenv
2318
pyproject-hooks==1.0.0
@@ -29,10 +24,5 @@ tomli==2.0.1
2924
typing-extensions==4.10.0
3025
# via delocate
3126
virtualenv==20.25.1
32-
# via -r cibuildwheel/resources/constraints.in
3327
zipp==3.18.1
3428
# via importlib-metadata
35-
36-
# The following packages are considered to be unsafe in a requirements file:
37-
pip==24.0
38-
# via -r cibuildwheel/resources/constraints.in
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.9
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.9
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
148
# via virtualenv
15-
importlib-metadata==7.0.2
9+
importlib-metadata==7.1.0
1610
# via build
1711
packaging==24.0
1812
# via
1913
# build
2014
# delocate
15+
pip==24.0
2116
platformdirs==4.2.0
2217
# via virtualenv
2318
pyproject-hooks==1.0.0
@@ -29,10 +24,5 @@ tomli==2.0.1
2924
typing-extensions==4.10.0
3025
# via delocate
3126
virtualenv==20.25.1
32-
# via -r cibuildwheel/resources/constraints.in
3327
zipp==3.18.1
3428
# via importlib-metadata
35-
36-
# The following packages are considered to be unsafe in a requirements file:
37-
pip==24.0
38-
# via -r cibuildwheel/resources/constraints.in
+3-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.12
3-
# by the following command:
4-
#
5-
# nox -s update_constraints-3.12
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# nox -s update_constraints
73
build==1.1.1
8-
# via -r cibuildwheel/resources/constraints.in
94
delocate==0.10.7
10-
# via -r cibuildwheel/resources/constraints.in
115
distlib==0.3.8
126
# via virtualenv
137
filelock==3.13.1
@@ -16,15 +10,11 @@ packaging==24.0
1610
# via
1711
# build
1812
# delocate
13+
pip==24.0
1914
platformdirs==4.2.0
2015
# via virtualenv
2116
pyproject-hooks==1.0.0
2217
# via build
2318
typing-extensions==4.10.0
2419
# via delocate
2520
virtualenv==20.25.1
26-
# via -r cibuildwheel/resources/constraints.in
27-
28-
# The following packages are considered to be unsafe in a requirements file:
29-
pip==24.0
30-
# via -r cibuildwheel/resources/constraints.in

noxfile.py

+32-37
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"]
1111

12-
PYTHON_ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
13-
1412
DIR = Path(__file__).parent.resolve()
1513

1614
if os.environ.get("CI", None):
@@ -23,7 +21,7 @@ def tests(session: nox.Session) -> None:
2321
Run the unit and regular tests.
2422
"""
2523
unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else []
26-
session.install("-e", ".[test]")
24+
session.install("-e.[test]")
2725
if session.posargs:
2826
session.run("pytest", *session.posargs)
2927
else:
@@ -46,7 +44,8 @@ def pylint(session: nox.Session) -> None:
4644
Run pylint.
4745
"""
4846

49-
session.install("pylint", ".")
47+
name = "cibuildwheel @ ." if getattr(session.virtualenv, "venv_backend", "") == "uv" else "."
48+
session.install("pylint", name)
5049
session.run("pylint", "cibuildwheel", *session.posargs)
5150

5251

@@ -60,32 +59,36 @@ def check_manifest(session: nox.Session) -> None:
6059
session.run("check-manifest", *session.posargs)
6160

6261

63-
@nox.session(python=PYTHON_ALL_VERSIONS)
62+
@nox.session
6463
def update_constraints(session: nox.Session) -> None:
6564
"""
6665
Update the dependencies inplace.
6766
"""
68-
session.install("pip-tools")
69-
assert isinstance(session.python, str)
70-
python_version = session.python.replace(".", "")
71-
env = os.environ.copy()
72-
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
73-
# regenerate the constraints files
74-
env["CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
75-
session.run(
76-
"pip-compile",
77-
"--allow-unsafe",
78-
"--upgrade",
79-
"cibuildwheel/resources/constraints.in",
80-
f"--output-file=cibuildwheel/resources/constraints-python{python_version}.txt",
81-
env=env,
82-
)
83-
if session.python == PYTHON_ALL_VERSIONS[-1]:
84-
RESOURCES = DIR / "cibuildwheel" / "resources"
85-
shutil.copyfile(
86-
RESOURCES / f"constraints-python{python_version}.txt",
87-
RESOURCES / "constraints.txt",
67+
68+
if getattr(session.virtualenv, "venv_backend", "") != "uv":
69+
session.install("uv>=0.1.23")
70+
71+
for minor_version in range(7, 13):
72+
python_version = f"3.{minor_version}"
73+
env = os.environ.copy()
74+
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
75+
# regenerate the constraints files
76+
env["UV_CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
77+
session.run(
78+
"uv",
79+
"pip",
80+
"compile",
81+
f"--python-version={python_version}",
82+
"--upgrade",
83+
"cibuildwheel/resources/constraints.in",
84+
f"--output-file=cibuildwheel/resources/constraints-python{python_version.replace('.', '')}.txt",
85+
env=env,
8886
)
87+
RESOURCES = DIR / "cibuildwheel" / "resources"
88+
shutil.copyfile(
89+
RESOURCES / "constraints-python312.txt",
90+
RESOURCES / "constraints.txt",
91+
)
8992

9093

9194
@nox.session
@@ -104,7 +107,7 @@ def update_proj(session: nox.Session) -> None:
104107
"""
105108
Update the README inplace.
106109
"""
107-
session.install("-e", ".[bin]")
110+
session.install("-e.[bin]")
108111
session.run(
109112
"python",
110113
"bin/projects.py",
@@ -127,18 +130,10 @@ def generate_schema(session: nox.Session) -> None:
127130
@nox.session(python="3.9")
128131
def docs(session: nox.Session) -> None:
129132
"""
130-
Build the docs.
133+
Build the docs. Will serve unless --non-interactive
131134
"""
132-
session.install("-e", ".[docs]")
133-
session.run("pip", "list")
134-
135-
if session.posargs:
136-
if "serve" in session.posargs:
137-
session.run("mkdocs", "serve")
138-
else:
139-
session.error("Unrecognized args, use 'serve'")
140-
else:
141-
session.run("mkdocs", "build")
135+
session.install("-e.[docs]")
136+
session.run("mkdocs", "serve" if session.interactive else "build")
142137

143138

144139
@nox.session

0 commit comments

Comments
 (0)