Merge lp:~gary/launchpad/bug559128 into lp:launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~gary/launchpad/bug559128
Merge into: lp:launchpad
Diff against target: 297 lines (+64/-23)
12 files modified
Makefile (+1/-0)
buildout-templates/_pythonpath.py.in (+9/-3)
buildout-templates/bin/combine-css.in (+8/-2)
buildout-templates/bin/jstest.in (+7/-1)
buildout-templates/bin/kill-test-services.in (+6/-1)
buildout-templates/bin/lint.sh.in (+6/-4)
buildout-templates/bin/retest.in (+2/-1)
buildout-templates/bin/sprite-util.in (+7/-3)
buildout-templates/bin/test.in (+12/-5)
buildout-templates/bin/update-download-cache.in (+3/-1)
buildout.cfg (+1/-0)
versions.cfg (+2/-2)
To merge this branch: bzr merge lp:~gary/launchpad/bug559128
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) Approve
Review via email: mp+23876@code.launchpad.net

Commit message

Switch most of the buildout-generated code to using relative paths, to address bug 559128

Description of the change

This branch switches most of the buildout-generated code to using relative paths, to address bug 559128. Better distribution of compiled eggs will be a better solution to the underlying causes, but for now this fixes the problem and gets closer to making builds themselves use relative paths.

