-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate requirements files from pyproject.toml (#483)
- Loading branch information
Showing
8 changed files
with
29 additions
and
136 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
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
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,2 +1,2 @@ | ||
pre-commit>=3.3 | ||
rtoml | ||
tomli; python_version < '3.11' |
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,3 +1,4 @@ | ||
# Generated from pyproject.toml | ||
numpy>=1.22 | ||
matplotlib>=3.5 | ||
pydata-sphinx-theme>=0.13 | ||
|
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,3 +1,4 @@ | ||
# Generated from pyproject.toml | ||
pytest | ||
pytest-cov | ||
matplotlib |
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
#!/usr/bin/env python | ||
"""Generate requirements/*.txt files from pyproject.toml.""" | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
try: # standard module since Python 3.11 | ||
import tomllib as toml | ||
except ImportError: | ||
try: # available for older Python via pip | ||
import tomli as toml | ||
except ImportError: | ||
sys.exit("Please install `tomli` first: `pip install tomli`") | ||
|
||
repo_dir = (Path(__file__).parent / "..").resolve() | ||
req_dir = repo_dir / "requirements" | ||
pyproject = toml.loads((repo_dir / "pyproject.toml").read_text()) | ||
|
||
for key, opt_list in pyproject["project"]["optional-dependencies"].items(): | ||
lines = ["# Generated from pyproject.toml"] + opt_list | ||
req_fname = req_dir / f"{key}.txt" | ||
req_fname.write_text("\n".join(lines) + "\n") |
This file was deleted.
Oops, something went wrong.