Skip to content

Commit 7c717f6

Browse files
committed
Add a script to generate the requirements files
and check that they are up to date in the CI Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 4815785 commit 7c717f6

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Check requirements file consistency
2+
3+
on: [push]
4+
5+
jobs:
6+
requirements-check:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install uv
11+
uses: astral-sh/setup-uv@v6
12+
with:
13+
version: "0.7.x"
14+
- name: Install dependencies
15+
run: uv sync --frozen
16+
- run: uv run ./requirements/update_requirements.py
17+
- run: git diff --exit-code

requirements/base.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# generated with update_requirements.py, do not edit manually
12
cryptography>=3.3.1
2-
GitPython
3+
gitpython
4+
legacycrypt
35
packaging>=20.7
4-
pytest>=8.0.0
56
pluggy>=1.1.0
6-
requests
7-
legacycrypt
7+
pytest>=8.0.0
88
pytest-dependency
9+
requests

requirements/dev.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# All requirements + those only used in development
1+
# generated with update_requirements.py, do not edit manually
22
ansible>=5.0.1
33
bs4>=0.0.1
4-
flake8
5-
PyYAML>=6.0
64
mypy
7-
typing_extensions
5+
flake8
6+
pydocstyle
87
pyright
8+
pyyaml>=6.0
99
types-requests
10+
typing-extensions
1011
-r base.txt

requirements/update_requirements.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import tomllib
5+
from pathlib import Path
6+
7+
parser = argparse.ArgumentParser(description="Convert the dependencies from pyproject.toml in requirements.txt files")
8+
args = parser.parse_args()
9+
10+
PROJECT_DIR = Path(__file__).parent.parent
11+
HEADER = "# generated with update_requirements.py, do not edit manually"
12+
13+
with open(f'{PROJECT_DIR}/pyproject.toml', 'rb') as f:
14+
pyproject = tomllib.load(f)
15+
16+
17+
main_deps = pyproject['project']['dependencies']
18+
with open(f'{PROJECT_DIR}/requirements/base.txt', 'w') as f:
19+
print(HEADER, file=f)
20+
for dep in main_deps:
21+
print(dep, file=f)
22+
23+
dev_deps = pyproject['dependency-groups']['dev']
24+
with open(f'{PROJECT_DIR}/requirements/dev.txt', 'w') as f:
25+
print(HEADER, file=f)
26+
for dep in dev_deps:
27+
print(dep, file=f)
28+
print('-r base.txt', file=f)

0 commit comments

Comments
 (0)