Merge lp:~xtoddx/nova/glance-venv into lp:~hudson-openstack/nova/trunk

Proposed by Todd Willey
Status: Work in progress
Proposed branch: lp:~xtoddx/nova/glance-venv
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 203 lines (+91/-79)
1 file modified
tools/install_venv.py (+91/-79)
To merge this branch: bzr merge lp:~xtoddx/nova/glance-venv
Reviewer Review Type Date Requested Status
Soren Hansen (community) Needs Resubmitting
Jay Pipes (community) Disapprove
Review via email: mp+46537@code.launchpad.net

Description of the change

Add glance to venv. I'm doing this as a .pth file similar to how we do it for nova. I think we should have all openstack components as .pth files and not as pip packages in case we're working on developing a feature that touches multiple packages.

lp:~citrix-openstack has a branch (lp:~citrix-openstack/nova/xenapi-glance-2) that adds glance to pip-requires instead. We should figure out which makes more sense and make sure we don't conflict.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

I don't think we should treat Glance differently than any other dependency, so I'm going to vote no on this one...plus, there's a bug that I'm currently addressing this issue in: https://bugs.launchpad.net/nova/+bug/704176

review: Disapprove
lp:~xtoddx/nova/glance-venv updated
575. By Todd Willey

pep8 on tools/nova_venv.py, even though it isn't checked by hudson.

Revision history for this message
Soren Hansen (soren) wrote :

Bexar GammaFreeze has kicked in, deferred to Cactus. Setting to "Work in Progress" to clear the review queue. Feel free to set back to "Needs Review" once Cactus opens up (of if this issue gets promoted to a release critical one).

review: Needs Resubmitting

Unmerged revisions

575. By Todd Willey

pep8 on tools/nova_venv.py, even though it isn't checked by hudson.

574. By Todd Willey

clean up file writes, and use two-levels of dirname calls for right path.

573. By Todd Willey

