19
19
# under the License.
20
20
21
21
import os
22
- from setuptools import setup , find_packages , findall
22
+ import re
23
+ from setuptools import setup , find_packages
23
24
from horizon import version
24
25
25
26
27
+ ROOT = os .path .dirname (__file__ )
28
+ PIP_REQUIRES = os .path .join (ROOT , "tools" , "pip-requires" )
29
+ TEST_REQUIRES = os .path .join (ROOT , "tools" , "test-requires" )
30
+
31
+
32
+ """
33
+ We generate our install_requires and dependency_links from the
34
+ files listed in pip-requires and test-requires so that we don't have
35
+ to maintain the dependency definitions in two places.
36
+ """
37
+
38
+
39
+ def parse_requirements (* filenames ):
40
+ requirements = []
41
+ for f in filenames :
42
+ for line in open (f , 'r' ).read ().split ('\n ' ):
43
+ if re .match (r'(\s*#)|(\s*$)' , line ):
44
+ continue
45
+ if re .match (r'\s*-e\s+' , line ):
46
+ requirements .append (re .sub (r'\s*-e\s+.*#egg=(.*)$' , r'\1' , line ))
47
+ elif re .match (r'\s*-f\s+' , line ):
48
+ pass
49
+ else :
50
+ requirements .append (line )
51
+ return requirements
52
+
53
+
54
+ def parse_dependency_links (* filenames ):
55
+ dependency_links = []
56
+ for f in filenames :
57
+ for line in open (f , 'r' ).read ().split ('\n ' ):
58
+ if re .match (r'\s*-[ef]\s+' , line ):
59
+ line = re .sub (r'\s*-[ef]\s+' , '' , line )
60
+ line = re .sub (r'\s*git\+https' , 'http' , line )
61
+ line = re .sub (r'\.git#' , '/tarball/master#' , line )
62
+ dependency_links .append (line )
63
+ return dependency_links
64
+
65
+
26
66
def read (fname ):
27
- return open (os .path .join (os . path . dirname ( __file__ ) , fname )).read ()
67
+ return open (os .path .join (ROOT , fname )).read ()
28
68
29
69
30
70
setup (name = "horizon" ,
@@ -36,12 +76,9 @@ def read(fname):
36
76
author = 'Devin Carlen' ,
37
77
38
78
packages = find_packages (),
39
- package_data = {'horizon' : [s [len ('horizon/' ):] for s in
40
- findall ('horizon/templates' ) \
41
- + findall ('horizon/dashboards/nova/templates' ) \
42
- + findall ('horizon/dashboards/syspanel/templates' ) \
43
- + findall ('horizon/dashboards/settings/templates' )]},
44
- install_requires = [],
79
+ zip_safe = False ,
80
+ install_requires = parse_requirements (PIP_REQUIRES , TEST_REQUIRES ),
81
+ dependency_links = parse_dependency_links (PIP_REQUIRES , TEST_REQUIRES ),
45
82
classifiers = ['Development Status :: 4 - Beta' ,
46
83
'Framework :: Django' ,
47
84
'Intended Audience :: Developers' ,
0 commit comments