chore: use uv pip compile (#1778)

This commit is contained in:
Henry Schreiner
2024-03-21 15:41:31 -04:00
committed by GitHub
parent 6537b8f51f
commit 312cf1573e
9 changed files with 60 additions and 130 deletions
+1
View File
@@ -215,6 +215,7 @@ def _resolve_cascade(
return result return result
# pylint: disable-next=inconsistent-return-statements
def _merge_values(before: str | None, after: str, rule: InheritRule, merge_sep: str | None) -> str: def _merge_values(before: str | None, after: str, rule: InheritRule, merge_sep: str | None) -> str:
if rule == InheritRule.NONE: if rule == InheritRule.NONE:
return after return after
@@ -1,21 +1,18 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.10 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.10
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
# via virtualenv # via virtualenv
importlib-metadata==7.1.0
# via build
packaging==24.0 packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -27,8 +24,5 @@ tomli==2.0.1
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in zipp==3.18.1
# via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
@@ -1,13 +1,7 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.11 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.11
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
@@ -16,6 +10,7 @@ packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -23,8 +18,3 @@ pyproject-hooks==1.0.0
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
@@ -1,13 +1,7 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.12 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.12
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
@@ -16,6 +10,7 @@ packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -23,8 +18,3 @@ pyproject-hooks==1.0.0
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
@@ -1,13 +1,7 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.7 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.7
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.12.2 filelock==3.12.2
@@ -20,6 +14,7 @@ packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.0.0 platformdirs==4.0.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -34,10 +29,5 @@ typing-extensions==4.7.1
# importlib-metadata # importlib-metadata
# platformdirs # platformdirs
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
zipp==3.15.0 zipp==3.15.0
# via importlib-metadata # via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
@@ -1,23 +1,18 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.8 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.8
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
# via virtualenv # via virtualenv
importlib-metadata==7.0.2 importlib-metadata==7.1.0
# via build # via build
packaging==24.0 packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -29,10 +24,5 @@ tomli==2.0.1
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
zipp==3.18.1 zipp==3.18.1
# via importlib-metadata # via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
@@ -1,23 +1,18 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.9 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.9
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
# via virtualenv # via virtualenv
importlib-metadata==7.0.2 importlib-metadata==7.1.0
# via build # via build
packaging==24.0 packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -29,10 +24,5 @@ tomli==2.0.1
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
zipp==3.18.1 zipp==3.18.1
# via importlib-metadata # via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
+3 -13
View File
@@ -1,13 +1,7 @@
# # This file was autogenerated by uv via the following command:
# This file is autogenerated by pip-compile with Python 3.12 # nox -s update_constraints
# by the following command:
#
# nox -s update_constraints-3.12
#
build==1.1.1 build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.10.7 delocate==0.10.7
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
filelock==3.13.1 filelock==3.13.1
@@ -16,6 +10,7 @@ packaging==24.0
# via # via
# build # build
# delocate # delocate
pip==24.0
platformdirs==4.2.0 platformdirs==4.2.0
# via virtualenv # via virtualenv
pyproject-hooks==1.0.0 pyproject-hooks==1.0.0
@@ -23,8 +18,3 @@ pyproject-hooks==1.0.0
typing-extensions==4.10.0 typing-extensions==4.10.0
# via delocate # via delocate
virtualenv==20.25.1 virtualenv==20.25.1
# via -r cibuildwheel/resources/constraints.in
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r cibuildwheel/resources/constraints.in
+21 -26
View File
@@ -9,8 +9,6 @@ import nox
nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"] nox.options.sessions = ["lint", "pylint", "check_manifest", "tests"]
PYTHON_ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
DIR = Path(__file__).parent.resolve() DIR = Path(__file__).parent.resolve()
if os.environ.get("CI", None): if os.environ.get("CI", None):
@@ -23,7 +21,7 @@ def tests(session: nox.Session) -> None:
Run the unit and regular tests. Run the unit and regular tests.
""" """
unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else [] unit_test_args = ["--run-docker"] if sys.platform.startswith("linux") else []
session.install("-e", ".[test]") session.install("-e.[test]")
if session.posargs: if session.posargs:
session.run("pytest", *session.posargs) session.run("pytest", *session.posargs)
else: else:
@@ -46,7 +44,8 @@ def pylint(session: nox.Session) -> None:
Run pylint. Run pylint.
""" """
session.install("pylint", ".") name = "cibuildwheel @ ." if getattr(session.virtualenv, "venv_backend", "") == "uv" else "."
session.install("pylint", name)
session.run("pylint", "cibuildwheel", *session.posargs) session.run("pylint", "cibuildwheel", *session.posargs)
@@ -60,30 +59,34 @@ def check_manifest(session: nox.Session) -> None:
session.run("check-manifest", *session.posargs) session.run("check-manifest", *session.posargs)
@nox.session(python=PYTHON_ALL_VERSIONS) @nox.session
def update_constraints(session: nox.Session) -> None: def update_constraints(session: nox.Session) -> None:
""" """
Update the dependencies inplace. Update the dependencies inplace.
""" """
session.install("pip-tools")
assert isinstance(session.python, str) if getattr(session.virtualenv, "venv_backend", "") != "uv":
python_version = session.python.replace(".", "") session.install("uv>=0.1.23")
for minor_version in range(7, 13):
python_version = f"3.{minor_version}"
env = os.environ.copy() env = os.environ.copy()
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to # CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
# regenerate the constraints files # regenerate the constraints files
env["CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}" env["UV_CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
session.run( session.run(
"pip-compile", "uv",
"--allow-unsafe", "pip",
"compile",
f"--python-version={python_version}",
"--upgrade", "--upgrade",
"cibuildwheel/resources/constraints.in", "cibuildwheel/resources/constraints.in",
f"--output-file=cibuildwheel/resources/constraints-python{python_version}.txt", f"--output-file=cibuildwheel/resources/constraints-python{python_version.replace('.', '')}.txt",
env=env, env=env,
) )
if session.python == PYTHON_ALL_VERSIONS[-1]:
RESOURCES = DIR / "cibuildwheel" / "resources" RESOURCES = DIR / "cibuildwheel" / "resources"
shutil.copyfile( shutil.copyfile(
RESOURCES / f"constraints-python{python_version}.txt", RESOURCES / "constraints-python312.txt",
RESOURCES / "constraints.txt", RESOURCES / "constraints.txt",
) )
@@ -104,7 +107,7 @@ def update_proj(session: nox.Session) -> None:
""" """
Update the README inplace. Update the README inplace.
""" """
session.install("-e", ".[bin]") session.install("-e.[bin]")
session.run( session.run(
"python", "python",
"bin/projects.py", "bin/projects.py",
@@ -127,18 +130,10 @@ def generate_schema(session: nox.Session) -> None:
@nox.session(python="3.9") @nox.session(python="3.9")
def docs(session: nox.Session) -> None: def docs(session: nox.Session) -> None:
""" """
Build the docs. Build the docs. Will serve unless --non-interactive
""" """
session.install("-e", ".[docs]") session.install("-e.[docs]")
session.run("pip", "list") session.run("mkdocs", "serve" if session.interactive else "build")
if session.posargs:
if "serve" in session.posargs:
session.run("mkdocs", "serve")
else:
session.error("Unrecognized args, use 'serve'")
else:
session.run("mkdocs", "build")
@nox.session @nox.session