Skip to content

Commit bf7b367

Browse files
committed
tests: switch to uv pip-compile for lockfiles
This switches the nox pip-compile session and lockfiles to use uv pip compile (written in Rust and much faster) instead of pip-compile from pip-tools for our dependency update jobs. As a side effect, this addresses the issue brought up in ansible#1950 (comment), as we're no longer using pip-compile that can break anytime pip changes the private/internal APIs that pip-tools relies on. I re-generated the lockfiles with `--no-upgrade` to avoid extraneous changes in this PR. The only additions are the formatting of comments in the lockfile and colorama. colorama was added as a result of `uv pip-compile`'s `--universal` flag which creates "universal" lockfiles that include dependencies of other platforms, architectures, and Python versions than those of the system used to generate the lockfile. `--universal` should create more consistent results for contributors who use other systems (e.g., Mac OS or a newer Python version than the one used in CI). Fixes: ansible#1755
1 parent da2f837 commit bf7b367

10 files changed

+49
-66
lines changed

.pip-tools.toml

-5
This file was deleted.

noxfile.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shlex
55
import shutil
66
from argparse import ArgumentParser, BooleanOptionalAction
7+
from contextlib import suppress
78
from glob import iglob
89
from pathlib import Path
910
from typing import cast
@@ -157,10 +158,7 @@ def lint(session: nox.Session):
157158
@nox.session(name="pip-compile", python=["3.11"])
158159
@nox.parametrize(["req"], requirements_files, requirements_files)
159160
def pip_compile(session: nox.Session, req: str):
160-
# .pip-tools.toml was introduced in v7
161-
# pip 24.3 causes a regression in pip-compile.
162-
# See https://github.com/jazzband/pip-tools/issues/2131.
163-
session.install("pip-tools >= 7", "pip < 24.3")
161+
install(session, req="pip-compile")
164162

165163
# Use --upgrade by default unless a user passes -P.
166164
args = list(session.posargs)
@@ -175,10 +173,16 @@ def pip_compile(session: nox.Session, req: str):
175173
arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args
176174
):
177175
args.append("--upgrade")
176+
# Use "--no-upgrade" as a signal for our noxfile to not pass --upgrade, but
177+
# don't pass it on to uv. It doesn't support it.
178+
with suppress(ValueError):
179+
args.remove("--no-upgrade")
178180

179181
# fmt: off
180182
session.run(
181-
"pip-compile",
183+
"uv", "pip", "compile",
184+
"--universal",
185+
"--quiet",
182186
"--output-file", f"tests/{req}.txt",
183187
*args,
184188
f"tests/{req}.in",

tests/formatters.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/formatters.txt --strip-extras tests/formatters.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/formatters.txt tests/formatters.in
73
black==24.10.0
84
# via -r tests/formatters.in
95
click==8.1.7
106
# via black
7+
colorama==0.4.6 ; platform_system == 'Windows'
8+
# via click
119
isort==5.13.2
1210
# via -r tests/formatters.in
1311
mypy-extensions==1.0.0

tests/pr_labeler.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/pr_labeler.txt --strip-extras tests/pr_labeler.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/pr_labeler.txt tests/pr_labeler.in
73
certifi==2024.8.30
84
# via requests
95
cffi==1.17.1
@@ -16,6 +12,8 @@ click==8.1.7
1612
# via typer-slim
1713
codeowners==0.7.0
1814
# via -r tests/pr_labeler.in
15+
colorama==0.4.6 ; platform_system == 'Windows'
16+
# via click
1917
cryptography==43.0.1
2018
# via pyjwt
2119
deprecated==1.2.14

tests/requirements-relaxed.txt

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/requirements-relaxed.txt --strip-extras tests/requirements-relaxed.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/requirements-relaxed.txt tests/requirements-relaxed.in
73
aiofiles==24.1.0
84
# via
95
# antsibull-core
@@ -55,6 +51,11 @@ charset-normalizer==3.4.0
5551
# via requests
5652
click==8.1.7
5753
# via sphinx-intl
54+
colorama==0.4.6 ; (platform_system != 'Windows' and sys_platform == 'win32') or platform_system == 'Windows' or os_name == 'nt'
55+
# via
56+
# build
57+
# click
58+
# sphinx
5859
docutils==0.21.2
5960
# via
6061
# antsibull-changelog
@@ -129,6 +130,8 @@ semantic-version==2.10.0
129130
# antsibull-changelog
130131
# antsibull-core
131132
# antsibull-docs
133+
setuptools==75.6.0
134+
# via sphinx-intl
132135
six==1.16.0
133136
# via twiggy
134137
snowballstemmer==2.2.0
@@ -181,7 +184,3 @@ urllib3==2.2.3
181184
# via requests
182185
yarl==1.18.0
183186
# via aiohttp
184-
185-
# The following packages are considered to be unsafe in a requirements file:
186-
setuptools==75.6.0
187-
# via sphinx-intl

tests/requirements.txt

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/requirements.txt --strip-extras tests/requirements.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/requirements.txt tests/requirements.in
73
aiofiles==24.1.0
84
# via
95
# antsibull-core
@@ -57,6 +53,11 @@ charset-normalizer==3.4.0
5753
# via requests
5854
click==8.1.7
5955
# via sphinx-intl
56+
colorama==0.4.6 ; (platform_system != 'Windows' and sys_platform == 'win32') or platform_system == 'Windows' or os_name == 'nt'
57+
# via
58+
# build
59+
# click
60+
# sphinx
6061
docutils==0.18.1
6162
# via
6263
# antsibull-changelog
@@ -131,6 +132,8 @@ semantic-version==2.10.0
131132
# antsibull-changelog
132133
# antsibull-core
133134
# antsibull-docs
135+
setuptools==75.6.0
136+
# via sphinx-intl
134137
six==1.16.0
135138
# via twiggy
136139
snowballstemmer==2.2.0
@@ -187,7 +190,3 @@ urllib3==2.2.3
187190
# via requests
188191
yarl==1.18.0
189192
# via aiohttp
190-
191-
# The following packages are considered to be unsafe in a requirements file:
192-
setuptools==75.6.0
193-
# via sphinx-intl

tests/spelling.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/spelling.txt --strip-extras tests/spelling.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/spelling.txt tests/spelling.in
73
codespell==2.3.0
84
# via -r tests/spelling.in

tests/static.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/static.txt --strip-extras tests/static.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/static.txt tests/static.in
73
ruff==0.7.4
84
# via -r tests/static.in

tests/tag.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/tag.txt --strip-extras tests/tag.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/tag.txt tests/tag.in
73
click==8.1.7
84
# via typer
5+
colorama==0.4.6 ; platform_system == 'Windows'
6+
# via click
97
gitdb==4.0.11
108
# via gitpython
119
gitpython==3.1.43

tests/typing.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.11
3-
# by the following command:
4-
#
5-
# pip-compile --allow-unsafe --output-file=tests/typing.txt --strip-extras tests/typing.in
6-
#
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile --universal --output-file tests/typing.txt tests/typing.in
73
argcomplete==3.5.1
84
# via nox
95
certifi==2024.8.30
@@ -20,6 +16,10 @@ click==8.1.7
2016
# typer-slim
2117
codeowners==0.7.0
2218
# via -r tests/../hacking/pr_labeler/requirements.txt
19+
colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
20+
# via
21+
# click
22+
# colorlog
2323
colorlog==6.9.0
2424
# via nox
2525
cryptography==43.0.3

0 commit comments

Comments
 (0)