From 8f86a68eab7f8f0c3bfd2c2e7e59e1e039ab3182 Mon Sep 17 00:00:00 2001 From: Don Naro Date: Wed, 28 Feb 2024 14:13:16 +0000 Subject: [PATCH] add pip compile session --- noxfile.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index e2d38c3b..c96e7a0e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,9 +1,33 @@ import nox + +@nox.session(name="pip-compile", python=["3.11"]) +def pip_compile(session: nox.Session): + # .pip-tools.toml was introduced in v7 + session.install("pip-tools >= 7") + + # Use --upgrade by default unless a user passes -P. + args = list(session.posargs) + if not any( + arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args + ): + args.append("--upgrade") + + session.run( + "pip-compile", + "--output-file", + f"requirements.txt", + *args, + f"requirements.in", + ) + + @nox.session def build(session: nox.Session): session.install( - "-r", "requirements.in", - "-c", "requirements.txt", + "-r", + "requirements.in", + "-c", + "requirements.txt", ) session.run("python", "-I", "build.py", *session.posargs)