File tree Expand file tree Collapse file tree 11 files changed +58
-232
lines changed Expand file tree Collapse file tree 11 files changed +58
-232
lines changed Original file line number Diff line number Diff line change 2424 - --fix
2525 - repo : local
2626 hooks :
27- - id : pyproject.toml
28- name : pyproject.toml
27+ - id : generate_requirements.py
28+ name : generate_requirements.py
2929 language : system
30- entry : python tools/generate_pyproject.toml .py
31- files : " pyproject.toml|requirements/.*\\ .txt|tools/.*pyproject.* "
30+ entry : python tools/generate_requirements .py
31+ files : " pyproject.toml|requirements/.*\\ .txt|tools/generate_requirements.py "
Original file line number Diff line number Diff line change 1- # ###############################################################################
2- # DO NOT EDIT
3- # AUTOGENERATED BY
4- #
5- # $ python tools/generate_pyproject.toml.py
6- #
7- # EDIT tools/pyproject.toml.in AND RUN THAT SCRIPT.
8- #
9- # ###############################################################################
10-
111[build-system ]
122build-backend = ' setuptools.build_meta'
133requires = [' setuptools>=61.2' ]
@@ -59,6 +49,7 @@ Homepage = 'https://networkx.org/'
5949"Bug Tracker" = ' https://github.com/networkx/networkx/issues'
6050Documentation = ' https://networkx.org/documentation/stable/'
6151"Source Code" = ' https://github.com/networkx/networkx'
52+
6253[project .entry-points ."networkx .plugins" ]
6354nx-loopback = ' networkx.classes.tests.dispatch_interface:dispatcher'
6455
@@ -94,6 +85,7 @@ test = [
9485 ' pytest>=7.2' ,
9586 ' pytest-cov>=4.0' ,
9687]
88+
9789[tool .setuptools ]
9890zip-safe = false
9991include-package-data = false
@@ -131,6 +123,7 @@ platforms = [
131123 ' Windows' ,
132124 ' Unix' ,
133125]
126+
134127[tool .setuptools .dynamic .version ]
135128attr = ' networkx.__version__'
136129
Original file line number Diff line number Diff line change 22
33## Index
44
5+ These files are generated by ` tools/generate_requirements.py ` from ` pyproject.toml ` .
6+
57- [ ` default.txt ` ] ( default.txt )
68 Default requirements
79- [ ` extra.txt ` ] ( extra.txt )
Original file line number Diff line number Diff line change 1+ # Generated via tools/generate_requirements.py and pre-commit hook.
2+ # Do not edit this file; modify pyproject.toml instead.
13numpy>=1.22
24scipy>=1.9,!=1.11.0,!=1.11.1
35matplotlib>=3.5
Original file line number Diff line number Diff line change 1+ # Generated via tools/generate_requirements.py and pre-commit hook.
2+ # Do not edit this file; modify pyproject.toml instead.
13pre-commit>=3.2
24mypy>=1.1
35rtoml
Original file line number Diff line number Diff line change 1+ # Generated via tools/generate_requirements.py and pre-commit hook.
2+ # Do not edit this file; modify pyproject.toml instead.
13sphinx>=7
24pydata-sphinx-theme>=0.14
35sphinx-gallery>=0.14
Original file line number Diff line number Diff line change 1+ # Generated via tools/generate_requirements.py and pre-commit hook.
2+ # Do not edit this file; modify pyproject.toml instead.
13lxml>=4.6
24pygraphviz>=1.11
35pydot>=1.4.2
Original file line number Diff line number Diff line change 1+ # Generated via tools/generate_requirements.py and pre-commit hook.
2+ # Do not edit this file; modify pyproject.toml instead.
13pytest>=7.2
24pytest-cov>=4.0
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ """Generate requirements/*.txt files from pyproject.toml."""
3+
4+ import sys
5+ from pathlib import Path
6+
7+ try : # standard module since Python 3.11
8+ import tomllib as toml
9+ except ImportError :
10+ try : # available for older Python via pip
11+ import tomli as toml
12+ except ImportError :
13+ sys .exit ("Please install `tomli` first: `pip install tomli`" )
14+
15+ script_pth = Path (__file__ )
16+ repo_dir = script_pth .parent .parent
17+ script_relpth = script_pth .relative_to (repo_dir )
18+ header = [
19+ f"# Generated via { script_relpth .as_posix ()} and pre-commit hook." ,
20+ "# Do not edit this file; modify pyproject.toml instead." ,
21+ ]
22+
23+
24+ def generate_requirement_file (name : str , req_list : list [str ]) -> None :
25+ req_fname = repo_dir / "requirements" / f"{ name } .txt"
26+ req_fname .write_text ("\n " .join (header + req_list ) + "\n " )
27+
28+
29+ def main () -> None :
30+ pyproject = toml .loads ((repo_dir / "pyproject.toml" ).read_text ())
31+
32+ generate_requirement_file ("default" , pyproject ["project" ]["dependencies" ])
33+
34+ for key , opt_list in pyproject ["project" ]["optional-dependencies" ].items ():
35+ generate_requirement_file (key , opt_list )
36+
37+
38+ if __name__ == "__main__" :
39+ main ()
You can’t perform that action at this time.
0 commit comments