-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nox session to pip-compile requirements (#229)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> Co-authored-by: Maxwell G <[email protected]>
- Loading branch information
1 parent
4947d22
commit d0b1ab7
Showing
6 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
"pip-compile", | ||
"--output-file", | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pip-tools >= 7 # .pip-tools.toml was introduced in v6.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.