Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nox session to pip-compile requirements #229

Merged
merged 24 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pip-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.pip-tools]
resolver = "backtracking"
allow-unsafe = true
strip-extras = true
quiet = true
47 changes: 44 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,50 @@
from pathlib import Path

import nox

@nox.session(python=["3.11"]) # The python version should match the readthedocs configuration.
requirements_directory = Path("requirements").resolve()

requirements_files = [
requirements_input_file_path.stem
for requirements_input_file_path in requirements_directory.glob("*.in")
]


@nox.session(name="pip-compile", python=["3.11"])
@nox.parametrize(["req"], arg_values_list=requirements_files, ids=requirements_files)
def pip_compile(session: nox.Session, req: str):
"""Generate lock files from input files or upgrade packages in lock files."""
# fmt: off
session.install(
"-r", str(requirements_directory / "pip-tools.in"),
"-c", str(requirements_directory / "pip-tools.txt"),
)
# fmt: on

# Use --upgrade by default unless a user passes -P.
upgrade_related_cli_flags = ("-P", "--upgrade-package", "--no-upgrade")
has_upgrade_related_cli_flags = any(
arg.startswith(upgrade_related_cli_flags) for arg in session.posargs
)
injected_extra_cli_args = () if has_upgrade_related_cli_flags else ("--upgrade",)

session.run(
webknjaz marked this conversation as resolved.
Show resolved Hide resolved
"pip-compile",
"--output-file",
oraNod marked this conversation as resolved.
Show resolved Hide resolved
str(requirements_directory / f"{req}.txt"),
*session.posargs,
*injected_extra_cli_args,
str(requirements_directory / f"{req}.in"),
)


@nox.session(python=["3.11"]) # The python version should match the readthedocs configuration.
def build(session: nox.Session):
"""Generate HTML files for the Ansible docsite."""
# fmt: off
session.install(
"-r", "requirements.in",
"-c", "requirements.txt",
"-r", str(requirements_directory / "requirements.in"),
"-c", str(requirements_directory / "requirements.txt"),
)
# fmt: on
session.run("python", "-I", "build.py", *session.posargs)
1 change: 1 addition & 0 deletions requirements/pip-tools.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip-tools >= 7 # .pip-tools.toml was introduced in v6.14
26 changes: 26 additions & 0 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --output-file=requirements/pip-tools.txt --strip-extras requirements/pip-tools.in
#
build==1.0.3
# via pip-tools
click==8.1.7
# via pip-tools
packaging==23.2
# via build
pip-tools==7.4.0
# via -r requirements/pip-tools.in
pyproject-hooks==1.0.0
# via
# build
# pip-tools
wheel==0.42.0
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via pip-tools
setuptools==69.1.1
# via pip-tools
File renamed without changes.
File renamed without changes.