Add glance to venv.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/install_venv.py'
2--- tools/install_venv.py 2011-01-11 18:11:30 +0000
3+++ tools/install_venv.py 2011-01-17 22:37:41 +0000
4@@ -30,108 +30,120 @@
5 ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
6 VENV = os.path.join(ROOT, '.nova-venv')
7 PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires')
8-TWISTED_NOVA='http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz'
9+TWISTED_NOVA = 'http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz'
10+
11
12 def die(message, *args):
13- print >>sys.stderr, message % args
14- sys.exit(1)
15+ print >>sys.stderr, message % args
16+ sys.exit(1)
17
18
19 def run_command(cmd, redirect_output=True, check_exit_code=True):
20- """
21- Runs a command in an out-of-process shell, returning the
22- output of that command. Working directory is ROOT.
23- """
24- if redirect_output:
25- stdout = subprocess.PIPE
26- else:
27- stdout = None
28-
29- proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
30- output = proc.communicate()[0]
31- if check_exit_code and proc.returncode != 0:
32- die('Command "%s" failed.\n%s', ' '.join(cmd), output)
33- return output
34-
35-
36-HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], check_exit_code=False).strip())
37-HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], check_exit_code=False).strip())
38+ """
39+ Runs a command in an out-of-process shell, returning the
40+ output of that command. Working directory is ROOT.
41+ """
42+ if redirect_output:
43+ stdout = subprocess.PIPE
44+ else:
45+ stdout = None
46+
47+ proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
48+ output = proc.communicate()[0]
49+ if check_exit_code and proc.returncode != 0:
50+ die('Command "%s" failed.\n%s', ' '.join(cmd), output)
51+ return output
52+
53+
54+HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
55+ check_exit_code=False).strip())
56+HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
57+ check_exit_code=False).strip())
58
59
60 def check_dependencies():
61- """Make sure virtualenv is in the path."""
62+ """Make sure virtualenv is in the path."""
63
64- if not HAS_VIRTUALENV:
65- print 'not found.'
66- # Try installing it via easy_install...
67- if HAS_EASY_INSTALL:
68- print 'Installing virtualenv via easy_install...',
69- if not (run_command(['which', 'easy_install']) and
70- run_command(['easy_install', 'virtualenv'])):
71- die('ERROR: virtualenv not found.\n\nNova development requires virtualenv,'
72- ' please install it using your favorite package management tool')
73- print 'done.'
74- print 'done.'
75+ if not HAS_VIRTUALENV:
76+ print 'not found.'
77+ # Try installing it via easy_install...
78+ if HAS_EASY_INSTALL:
79+ print 'Installing virtualenv via easy_install...',
80+ if not (run_command(['which', 'easy_install']) and
81+ run_command(['easy_install', 'virtualenv'])):
82+ die('ERROR: virtualenv not found.\n\nNova development '
83+ 'requires virtualenv, please install it using your '
84+ 'favorite package management tool')
85+ print 'done.'
86+ print 'done.'
87
88
89 def create_virtualenv(venv=VENV):
90- """Creates the virtual environment and installs PIP only into the
91- virtual environment
92- """
93- print 'Creating venv...',
94- run_command(['virtualenv', '-q', '--no-site-packages', VENV])
95- print 'done.'
96- print 'Installing pip in virtualenv...',
97- if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
98- die("Failed to install pip.")
99- print 'done.'
100+ """Creates the virtual environment and installs PIP only into the
101+ virtual environment
102+ """
103+ print 'Creating venv...',
104+ run_command(['virtualenv', '-q', '--no-site-packages', VENV])
105+ print 'done.'
106+ print 'Installing pip in virtualenv...',
107+ if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
108+ die("Failed to install pip.")
109+ print 'done.'
110
111
112 def install_dependencies(venv=VENV):
113- print 'Installing dependencies with pip (this can take a while)...'
114- # Install greenlet by hand - just listing it in the requires file does not
115- # get it in stalled in the right order
116- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, 'greenlet'],
117- redirect_output=False)
118- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
119- redirect_output=False)
120- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, TWISTED_NOVA],
121- redirect_output=False)
122-
123-
124- # Tell the virtual env how to "import nova"
125- pthfile = os.path.join(venv, "lib", "python2.6", "site-packages", "nova.pth")
126- f = open(pthfile, 'w')
127- f.write("%s\n" % ROOT)
128+ print 'Installing dependencies with pip (this can take a while)...'
129+ # Install greenlet by hand - just listing it in the requires file does not
130+ # get it in stalled in the right order
131+ run_command(
132+ ['tools/with_venv.sh', 'pip', 'install', '-E', venv, 'greenlet'],
133+ redirect_output=False)
134+ run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv,
135+ '-r', PIP_REQUIRES], redirect_output=False)
136+ run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv,
137+ TWISTED_NOVA], redirect_output=False)
138+
139+ # Tell the virtual env how to "import nova"
140+ pthfile = os.path.join(venv, "lib", "python2.6", "site-packages",
141+ "nova.pth")
142+ with open(pthfile, 'w') as f:
143+ f.write("%s\n" % ROOT)
144+
145+ # Tell the virtual env how to "import glance"
146+ import glance
147+ glancedir = os.path.dirname(os.path.dirname(glance.__file__))
148+ pthfile = os.path.join(venv, "lib", "python2.6", "site-packages",
149+ "glance.pth")
150+ with open(pthfile, 'w') as f:
151+ f.write("%s\n" % glancedir)
152
153
154 def print_help():
155- help = """
156- Nova development environment setup is complete.
157-
158- Nova development uses virtualenv to track and manage Python dependencies
159- while in development and testing.
160-
161- To activate the Nova virtualenv for the extent of your current shell session
162- you can run:
163-
164- $ source .nova-venv/bin/activate
165-
166- Or, if you prefer, you can run commands in the virtualenv on a case by case
167- basis by running:
168+ help = """Nova development environment setup is complete.
169+
170+Nova development uses virtualenv to track and manage Python dependencies
171+while in development and testing.
172+
173+To activate the Nova virtualenv for the extent of your current shell session
174+you can run:
175+
176+ $ source .nova-venv/bin/activate
177+
178+Or, if you prefer, you can run commands in the virtualenv on a case by case
179+basis by running:
180
181 $ tools/with_venv.sh <your command>
182
183- Also, make test will automatically use the virtualenv.
184- """
185- print help
186+Also, make test will automatically use the virtualenv.
187+"""
188+ print help
189
190
191 def main(argv):
192- check_dependencies()
193- create_virtualenv()
194- install_dependencies()
195- print_help()
196+ check_dependencies()
197+ create_virtualenv()
198+ install_dependencies()
199+ print_help()
200
201 if __name__ == '__main__':
202- main(sys.argv)
203+ main(sys.argv)