|
5 | 5 |
|
6 | 6 | # Shamelessly stolen (then modified) from https://github.com/cburgmer/pdfserver/blob/master/setup.py
|
7 | 7 | def parse_requirements(file_name):
|
8 |
| - import re |
9 |
| - requirements = [] |
10 |
| - for line in open(file_name, 'r').read().split('\n'): |
11 |
| - if re.match(r'(\s*#)|(\s*$)', line): |
12 |
| - continue |
13 |
| - # if re.match(r'\s*-e\s+', line): |
14 |
| - m = re.search(r"(git(?:\+\w{3})?|https?|svn)://.+#egg=(.*)$", line) |
15 |
| - if m: |
16 |
| - # FIXME: Can't install packages from source repos right now |
17 |
| - if 'http' in m.group(1): |
18 |
| - # Distutils can install Http served packages right now |
19 |
| - # FIXME: Skip this now |
20 |
| - # requirements.append(m.group(2)) |
21 |
| - pass |
22 |
| - pass |
23 |
| - elif re.match(r'\s*-f\s+', line): |
24 |
| - pass |
25 |
| - elif re.match(r'\s*-i\s+', line): |
26 |
| - pass |
27 |
| - else: |
28 |
| - requirements.append(line) |
29 |
| - |
30 |
| - return requirements |
| 8 | + import re |
| 9 | + requirements = [] |
| 10 | + for line in open(file_name, 'r').read().split('\n'): |
| 11 | + if re.match(r'(\s*#)|(\s*$)', line): |
| 12 | + continue |
| 13 | + # if re.match(r'\s*-e\s+', line): |
| 14 | + m = re.search(r"(git(?:\+\w{3})?|https?|svn)://.+#egg=(.*)$", line) |
| 15 | + if m: |
| 16 | + # FIXME: Can't install packages from source repos right now |
| 17 | + if 'http' in m.group(1): |
| 18 | + # Distutils can install Http served packages right now |
| 19 | + # FIXME: Skip this now |
| 20 | + # requirements.append(m.group(2)) |
| 21 | + pass |
| 22 | + pass |
| 23 | + elif re.match(r'\s*-f\s+', line): |
| 24 | + pass |
| 25 | + elif re.match(r'\s*-i\s+', line): |
| 26 | + pass |
| 27 | + else: |
| 28 | + requirements.append(line) |
| 29 | + |
| 30 | + return requirements |
31 | 31 |
|
32 | 32 |
|
33 | 33 | def parse_dependency_links(file_name):
|
34 |
| - import re |
35 |
| - dependency_links = [] |
36 |
| - for line in open(file_name, 'r').read().split('\n'): |
37 |
| - if re.match(r'\s*-[ef]\s+', line): |
38 |
| - dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line)) |
39 |
| - continue |
40 |
| - m = re.search(r"((?:git(?:\+ssh)|http|svn)://.+#egg=.*)$", line) |
41 |
| - if m: |
42 |
| - dependency_links.append(m.group(1)) |
43 |
| - |
44 |
| - return dependency_links |
| 34 | + import re |
| 35 | + dependency_links = [] |
| 36 | + for line in open(file_name, 'r').read().split('\n'): |
| 37 | + if re.match(r'\s*-[ef]\s+', line): |
| 38 | + dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line)) |
| 39 | + continue |
| 40 | + m = re.search(r"((?:git(?:\+ssh)|http|svn)://.+#egg=.*)$", line) |
| 41 | + if m: |
| 42 | + dependency_links.append(m.group(1)) |
| 43 | + |
| 44 | + return dependency_links |
45 | 45 |
|
46 | 46 | params = dict(
|
47 |
| - name='API Example', |
48 |
| - packages=find_packages(), |
49 |
| - install_requires=parse_requirements('requirements.txt'), |
50 |
| - dependency_links=parse_dependency_links('requirements.txt'), |
51 |
| - entry_points={ |
52 |
| - 'console_scripts': [ |
53 |
| - ] |
54 |
| - }, |
| 47 | + name='API Example', |
| 48 | + packages=find_packages(), |
| 49 | + install_requires=parse_requirements('requirements.txt'), |
| 50 | + dependency_links=parse_dependency_links('requirements.txt'), |
| 51 | + entry_points={ |
| 52 | + 'console_scripts': [ |
| 53 | + ] |
| 54 | + }, |
55 | 55 | )
|
56 | 56 |
|
57 | 57 | setup(**params)
|
0 commit comments