File tree 7 files changed +44
-13
lines changed
7 files changed +44
-13
lines changed Original file line number Diff line number Diff line change 41
41
42
42
- repo : local
43
43
hooks :
44
- - id : pyproject.toml
45
- name : pyproject.toml
44
+ - id : generate_requirements.py
45
+ name : generate_requirements.py
46
46
language : system
47
47
entry : python tools/generate_requirements.py
48
- files : " pyproject.toml|requirements/.*\\ .txt|tools/.*generate.* "
48
+ files : " pyproject.toml|requirements/.*\\ .txt|tools/generate_requirements.py "
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ Homepage = 'https://numpydoc.readthedocs.io'
43
43
Source = ' https://github.com/numpy/numpydoc/'
44
44
45
45
[project .optional-dependencies ]
46
+ developer = [
47
+ ' pre-commit>=3.3' ,
48
+ " tomli; python_version < '3.11'" ,
49
+ ]
46
50
doc = [
47
51
' numpy>=1.22' ,
48
52
' matplotlib>=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.
3
+ sphinx>=5
4
+ Jinja2>=2.10
5
+ tabulate>=0.8.10
6
+ tomli>=1.1.0;python_version<'3.11'
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.
1
3
pre-commit>=3.3
2
4
tomli; python_version < '3.11'
Original file line number Diff line number Diff line change 1
- # Generated from pyproject.toml
1
+ # Generated via tools/generate_requirements.py and pre-commit hook.
2
+ # Do not edit this file; modify pyproject.toml instead.
2
3
numpy>=1.22
3
4
matplotlib>=3.5
4
5
pydata-sphinx-theme>=0.13
Original file line number Diff line number Diff line change 1
- # Generated from pyproject.toml
1
+ # Generated via tools/generate_requirements.py and pre-commit hook.
2
+ # Do not edit this file; modify pyproject.toml instead.
2
3
pytest
3
4
pytest-cov
4
5
matplotlib
Original file line number Diff line number Diff line change 12
12
except ImportError :
13
13
sys .exit ("Please install `tomli` first: `pip install tomli`" )
14
14
15
- repo_dir = (Path (__file__ ).parent / ".." ).resolve ()
16
- req_dir = repo_dir / "requirements"
17
- pyproject = toml .loads ((repo_dir / "pyproject.toml" ).read_text ())
18
-
19
- for key , opt_list in pyproject ["project" ]["optional-dependencies" ].items ():
20
- lines = ["# Generated from pyproject.toml" ] + opt_list
21
- req_fname = req_dir / f"{ key } .txt"
22
- req_fname .write_text ("\n " .join (lines ) + "\n " )
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