Skip to content

Commit 2042b89

Browse files
committed
Makes setup.py actually list it's dependencies for pip/easy_install.
Change-Id: I9b774f5d64662f67d2a4dd2d1dd4dc59be0f45df
1 parent a674025 commit 2042b89

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ openstack_dashboard/local/local_settings.py
1313
docs/build/
1414
docs/source/sourcecode
1515
.venv
16+
build
17+
dist

setup.py

+45-8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,52 @@
1919
# under the License.
2020

2121
import os
22-
from setuptools import setup, find_packages, findall
22+
import re
23+
from setuptools import setup, find_packages
2324
from horizon import version
2425

2526

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+
2666
def read(fname):
27-
return open(os.path.join(os.path.dirname(__file__), fname)).read()
67+
return open(os.path.join(ROOT, fname)).read()
2868

2969

3070
setup(name="horizon",
@@ -36,12 +76,9 @@ def read(fname):
3676
author='Devin Carlen',
3777
author_email='[email protected]',
3878
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),
4582
classifiers=['Development Status :: 4 - Beta',
4683
'Framework :: Django',
4784
'Intended Audience :: Developers',

tools/pip-requires

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ iso8601
1919
# Horizon Non-pip Requirements
2020
-e git+https://github.com/openstack/python-novaclient.git#egg=python-novaclient
2121
-e git+https://github.com/openstack/python-keystoneclient.git#egg=python-keystoneclient
22-
-e git+https://github.com/openstack/python-quantumclient.git#egg=python-quantumclient-dev
22+
-e git+https://github.com/openstack/python-quantumclient.git#egg=python-quantumclient
2323
-e git+https://github.com/openstack/glance.git#egg=glance

tools/test-requires

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Testing Requirements
22
CherryPy
33
coverage
4-
django-nose==0.1.2
4+
django-nose
55
django-nose-selenium
66
mox
7-
nose==1.0.0
7+
nose
88
pep8
99
pylint
1010

0 commit comments

Comments
 (0)