Skip to content

Commit d6e1ba8

Browse files
committed
Enable pip install -e.[dev] to install development requirements
1 parent 227df47 commit d6e1ba8

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

setup.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
from setuptools import setup
22
from codecs import open
33
from os import path
4+
from pathlib import Path
5+
from typing import List
46

57
from pip_check_reqs import __version__
68

79
here = path.abspath(path.dirname(__file__))
810

11+
12+
def _get_dependencies(requirements_file: Path) -> List[str]:
13+
"""
14+
Return requirements from a requirements file.
15+
This expects a requirements file with no ``--find-links`` lines.
16+
"""
17+
lines = requirements_file.read_text().strip().split('\n')
18+
return [line for line in lines if not line.startswith('#')]
19+
20+
921
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
1022
long_description = f.read()
1123

1224
with open(path.join(here, 'CHANGELOG.rst'), encoding='utf-8') as f:
1325
long_description += f.read()
1426

15-
# This is not usual, but this project needs both install_requires
16-
# and requirements.txt and we'd like to not duplicate them
17-
with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f:
18-
requirements = [s.strip() for s in f.readlines()]
27+
INSTALL_REQUIRES = _get_dependencies(
28+
requirements_file=Path('requirements.txt'),
29+
)
30+
31+
DEV_REQUIRES = _get_dependencies(
32+
requirements_file=Path('test-requirements.txt'),
33+
)
1934

2035
setup(
2136
name='pip_check_reqs',
@@ -44,5 +59,6 @@
4459
'pip-extra-reqs=pip_check_reqs.find_extra_reqs:main',
4560
],
4661
},
47-
install_requires=requirements,
62+
install_requires=INSTALL_REQUIRES,
63+
extras_require={'dev': DEV_REQUIRES},
4864
)

0 commit comments

Comments
 (0)