-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a90682f
commit 2562983
Showing
2 changed files
with
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This script requires python 3.12 to run. | ||
from __future__ import annotations | ||
|
||
import sys | ||
import tomllib | ||
from typing import Any | ||
|
||
|
||
def gen_requirements_txt(pyproject_cfg: dict[str, Any]) -> str: | ||
try: | ||
_res: list[str] = pyproject_cfg["project"]["dependencies"] | ||
return "\n".join(_res) | ||
except KeyError: | ||
return "" | ||
|
||
|
||
if __name__ == "__main__": | ||
script_name, *args = sys.argv | ||
if len(args) < 2: | ||
print(f"Usage: {script_name} <pyproject.toml> <requirements.txt>") | ||
sys.exit(1) | ||
|
||
pyproject_toml, requirements_txt, *_ = args | ||
with open(pyproject_toml, "rb") as src, open(requirements_txt, "w") as dst: | ||
_parsed = tomllib.load(src) | ||
dst.write(gen_requirements_txt(_parsed)) |
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