forked from coqui-ai/TTS
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add script to automatically generate requirements.dev.txt
Having this file is still useful to allow installing *only* dev requirements (e.g. in CI) with: pip install -r requirements.dev.txt Generate that file automatically from the pyproject.toml based on: https://github.com/numpy/numpydoc/blob/e7c6baf00f5f73a4a8f8318d0cb4e04949c9a5d1/tools/generate_requirements.py
- Loading branch information
Showing
5 changed files
with
54 additions
and
1 deletion.
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
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,4 +1,8 @@ | ||
# Generated via scripts/generate_requirements.py and pre-commit hook. | ||
# Do not edit this file; modify pyproject.toml instead. | ||
black==24.2.0 | ||
coverage[toml] | ||
nose2 | ||
pre-commit | ||
ruff==0.3.0 | ||
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
"""Generate requirements/*.txt files from pyproject.toml. | ||
Adapted from: | ||
https://github.com/numpy/numpydoc/blob/e7c6baf00f5f73a4a8f8318d0cb4e04949c9a5d1/tools/generate_requirements.py | ||
""" | ||
|
||
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`") | ||
|
||
script_pth = Path(__file__) | ||
repo_dir = script_pth.parent.parent | ||
script_relpth = script_pth.relative_to(repo_dir) | ||
header = [ | ||
f"# Generated via {script_relpth.as_posix()} and pre-commit hook.", | ||
"# Do not edit this file; modify pyproject.toml instead.", | ||
] | ||
|
||
|
||
def generate_requirement_file(name: str, req_list: list[str]) -> None: | ||
req_fname = repo_dir / f"requirements.{name}.txt" | ||
req_fname.write_text("\n".join(header + req_list) + "\n") | ||
|
||
|
||
def main() -> None: | ||
pyproject = toml.loads((repo_dir / "pyproject.toml").read_text()) | ||
generate_requirement_file("dev", pyproject["project"]["optional-dependencies"]["dev"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |