|
1 | 1 | from setuptools import setup
|
2 | 2 | from codecs import open
|
3 | 3 | from os import path
|
| 4 | +from pathlib import Path |
| 5 | +from typing import List |
4 | 6 |
|
5 | 7 | from pip_check_reqs import __version__
|
6 | 8 |
|
7 | 9 | here = path.abspath(path.dirname(__file__))
|
8 | 10 |
|
| 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 | + |
9 | 21 | with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
10 | 22 | long_description = f.read()
|
11 | 23 |
|
12 | 24 | with open(path.join(here, 'CHANGELOG.rst'), encoding='utf-8') as f:
|
13 | 25 | long_description += f.read()
|
14 | 26 |
|
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 | +) |
19 | 34 |
|
20 | 35 | setup(
|
21 | 36 | name='pip_check_reqs',
|
|
44 | 59 | 'pip-extra-reqs=pip_check_reqs.find_extra_reqs:main',
|
45 | 60 | ],
|
46 | 61 | },
|
47 |
| - install_requires=requirements, |
| 62 | + install_requires=INSTALL_REQUIRES, |
| 63 | + extras_require={'dev': DEV_REQUIRES}, |
48 | 64 | )
|
0 commit comments