Skip to content

Commit 83d934e

Browse files
committed
MAINT: Add update_requirements.py; update requirements
1 parent e2639c4 commit 83d934e

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ matrix:
2929
# Absolute minimum dependencies
3030
- python: 3.5
3131
env:
32-
- DEPENDS="numpy==1.10.1 setuptools==30.3.0"
32+
- DEPENDS="-r min-requirements.txt setuptools==30.3.0"
3333
# Absolute minimum dependencies
3434
- python: 3.5
3535
env:
36-
- DEPENDS="numpy==1.10.1"
36+
- DEPENDS="-r min-requirements.txt"
3737
- CHECK_TYPE="import"
3838
# Absolute minimum dependencies plus oldest MPL
3939
# Check these against:
@@ -42,11 +42,11 @@ matrix:
4242
# requirements.txt
4343
- python: 3.5
4444
env:
45-
- DEPENDS="numpy==1.10.1 matplotlib==1.3.1"
45+
- DEPENDS="-r min-requirements.txt matplotlib==1.3.1"
4646
# Minimum pydicom dependency
4747
- python: 3.5
4848
env:
49-
- DEPENDS="numpy==1.10.1 pydicom==0.9.9 pillow==2.6"
49+
- DEPENDS="-r min-requirements.txt pydicom==0.9.9 pillow==2.6"
5050
# pydicom master branch
5151
- python: 3.5
5252
env:

doc/source/installation.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,10 @@ is for you.
8181
Requirements
8282
------------
8383

84-
.. check these against:
85-
nibabel/info.py
86-
requirements.txt
87-
.travis.yml
84+
.. check these against setup.cfg
8885
89-
* Python_ 2.7, or >= 3.4
90-
* NumPy_ 1.8 or greater
86+
* Python_ 3.5 or greater
87+
* NumPy_ 1.10.1 or greater
9188
* Six_ 1.3 or greater
9289
* SciPy_ (optional, for full SPM-ANALYZE support)
9390
* PyDICOM_ 0.9.9 or greater (optional, for DICOM support)

min-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Auto-generated by tools/update_requirements.py
2+
numpy ==1.10.1
3+
six ==1.3

requirements.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# Minumum requirements
2-
#
3-
# Check these against
4-
# nibabel/info.py
5-
# .travis.yml
6-
# doc/source/installation.rst
7-
8-
six>=1.3
9-
numpy>=1.10.1
1+
# Auto-generated by tools/update_requirements.py
2+
numpy >=1.10.1
3+
six >=1.3

tools/update_requirements.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
from configparser import ConfigParser
4+
from pathlib import Path
5+
6+
if sys.version_info < (3, 6):
7+
print("This script requires Python 3.6 to work correctly")
8+
sys.exit(1)
9+
10+
repo_root = Path(__file__).parent.parent
11+
setup_cfg = repo_root / "setup.cfg"
12+
reqs = repo_root / "requirements.txt"
13+
min_reqs = repo_root / "min-requirements.txt"
14+
15+
config = ConfigParser()
16+
config.read(setup_cfg)
17+
requirements = config.get("options", "install_requires").strip().splitlines()
18+
19+
script_name = Path(__file__).relative_to(repo_root)
20+
21+
lines = [f"# Auto-generated by {script_name}", ""]
22+
23+
# Write requirements
24+
lines[1:-1] = requirements
25+
reqs.write_text("\n".join(lines))
26+
27+
# Write minimum requirements
28+
lines[1:-1] = [req.replace(">=", "==").replace("~=", "==") for req in requirements]
29+
min_reqs.write_text("\n".join(lines))

0 commit comments

Comments
 (0)