Skip to content

Commit

Permalink
Add dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
lloesche committed Mar 5, 2024
1 parent 0ece3ea commit ac4dab1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all generate_in requirements.txt requirements-test.txt
.PHONY: all generate_in requirements.txt requirements-test.txt requirements-dev.txt

all: generate_in requirements.txt requirements-test.txt
all: generate_in requirements.txt requirements-test.txt requirements-dev.txt

generate_in:
python tools/make-requirements-in.py
Expand All @@ -10,3 +10,6 @@ requirements.txt: requirements.in pyproject.toml

requirements-test.txt: requirements-test.in pyproject.toml
pip-compile -q --no-annotate --resolver=backtracking --upgrade --allow-unsafe --no-header --unsafe-package n/a --no-strip-extras requirements-test.in -o requirements-test.txt

requirements-dev.txt: requirements-dev.in pyproject.toml
pip-compile -q --no-annotate --resolver=backtracking --upgrade --allow-unsafe --no-header --unsafe-package n/a --no-strip-extras requirements-dev.in -o requirements-dev.txt
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ test = [
"types-aiofiles",
]

dev = [
"pip-tools",
]

[tool.setuptools.package-data]
fixcompliance = ["py.typed"]

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip-tools
8 changes: 8 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build==1.1.1
click==8.1.7
packaging==23.2
pip==24.0
pip-tools==7.4.0
pyproject-hooks==1.0.0
setuptools==69.1.1
wheel==0.42.0
12 changes: 9 additions & 3 deletions tools/make-requirements-in.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ def create_in_files(pyproject_path: str):
pyproject = tomllib.load(f)

dependencies = pyproject.get("project", {}).get("dependencies", [])
optional_dependencies = pyproject.get("pyproject", {}).get("optional-dependencies", {}).get("test", [])
test_dependencies = pyproject.get("pyproject", {}).get("optional-dependencies", {}).get("test", [])
dev_dependencies = pyproject.get("pyproject", {}).get("optional-dependencies", {}).get("dev", [])

# Write main dependencies to requirements.in
with open("requirements.in", "w") as f:
for dep in dependencies:
f.write(dep + "\n")

# Write test dependencies to requirements-test.in (includes extras)
# Write test dependencies to requirements-test.in
with open("requirements-test.in", "w") as f:
for test_dep in optional_dependencies:
for test_dep in test_dependencies:
f.write(test_dep + "\n")

# Write dev dependencies to requirements-dev.in
with open("requirements-dev.in", "w") as f:
for dev_dep in dev_dependencies:
f.write(dev_dep + "\n")


if __name__ == "__main__":
pyproject_path = "pyproject.toml"
Expand Down

0 comments on commit ac4dab1

Please sign in to comment.