Skip to content

Commit

Permalink
tests: switch to uv pip-compile for lockfiles
Browse files Browse the repository at this point in the history
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
#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: #1755
  • Loading branch information
gotmax23 committed Nov 23, 2024
1 parent da2f837 commit bf7b367
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 66 deletions.
5 changes: 0 additions & 5 deletions .pip-tools.toml

This file was deleted.

14 changes: 9 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shlex
import shutil
from argparse import ArgumentParser, BooleanOptionalAction
from contextlib import suppress
from glob import iglob
from pathlib import Path
from typing import cast
Expand Down Expand Up @@ -157,10 +158,7 @@ def lint(session: nox.Session):
@nox.session(name="pip-compile", python=["3.11"])
@nox.parametrize(["req"], requirements_files, requirements_files)
def pip_compile(session: nox.Session, req: str):
# .pip-tools.toml was introduced in v7
# pip 24.3 causes a regression in pip-compile.
# See https://github.com/jazzband/pip-tools/issues/2131.
session.install("pip-tools >= 7", "pip < 24.3")
install(session, req="pip-compile")

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

# fmt: off
session.run(
"pip-compile",
"uv", "pip", "compile",
"--universal",
"--quiet",
"--output-file", f"tests/{req}.txt",
*args,
f"tests/{req}.in",
Expand Down
10 changes: 4 additions & 6 deletions tests/formatters.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/formatters.txt --strip-extras tests/formatters.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/formatters.txt tests/formatters.in
black==24.10.0
# via -r tests/formatters.in
click==8.1.7
# via black
colorama==0.4.6 ; platform_system == 'Windows'
# via click
isort==5.13.2
# via -r tests/formatters.in
mypy-extensions==1.0.0
Expand Down
10 changes: 4 additions & 6 deletions tests/pr_labeler.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/pr_labeler.txt --strip-extras tests/pr_labeler.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/pr_labeler.txt tests/pr_labeler.in
certifi==2024.8.30
# via requests
cffi==1.17.1
Expand All @@ -16,6 +12,8 @@ click==8.1.7
# via typer-slim
codeowners==0.7.0
# via -r tests/pr_labeler.in
colorama==0.4.6 ; platform_system == 'Windows'
# via click
cryptography==43.0.1
# via pyjwt
deprecated==1.2.14
Expand Down
19 changes: 9 additions & 10 deletions tests/requirements-relaxed.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/requirements-relaxed.txt --strip-extras tests/requirements-relaxed.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/requirements-relaxed.txt tests/requirements-relaxed.in
aiofiles==24.1.0
# via
# antsibull-core
Expand Down Expand Up @@ -55,6 +51,11 @@ charset-normalizer==3.4.0
# via requests
click==8.1.7
# via sphinx-intl
colorama==0.4.6 ; (platform_system != 'Windows' and sys_platform == 'win32') or platform_system == 'Windows' or os_name == 'nt'
# via
# build
# click
# sphinx
docutils==0.21.2
# via
# antsibull-changelog
Expand Down Expand Up @@ -129,6 +130,8 @@ semantic-version==2.10.0
# antsibull-changelog
# antsibull-core
# antsibull-docs
setuptools==75.6.0
# via sphinx-intl
six==1.16.0
# via twiggy
snowballstemmer==2.2.0
Expand Down Expand Up @@ -181,7 +184,3 @@ urllib3==2.2.3
# via requests
yarl==1.18.0
# via aiohttp

# The following packages are considered to be unsafe in a requirements file:
setuptools==75.6.0
# via sphinx-intl
19 changes: 9 additions & 10 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/requirements.txt --strip-extras tests/requirements.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/requirements.txt tests/requirements.in
aiofiles==24.1.0
# via
# antsibull-core
Expand Down Expand Up @@ -57,6 +53,11 @@ charset-normalizer==3.4.0
# via requests
click==8.1.7
# via sphinx-intl
colorama==0.4.6 ; (platform_system != 'Windows' and sys_platform == 'win32') or platform_system == 'Windows' or os_name == 'nt'
# via
# build
# click
# sphinx
docutils==0.18.1
# via
# antsibull-changelog
Expand Down Expand Up @@ -131,6 +132,8 @@ semantic-version==2.10.0
# antsibull-changelog
# antsibull-core
# antsibull-docs
setuptools==75.6.0
# via sphinx-intl
six==1.16.0
# via twiggy
snowballstemmer==2.2.0
Expand Down Expand Up @@ -187,7 +190,3 @@ urllib3==2.2.3
# via requests
yarl==1.18.0
# via aiohttp

# The following packages are considered to be unsafe in a requirements file:
setuptools==75.6.0
# via sphinx-intl
8 changes: 2 additions & 6 deletions tests/spelling.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/spelling.txt --strip-extras tests/spelling.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/spelling.txt tests/spelling.in
codespell==2.3.0
# via -r tests/spelling.in
8 changes: 2 additions & 6 deletions tests/static.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/static.txt --strip-extras tests/static.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/static.txt tests/static.in
ruff==0.7.4
# via -r tests/static.in
10 changes: 4 additions & 6 deletions tests/tag.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/tag.txt --strip-extras tests/tag.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/tag.txt tests/tag.in
click==8.1.7
# via typer
colorama==0.4.6 ; platform_system == 'Windows'
# via click
gitdb==4.0.11
# via gitpython
gitpython==3.1.43
Expand Down
12 changes: 6 additions & 6 deletions tests/typing.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=tests/typing.txt --strip-extras tests/typing.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/typing.txt tests/typing.in
argcomplete==3.5.1
# via nox
certifi==2024.8.30
Expand All @@ -20,6 +16,10 @@ click==8.1.7
# typer-slim
codeowners==0.7.0
# via -r tests/../hacking/pr_labeler/requirements.txt
colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
# via
# click
# colorlog
colorlog==6.9.0
# via nox
cryptography==43.0.3
Expand Down

0 comments on commit bf7b367

Please sign in to comment.