-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·41 lines (36 loc) · 1.7 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# =============================================================================
# @file setup.py
# @brief Installation setup file
# @author Michael Hucka <mhucka@caltech.edu>
# @license Please see the file named LICENSE in the project directory
# @website https://github.com/caltechlibrary/commonpy
#
# Note: the full configuration metadata is maintained in setup.cfg, not here.
# This file exists to hook in setup.cfg and requirements.txt, so that the
# requirements don't have to be repeated and so that "python3 setup.py" works.
# =============================================================================
from setuptools import setup
def requirements(file):
from os import path
required = []
requirements_file = path.join(path.abspath(path.dirname(__file__)), file)
if path.exists(requirements_file):
with open(requirements_file, encoding='utf-8') as f:
required = [ln for ln in filter(str.strip, f.read().splitlines())
if not ln.startswith('#')]
if any(item.startswith(('-', '.', '/')) for item in required):
# The requirements.txt uses pip features. Try to use pip's parser.
try:
from pip._internal.req import parse_requirements
from pip._internal.network.session import PipSession
parsed = parse_requirements(requirements_file, PipSession())
required = [item.requirement for item in parsed]
except ImportError:
# No pip, or not the expected version. Give up & return as-is.
pass
return required
setup(
setup_requires=['wheel'],
install_requires=requirements('requirements.txt'),
)