-
Notifications
You must be signed in to change notification settings - Fork 292
/
setup.py
57 lines (48 loc) · 1.67 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
from setuptools import setup, find_packages
# Shamelessly stolen (then modified) from https://github.com/cburgmer/pdfserver/blob/master/setup.py
def parse_requirements(file_name):
import re
requirements = []
for line in open(file_name, 'r').read().split('\n'):
if re.match(r'(\s*#)|(\s*$)', line):
continue
# if re.match(r'\s*-e\s+', line):
m = re.search(r"(git(?:\+\w{3})?|https?|svn)://.+#egg=(.*)$", line)
if m:
# FIXME: Can't install packages from source repos right now
if 'http' in m.group(1):
# Distutils can install Http served packages right now
# FIXME: Skip this now
# requirements.append(m.group(2))
pass
pass
elif re.match(r'\s*-f\s+', line):
pass
elif re.match(r'\s*-i\s+', line):
pass
else:
requirements.append(line)
return requirements
def parse_dependency_links(file_name):
import re
dependency_links = []
for line in open(file_name, 'r').read().split('\n'):
if re.match(r'\s*-[ef]\s+', line):
dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
continue
m = re.search(r"((?:git(?:\+ssh)|http|svn)://.+#egg=.*)$", line)
if m:
dependency_links.append(m.group(1))
return dependency_links
params = dict(
name='API Example',
packages=find_packages(),
install_requires=parse_requirements('requirements.txt'),
dependency_links=parse_dependency_links('requirements.txt'),
entry_points={
'console_scripts': [
]
},
)
setup(**params)