From 35c795e4c6fcb627dc1b07998ee28f3310f9a768 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Tue, 2 Aug 2022 22:56:59 +0200 Subject: [PATCH] fix: update workflow (#1209) move the `pip-compile` command directly in `noxfile.py` --- bin/update_dependencies.py | 41 -------------------------------------- noxfile.py | 23 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 43 deletions(-) delete mode 100755 bin/update_dependencies.py diff --git a/bin/update_dependencies.py b/bin/update_dependencies.py deleted file mode 100755 index c0d7f200..00000000 --- a/bin/update_dependencies.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 - -from __future__ import annotations - -import os -import shutil -import subprocess -import sys -from pathlib import Path - -DIR = Path(__file__).parent.resolve() -RESOURCES = DIR.parent / "cibuildwheel/resources" - -python_version = "".join(str(v) for v in sys.version_info[:2]) - -env = os.environ.copy() - -# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to -# regenerate the constraints files -env["CUSTOM_COMPILE_COMMAND"] = "bin/update_dependencies.py" - -os.chdir(DIR.parent) - -subprocess.run( - [ - "pip-compile", - "--allow-unsafe", - "--upgrade", - "cibuildwheel/resources/constraints.in", - f"--output-file=cibuildwheel/resources/constraints-python{python_version}.txt", - ], - check=True, - env=env, -) - -# default constraints.txt -if python_version == "39": - shutil.copyfile( - RESOURCES / f"constraints-python{python_version}.txt", - RESOURCES / "constraints.txt", - ) diff --git a/noxfile.py b/noxfile.py index 659e7ff5..142ea3fe 100644 --- a/noxfile.py +++ b/noxfile.py @@ -65,8 +65,27 @@ def update_constraints(session: nox.Session) -> None: """ Update the dependencies inplace. """ - session.install("requests", "pip-tools") - session.run("python", "bin/update_dependencies.py") + session.install("pip-tools") + assert isinstance(session.python, str) + python_version = session.python.replace(".", "") + env = os.environ.copy() + # CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to + # regenerate the constraints files + env["CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}" + session.run( + "pip-compile", + "--allow-unsafe", + "--upgrade", + "cibuildwheel/resources/constraints.in", + f"--output-file=cibuildwheel/resources/constraints-python{python_version}.txt", + env=env, + ) + if session.python == PYTHON_ALL_VERSIONS[-1]: + RESOURCES = DIR / "cibuildwheel" / "resources" + shutil.copyfile( + RESOURCES / f"constraints-python{python_version}.txt", + RESOURCES / "constraints.txt", + ) @nox.session