To test this for the current use case, get this branch in a directory with a unique name (like "bug559128" and run ``make bin/buildout && bin/buildout``. You can then grep the results for the string "bug559128". I only see them in the tags and the i18n scripts, which deployment does not use.

As an aside, in the future, LOSAs might like to be able to build an entire tree and just sync them out. If you run make build, currently only mailman adds further absolute paths. We probably won't be able to address that until we switch to Mailman 3 (after Python 2.6) but then it might be very easy. Further, if you run ``make run`` then +config-overrides.zcml gets an absolute path. Cleaning those up might give us a built tree that could be rsynced and run. That might be nice.

In any case, this branch accomplishes the relative path changes using new versions of z3c.recipe.filetemplate and our zc.buildout branches that support relative-paths. These have been reviewed separately. (https://code.edge.launchpad.net/~gary/z3c.recipe.filetemplate/relative-paths/+merge/23701 and https://code.edge.launchpad.net/~gary/zc.buildout/python-support-9-relative-paths/+merge/23696 , respectively). The syntax changes in the templates are described here: http://pypi.python.org/pypi/z3c.recipe.filetemplate#path-extensions and http://pypi.python.org/pypi/z3c.recipe.filetemplate#filters .

To post a comment you must log in.
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Looks good. I suppose we will QA this by removing the work-around from edge deployment config and seeing if the edge update breaks?

review: Approve
Revision history for this message
Gary Poster (gary) wrote :

On Apr 21, 2010, at 4:44 PM, Francis J. Lacoste wrote:

> Review: Approve
> Looks good. I suppose we will QA this by removing the work-around from edge deployment config and seeing if the edge update breaks?

Yeah. I also QA'd it by doing the following:

- (get branch and dependencies)
- make bin/buildout && bin/buildout
- cd ..
- mv (branch) (new location)
- cd (new location)
- make build
- make run

That worked. That's the closest thing I can figure on doing locally.

Gary

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2010-04-13 10:35:03 +0000
3+++ Makefile 2010-04-21 20:27:25 +0000
4@@ -334,6 +334,7 @@
5 $(RM) -rf $(APIDOC_DIR).tmp
6 $(RM) $(BZR_VERSION_INFO)
7 $(RM) _pythonpath.py
8+ $(RM) +config-overrides.zcml
9 $(RM) -rf \
10 /var/tmp/builddmaster \
11 /var/tmp/bzrsync \
12
13=== modified file 'buildout-templates/_pythonpath.py.in'
14--- buildout-templates/_pythonpath.py.in 2010-02-25 16:49:46 +0000
15+++ buildout-templates/_pythonpath.py.in 2010-04-21 20:27:25 +0000
16@@ -7,10 +7,14 @@
17 # This file works if the Python has been started with -S, or if bin/py
18 # has been used.
19
20+# Auto-generated code to handle relative paths
21+${python-relative-path-setup}
22+
23 import os
24 import sys
25
26-site_dir = "${scripts:parts-directory}"
27+
28+site_dir = ${scripts:parts-directory|path-repr}
29
30 if ('site' in sys.modules and
31 not sys.modules['site'].__file__.startswith(
32@@ -18,9 +22,11 @@
33 # We have the wrong site.py, so our paths are not set up correctly.
34 # We blow up, with a hopefully helpful error message.
35 raise RuntimeError(
36- 'The wrong site.py is imported. Scripts should usually be '
37+ 'The wrong site.py is imported (%r imported, %r expected). '
38+ 'Scripts should usually be '
39 "started with Launchpad's bin/py, or with a Python invoked with "
40- 'the -S flag.')
41+ 'the -S flag.' % (
42+ sys.modules['site'].__file__, os.path.join(site_dir, 'site.py')))
43
44 if site_dir not in sys.path:
45 sys.path.insert(0, site_dir)
46
47=== modified file 'buildout-templates/bin/combine-css.in'
48--- buildout-templates/bin/combine-css.in 2010-02-17 21:59:32 +0000
49+++ buildout-templates/bin/combine-css.in 2010-04-21 20:27:25 +0000
50@@ -1,4 +1,10 @@
51-#!/usr/bin/env ${buildout:directory}/bin/py
52+#!${buildout:executable} -S
53+
54+# Initialize our paths.
55+${python-relative-path-setup}
56+import sys
57+sys.path.insert(0, ${scripts:parts-directory|path-repr})
58+import site
59
60 import os
61
62@@ -6,7 +12,7 @@
63 from lazr.js.combo import combine_files
64
65
66-root = '${buildout:directory}'
67+root = ${buildout:directory|path-repr}
68 icing = os.path.join(root, 'lib/canonical/launchpad/icing')
69 target = os.path.join(icing, 'combo.css')
70 # It'd probably be nice to have this script find all the CSS files we might
71
72=== modified file 'buildout-templates/bin/jstest.in'
73--- buildout-templates/bin/jstest.in 2010-02-16 15:25:52 +0000
74+++ buildout-templates/bin/jstest.in 2010-04-21 20:27:25 +0000
75@@ -1,4 +1,4 @@
76-#! /usr/bin/env ${buildout:directory}/bin/py
77+#!${buildout:executable} -S
78 # Copyright 2009 Canonical Ltd. This software is licensed under the
79 # GNU Affero General Public License version 3 (see the file LICENSE).
80
81@@ -14,6 +14,12 @@
82
83 """
84
85+# Initialize our paths.
86+${python-relative-path-setup}
87+import sys
88+sys.path.insert(0, ${scripts:parts-directory|path-repr})
89+import site
90+
91 import subprocess
92 import os
93 from lp.scripts.utilities.lpwindmill import runLaunchpad
94
95=== modified file 'buildout-templates/bin/kill-test-services.in'
96--- buildout-templates/bin/kill-test-services.in 2010-02-03 13:33:24 +0000
97+++ buildout-templates/bin/kill-test-services.in 2010-04-21 20:27:25 +0000
98@@ -1,9 +1,14 @@
99-#! /usr/bin/env ${buildout:directory}/bin/py
100+#!${buildout:executable} -S
101 #
102 # Copyright 2009 Canonical Ltd. This software is licensed under the
103 # GNU Affero General Public License version 3 (see the file LICENSE).
104 """Kill all the test services that may persist between test runs."""
105
106+# Initialize our paths.
107+${python-relative-path-setup}
108+import sys
109+sys.path.insert(0, ${scripts:parts-directory|path-repr})
110+import site
111
112 # Tell canonical.config to use the testrunner config instance, so that
113 # we don't kill the real services.
114
115=== modified file 'buildout-templates/bin/lint.sh.in'
116--- buildout-templates/bin/lint.sh.in 2010-04-14 22:45:46 +0000
117+++ buildout-templates/bin/lint.sh.in 2010-04-21 20:27:25 +0000
118@@ -6,7 +6,9 @@
119 # Runs xmlint, pyflakes and pylint on files changed from parent branch.
120 # Use '-v' to run pylint under stricter conditions with additional messages.
121
122-utilitiesdir=`dirname $0`/../utilities
123+${shell-relative-path-setup}
124+
125+utilitiesdir=${buildout:directory/utilities|shell-path}
126 [ -z "$utilitiesdir" ] && utilitiesdir=.
127
128 # Fail if any of the required tools are not installed.
129@@ -153,7 +155,7 @@
130 echo " cp $4 $1"
131 echo " Run make schema again to update the test/dev database."
132 }
133-
134+
135 if [ -n "$sql_diff" -o -n "$sql_dev_diff" -o -n "$karma_bombs" ]; then
136 echo ""
137 echo ""
138@@ -161,7 +163,7 @@
139 echo ""
140 fi
141
142-#
143+#
144 if [ -n "$sql_diff" -o -n "$karma_bombs" ]; then
145 echo "$current_sql"
146 fi
147@@ -279,7 +281,7 @@
148 fi
149
150 extra_path="/usr/share/pyshared:/usr/share/pycentral/pylint/site-packages"
151-export PYTHONPATH="${os-paths}:$extra_path:$PYTHONPATH"
152+export PYTHONPATH=${scripts:parts-directory|shell-path}:"$extra_path":"$PYTHONPATH"
153 pylint="${buildout:executable} -Wi::DeprecationWarning `which pylint`"
154
155 # XXX sinzui 2007-10-18 bug=154140:
156
157=== modified file 'buildout-templates/bin/retest.in'
158--- buildout-templates/bin/retest.in 2009-10-01 10:12:28 +0000
159+++ buildout-templates/bin/retest.in 2010-04-21 20:27:25 +0000
160@@ -31,9 +31,10 @@
161 from itertools import takewhile
162 from pprint import pprint
163
164+${python-relative-path-setup}
165
166 # The test script for this branch.
167-TEST = '${buildout:directory}/bin/test'
168+TEST = ${buildout:directory/bin/test|path-repr}
169
170 # Regular expression to match numbered stories.
171 STORY_RE = re.compile("(.*)/\d{2}-.*")
172
173=== modified file 'buildout-templates/bin/sprite-util.in'
174--- buildout-templates/bin/sprite-util.in 2010-02-10 06:02:33 +0000
175+++ buildout-templates/bin/sprite-util.in 2010-04-21 20:27:25 +0000
176@@ -1,8 +1,13 @@
177-#!/usr/bin/env ${buildout:directory}/bin/py
178+#!${buildout:executable} -S
179
180 import os
181 import sys
182
183+# Initialize our paths.
184+${python-relative-path-setup}
185+sys.path.insert(0, ${scripts:parts-directory|path-repr})
186+import site
187+
188 from lp.services.spriteutils import SpriteUtil
189
190 command_options = ('create-image', 'create-css')
191@@ -21,8 +26,7 @@
192 print >> sys.stderr, usage()
193 sys.exit(2)
194
195-root = '${buildout:directory}'
196-icing = os.path.join(root, 'lib/canonical/launchpad/icing')
197+icing = ${buildout:directory/lib/canonical/launchpad/icing|path-repr}
198 combined_image_file = os.path.join(icing, 'icon-sprites')
199 positioning_file = os.path.join(icing, 'icon-sprites.positioning')
200 css_template_file = os.path.join(icing, 'style-3-0.css.in')
201
202=== modified file 'buildout-templates/bin/test.in'
203--- buildout-templates/bin/test.in 2010-04-07 12:03:10 +0000
204+++ buildout-templates/bin/test.in 2010-04-21 20:27:25 +0000
205@@ -1,4 +1,4 @@
206-#! /usr/bin/env ${buildout:directory}/bin/py
207+#!${buildout:executable} -S
208 ##############################################################################
209 #
210 # Copyright (c) 2004 Zope Corporation and Contributors.
211@@ -20,7 +20,14 @@
212
213 import logging, os, re, sys, time, warnings
214
215-BUILD_DIR = '${buildout:directory}'
216+# Initialize our paths.
217+${python-relative-path-setup}
218+import sys
219+sys.path.insert(0, ${scripts:parts-directory|path-repr})
220+import site
221+
222+BUILD_DIR = ${buildout:directory|path-repr}
223+CUSTOM_SITE_DIR = ${scripts:parts-directory|path-repr}
224
225 if os.getsid(0) == os.getsid(os.getppid()):
226 # We need to become the process group leader so test_on_merge.py
227@@ -43,7 +50,7 @@
228 assert os.environ['STORM_CEXTENSIONS'] == '1'
229
230 # Make sure our site.py is the one that subprocesses use.
231-os.environ['PYTHONPATH'] = "${scripts:parts-directory}"
232+os.environ['PYTHONPATH'] = CUSTOM_SITE_DIR
233
234 # Set a flag if this is the main testrunner process
235 if len(sys.argv) > 1 and sys.argv[1] == '--resume-layer':
236@@ -143,7 +150,7 @@
237 defaults = {
238 # Find tests in the tests and ftests directories
239 'tests_pattern': '^f?tests$',
240- 'test_path': ['${buildout:directory}/lib'],
241+ 'test_path': [${buildout:directory/lib|path-repr}],
242 'package': ['canonical', 'lp', 'devscripts'],
243 'layer': ['!(MailmanLayer)'],
244 }
245@@ -219,7 +226,7 @@
246 # e.g. run the test that you are currently editing.
247 try:
248 there = os.getcwd()
249- os.chdir('${buildout:directory}')
250+ os.chdir(BUILD_DIR)
251 result = testrunner.run([])
252 finally:
253 os.chdir(there)
254
255=== modified file 'buildout-templates/bin/update-download-cache.in'
256--- buildout-templates/bin/update-download-cache.in 2009-05-13 00:29:48 +0000
257+++ buildout-templates/bin/update-download-cache.in 2010-04-21 20:27:25 +0000
258@@ -1,2 +1,4 @@
259-bzr up ${buildout:directory}/buildout/download-cache
260+${shell-relative-path-setup}
261+
262+bzr up ${buildout:directory/buildout/download-cache|shell-path}
263
264
265=== modified file 'buildout.cfg'
266--- buildout.cfg 2010-04-07 12:03:10 +0000
267+++ buildout.cfg 2010-04-21 20:27:25 +0000
268@@ -11,6 +11,7 @@
269 unzip = true
270 eggs-directory = eggs
271 download-cache = download-cache
272+relative-paths = true
273
274 # Disable this option temporarily if you want buildout to find software
275 # dependencies *other* than those in our download-cache. Once you have the
276
277=== modified file 'versions.cfg'
278--- versions.cfg 2010-04-16 13:51:06 +0000
279+++ versions.cfg 2010-04-21 20:27:25 +0000
280@@ -94,7 +94,7 @@
281 z3c.pagelet = 1.0.2
282 z3c.pt = 1.0b16
283 z3c.ptcompat = 0.5.3
284-z3c.recipe.filetemplate = 2.0.2
285+z3c.recipe.filetemplate = 2.1.0
286 z3c.recipe.i18n = 0.5.3
287 z3c.recipe.scripts = 1.0.0dev-gary-r110068
288 z3c.recipe.tag = 0.2.0
289@@ -106,7 +106,7 @@
290 z3c.viewlet = 1.0.0
291 z3c.viewtemplate = 0.3.2
292 z3c.zrtresource = 1.0.1
293-zc.buildout = 1.5.0dev-gary-r110073
294+zc.buildout = 1.5.0dev-gary-r111190
295 zc.catalog = 1.2.0
296 zc.datetimewidget = 0.5.2
297 zc.i18n = 0.5.2