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)