diff --git a/tools/generate_requirements_txt.py b/tools/generate_requirements_txt.py new file mode 100644 index 00000000..a148c339 --- /dev/null +++ b/tools/generate_requirements_txt.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +from pathlib import Path + +import tomllib + +this_script = Path(__file__) +root = this_script.parents[1] +pyproject = root / 'pyproject.toml' + +with open(pyproject, 'rb') as f: + metadata = tomllib.load(f) + dependencies = metadata['project']['dependencies'] + +with open('requirements.txt', 'w') as f: + this_script_rel = this_script.relative_to(root) + f.write(f'# generated by {this_script_rel}\n') + f.write('\n'.join(dependencies)) + f.write('\n')