File tree Expand file tree Collapse file tree 5 files changed +56
-1
lines changed Expand file tree Collapse file tree 5 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1313 - checkout :
1414 path : /tmp/src/templateflow
1515
16+ - run :
17+ name : Generate requirements.txt
18+ command : |
19+ python /tmp/src/templateflow/.maint/update_requirements.py
20+
1621 - restore_cache :
1722 keys :
1823 - deps-v10-{{ checksum "/tmp/src/templateflow/requirements.txt"}}-{{ epoch }}
Original file line number Diff line number Diff line change 11# setuptools_scm
22templateflow /_version.py
33
4+ # circleci hash checking
5+ requirements.txt
6+ min-requirements.txt
7+
48# Byte-compiled / optimized / DLL files
59__pycache__ /
610* .py [cod ]
File renamed without changes.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ from copy import copy
3+ from pathlib import Path
4+ from packaging .requirements import Requirement , SpecifierSet
5+
6+ try :
7+ from tomllib import loads # Python +3.11
8+ except ImportError :
9+ from pip ._vendor .tomli import loads
10+
11+ repo_root = Path (__file__ ).parent .parent
12+ pyproject = repo_root / "pyproject.toml"
13+ reqs = repo_root / "requirements.txt"
14+ min_reqs = repo_root / "min-requirements.txt"
15+
16+ requirements = [
17+ Requirement (req )
18+ for req in loads (pyproject .read_text ())["project" ]["dependencies" ]
19+ ]
20+
21+ script_name = Path (__file__ ).relative_to (repo_root )
22+
23+
24+ def to_min (req ):
25+ if req .specifier :
26+ req = copy (req )
27+ try :
28+ min_spec = [spec for spec in req .specifier if spec .operator in (">=" , "~=" )][0 ]
29+ except IndexError :
30+ return req
31+ min_spec ._spec = ("==" ,) + min_spec ._spec [1 :]
32+ req .specifier = SpecifierSet (str (min_spec ))
33+ return req
34+
35+
36+ lines = [f"# Auto-generated by { script_name } " , "" ]
37+
38+ # Write requirements
39+ lines [1 :- 1 ] = [str (req ) for req in requirements ]
40+ reqs .write_text ("\n " .join (lines ))
41+
42+ # Write minimum requirements
43+ lines [1 :- 1 ] = [str (to_min (req )) for req in requirements ]
44+ min_reqs .write_text ("\n " .join (lines ))
Original file line number Diff line number Diff line change 11recursive-exclude templateflow/tests *
22recursive-exclude templateflow/conf/tests *
33recursive-exclude docs/ *
4+
45recursive-exclude .circleci/ *
56recursive-exclude .github/ *
7+ recursive-exclude .maint/ *
68
7- exclude .gitignore .gitattributes .git_archival.txt .travis.yml .zenodo.json codecov.yml update_changes.sh
9+ exclude .gitignore .gitattributes .git_archival.txt .travis.yml .zenodo.json codecov.yml
You can’t perform that action at this time.
0 commit comments