Status: | Merged |
---|---|
Approved by: | Jonathan Lange |
Approved revision: | 134 |
Merged at revision: | 133 |
Proposed branch: | lp:~james-w/pkgme/buildout |
Merge into: | lp:pkgme |
Diff against target: |
858 lines (+551/-67) 12 files modified
.bzrignore (+6/-0) .testr.conf (+1/-1) Makefile (+18/-0) README.txt (+29/-22) bootstrap.py (+262/-0) buildout.cfg (+36/-0) buildout.mk (+81/-0) distribute_setup.py (+74/-36) setup.py (+0/-1) sphinx.mk (+3/-3) tarmac_tests.sh (+7/-4) versions.cfg (+34/-0) |
To merge this branch: | bzr merge lp:~james-w/pkgme/buildout |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange | Approve | ||
Review via email: mp+121275@code.launchpad.net |
Commit message
Re-instate buildout.
Description of the change
Hi,
This re-instates the buildout code for pkgme.
Thanks,
James
To post a comment you must log in.
lp:~james-w/pkgme/buildout
updated
- 134. By James Westby
-
Output the download-cache operations to the log file too.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2012-08-03 14:30:04 +0000 |
3 | +++ .bzrignore 2012-08-24 19:57:18 +0000 |
4 | @@ -6,3 +6,9 @@ |
5 | fixtures-0.3.5-py2.6.egg |
6 | bzr-orphans |
7 | virtualenv |
8 | +.installed.cfg |
9 | +./bin |
10 | +develop-eggs |
11 | +download-cache |
12 | +eggs |
13 | +parts |
14 | |
15 | === modified file '.testr.conf' |
16 | --- .testr.conf 2012-08-03 14:30:04 +0000 |
17 | +++ .testr.conf 2012-08-24 19:57:18 +0000 |
18 | @@ -1,3 +1,3 @@ |
19 | [DEFAULT] |
20 | -test_command=PYTHONPATH=`pwd` python -m subunit.run $IDLIST |
21 | +test_command=./bin/py -m subunit.run $IDLIST |
22 | test_id_list_default=pkgme.tests.test_suite |
23 | |
24 | === added file 'Makefile' |
25 | --- Makefile 1970-01-01 00:00:00 +0000 |
26 | +++ Makefile 2012-08-24 19:57:18 +0000 |
27 | @@ -0,0 +1,18 @@ |
28 | +# Copyright (C) 2012 Canonical Ltd. |
29 | +# |
30 | +# This program is free software: you can redistribute it and/or modify |
31 | +# it under the terms of the GNU General Public License as published by |
32 | +# the Free Software Foundation, version 3 of the License. |
33 | +# |
34 | +# This program is distributed in the hope that it will be useful, |
35 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
36 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37 | +# GNU General Public License for more details. |
38 | +# |
39 | +# You should have received a copy of the GNU General Public License |
40 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
41 | + |
42 | +include buildout.mk |
43 | +include sphinx.mk |
44 | + |
45 | +TEST_COMMAND=$(PY) -m testtools.run pkgme.tests.test_suite |
46 | |
47 | === modified file 'README.txt' |
48 | --- README.txt 2012-08-03 14:30:04 +0000 |
49 | +++ README.txt 2012-08-24 19:57:18 +0000 |
50 | @@ -34,16 +34,34 @@ |
51 | Developers |
52 | ========== |
53 | |
54 | -Right now, the best way to hack on ``pkgme`` is in a virtualenv_. This allows |
55 | -you to hack on ``pkgme`` in a clean environment, without touching or changing |
56 | -your system Python. You will need access to the internet in order to install |
57 | -``pkgme`` into your virtualenv. On Debian/Ubuntu, make sure you have the |
58 | -`python-virtualenv` package installed, then do the following:: |
59 | - |
60 | - % virtualenv /arbitrary/path |
61 | - % source /arbitrary/path/bin/activate |
62 | - % python setup.py develop |
63 | - <hack> |
64 | +To get a development environment set up (using ``buildout``) run:: |
65 | + |
66 | + $ make bootstrap |
67 | + |
68 | +You can then run the tests with |
69 | + |
70 | + $ make check |
71 | + |
72 | +The bootstrap will fail if you have a system-wide install of buildout that |
73 | +is the same version as the one in use by this project. (You will see |
74 | +``DistributionNotFound: zc.buildout==<version>``). If you encounter |
75 | +that then you can either remove the site-wide install, or use a virtualenv |
76 | +to run the bootstrap step. |
77 | + |
78 | +You can get a shell to try code interactively by running ``./bin/py``. |
79 | + |
80 | +Buildout uses two directories as caches that can be shared between branches. |
81 | +The first is the ``download-cache`` directory. This contains all of the |
82 | +distributions of the Python dependencies. You can get this from |
83 | +``lp:ca-download-cache``, but the Makefile will grab it for you. |
84 | + |
85 | +The other directory is the ``eggs`` directory that holds built versions |
86 | +of the dependencies. |
87 | + |
88 | +The default for both of these is to symlink them from the parent directory, |
89 | +but if you wish to put them somewhere else you can set the locations with |
90 | +the ``CA_DOWNLOAD_CACHE_DIR`` and ``CA_EGGS_DIR`` environment variables. |
91 | + |
92 | |
93 | If you want to override the default location of the backends, set the |
94 | environment variable ``$PKGME_BACKEND_PATHS``. This is a colon-separated list |
95 | @@ -51,18 +69,7 @@ |
96 | |
97 | % export PKGME_BACKEND_PATHS=/pkgme/foo-backends:/pkgme/bar-backends |
98 | % cd my-about-to-be-packaged-code |
99 | - % pkgme |
100 | - |
101 | -When you're done, just run the ``deactivate`` command and blow away |
102 | -`/arbitrary/path`. |
103 | - |
104 | - |
105 | -Testing |
106 | -------- |
107 | - |
108 | -While in your virtualenv, you can run the full test suite like so:: |
109 | - |
110 | - % python setup.py test |
111 | + % ~/path/to/branch/bin/pkgme |
112 | |
113 | |
114 | Building the documentation |
115 | |
116 | === added file 'bootstrap.py' |
117 | --- bootstrap.py 1970-01-01 00:00:00 +0000 |
118 | +++ bootstrap.py 2012-08-24 19:57:18 +0000 |
119 | @@ -0,0 +1,262 @@ |
120 | +############################################################################## |
121 | +# |
122 | +# Copyright (c) 2006 Zope Foundation and Contributors. |
123 | +# All Rights Reserved. |
124 | +# |
125 | +# This software is subject to the provisions of the Zope Public License, |
126 | +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
127 | +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
128 | +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
129 | +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
130 | +# FOR A PARTICULAR PURPOSE. |
131 | +# |
132 | +############################################################################## |
133 | +"""Bootstrap a buildout-based project |
134 | + |
135 | +Simply run this script in a directory containing a buildout.cfg. |
136 | +The script accepts buildout command-line options, so you can |
137 | +use the -c option to specify an alternate configuration file. |
138 | +""" |
139 | + |
140 | +import os, shutil, sys, tempfile, urllib, urllib2, subprocess |
141 | +from optparse import OptionParser |
142 | + |
143 | +if sys.platform == 'win32': |
144 | + def quote(c): |
145 | + if ' ' in c: |
146 | + return '"%s"' % c # work around spawn lamosity on windows |
147 | + else: |
148 | + return c |
149 | +else: |
150 | + quote = str |
151 | + |
152 | +# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. |
153 | +stdout, stderr = subprocess.Popen( |
154 | + [sys.executable, '-Sc', |
155 | + 'try:\n' |
156 | + ' import ConfigParser\n' |
157 | + 'except ImportError:\n' |
158 | + ' print 1\n' |
159 | + 'else:\n' |
160 | + ' print 0\n'], |
161 | + stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |
162 | +has_broken_dash_S = bool(int(stdout.strip())) |
163 | + |
164 | +# In order to be more robust in the face of system Pythons, we want to |
165 | +# run without site-packages loaded. This is somewhat tricky, in |
166 | +# particular because Python 2.6's distutils imports site, so starting |
167 | +# with the -S flag is not sufficient. However, we'll start with that: |
168 | +if not has_broken_dash_S and 'site' in sys.modules: |
169 | + # We will restart with python -S. |
170 | + args = sys.argv[:] |
171 | + args[0:0] = [sys.executable, '-S'] |
172 | + args = map(quote, args) |
173 | + os.execv(sys.executable, args) |
174 | +# Now we are running with -S. We'll get the clean sys.path, import site |
175 | +# because distutils will do it later, and then reset the path and clean |
176 | +# out any namespace packages from site-packages that might have been |
177 | +# loaded by .pth files. |
178 | +clean_path = sys.path[:] |
179 | +import site # imported because of its side effects |
180 | +sys.path[:] = clean_path |
181 | +for k, v in sys.modules.items(): |
182 | + if k in ('setuptools', 'pkg_resources') or ( |
183 | + hasattr(v, '__path__') and |
184 | + len(v.__path__) == 1 and |
185 | + not os.path.exists(os.path.join(v.__path__[0], '__init__.py'))): |
186 | + # This is a namespace package. Remove it. |
187 | + sys.modules.pop(k) |
188 | + |
189 | +is_jython = sys.platform.startswith('java') |
190 | + |
191 | +setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' |
192 | +distribute_source = 'http://python-distribute.org/distribute_setup.py' |
193 | + |
194 | + |
195 | +# parsing arguments |
196 | +def normalize_to_url(option, opt_str, value, parser): |
197 | + if value: |
198 | + if '://' not in value: # It doesn't smell like a URL. |
199 | + value = 'file://%s' % ( |
200 | + urllib.pathname2url( |
201 | + os.path.abspath(os.path.expanduser(value))),) |
202 | + if opt_str == '--download-base' and not value.endswith('/'): |
203 | + # Download base needs a trailing slash to make the world happy. |
204 | + value += '/' |
205 | + else: |
206 | + value = None |
207 | + name = opt_str[2:].replace('-', '_') |
208 | + setattr(parser.values, name, value) |
209 | + |
210 | +usage = '''\ |
211 | +[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] |
212 | + |
213 | +Bootstraps a buildout-based project. |
214 | + |
215 | +Simply run this script in a directory containing a buildout.cfg, using the |
216 | +Python that you want bin/buildout to use. |
217 | + |
218 | +Note that by using --setup-source and --download-base to point to |
219 | +local resources, you can keep this script from going over the network. |
220 | +''' |
221 | + |
222 | +parser = OptionParser(usage=usage) |
223 | +parser.add_option("-v", "--version", dest="version", |
224 | + help="use a specific zc.buildout version") |
225 | +parser.add_option("-d", "--distribute", |
226 | + action="store_true", dest="use_distribute", default=False, |
227 | + help="Use Distribute rather than Setuptools.") |
228 | +parser.add_option("--setup-source", action="callback", dest="setup_source", |
229 | + callback=normalize_to_url, nargs=1, type="string", |
230 | + help=("Specify a URL or file location for the setup file. " |
231 | + "If you use Setuptools, this will default to " + |
232 | + setuptools_source + "; if you use Distribute, this " |
233 | + "will default to " + distribute_source + ".")) |
234 | +parser.add_option("--download-base", action="callback", dest="download_base", |
235 | + callback=normalize_to_url, nargs=1, type="string", |
236 | + help=("Specify a URL or directory for downloading " |
237 | + "zc.buildout and either Setuptools or Distribute. " |
238 | + "Defaults to PyPI.")) |
239 | +parser.add_option("--eggs", |
240 | + help=("Specify a directory for storing eggs. Defaults to " |
241 | + "a temporary directory that is deleted when the " |
242 | + "bootstrap script completes.")) |
243 | +parser.add_option("-t", "--accept-buildout-test-releases", |
244 | + dest='accept_buildout_test_releases', |
245 | + action="store_true", default=False, |
246 | + help=("Normally, if you do not specify a --version, the " |
247 | + "bootstrap script and buildout gets the newest " |
248 | + "*final* versions of zc.buildout and its recipes and " |
249 | + "extensions for you. If you use this flag, " |
250 | + "bootstrap and buildout will get the newest releases " |
251 | + "even if they are alphas or betas.")) |
252 | +parser.add_option("-c", None, action="store", dest="config_file", |
253 | + help=("Specify the path to the buildout configuration " |
254 | + "file to be used.")) |
255 | + |
256 | +options, args = parser.parse_args() |
257 | + |
258 | +# if -c was provided, we push it back into args for buildout's main function |
259 | +if options.config_file is not None: |
260 | + args += ['-c', options.config_file] |
261 | + |
262 | +if options.eggs: |
263 | + eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) |
264 | +else: |
265 | + eggs_dir = tempfile.mkdtemp() |
266 | + |
267 | +if options.setup_source is None: |
268 | + if options.use_distribute: |
269 | + options.setup_source = distribute_source |
270 | + else: |
271 | + options.setup_source = setuptools_source |
272 | + |
273 | +if options.accept_buildout_test_releases: |
274 | + args.append('buildout:accept-buildout-test-releases=true') |
275 | +args.append('bootstrap') |
276 | + |
277 | +try: |
278 | + import pkg_resources |
279 | + import setuptools # A flag. Sometimes pkg_resources is installed alone. |
280 | + if not hasattr(pkg_resources, '_distribute'): |
281 | + raise ImportError |
282 | +except ImportError: |
283 | + ez_code = urllib2.urlopen( |
284 | + options.setup_source).read().replace('\r\n', '\n') |
285 | + ez = {} |
286 | + exec ez_code in ez |
287 | + setup_args = dict(to_dir=eggs_dir, download_delay=0) |
288 | + if options.download_base: |
289 | + setup_args['download_base'] = options.download_base |
290 | + if options.use_distribute: |
291 | + setup_args['no_fake'] = True |
292 | + ez['use_setuptools'](**setup_args) |
293 | + if 'pkg_resources' in sys.modules: |
294 | + reload(sys.modules['pkg_resources']) |
295 | + import pkg_resources |
296 | + # This does not (always?) update the default working set. We will |
297 | + # do it. |
298 | + for path in sys.path: |
299 | + if path not in pkg_resources.working_set.entries: |
300 | + pkg_resources.working_set.add_entry(path) |
301 | + |
302 | +cmd = [quote(sys.executable), |
303 | + '-c', |
304 | + quote('from setuptools.command.easy_install import main; main()'), |
305 | + '-mqNxd', |
306 | + quote(eggs_dir)] |
307 | + |
308 | +if not has_broken_dash_S: |
309 | + cmd.insert(1, '-S') |
310 | + |
311 | +find_links = options.download_base |
312 | +if not find_links: |
313 | + find_links = os.environ.get('bootstrap-testing-find-links') |
314 | +if find_links: |
315 | + cmd.extend(['-f', quote(find_links)]) |
316 | + |
317 | +if options.use_distribute: |
318 | + setup_requirement = 'distribute' |
319 | +else: |
320 | + setup_requirement = 'setuptools' |
321 | +ws = pkg_resources.working_set |
322 | +setup_requirement_path = ws.find( |
323 | + pkg_resources.Requirement.parse(setup_requirement)).location |
324 | +env = dict( |
325 | + os.environ, |
326 | + PYTHONPATH=setup_requirement_path) |
327 | + |
328 | +requirement = 'zc.buildout' |
329 | +version = options.version |
330 | +if version is None and not options.accept_buildout_test_releases: |
331 | + # Figure out the most recent final version of zc.buildout. |
332 | + import setuptools.package_index |
333 | + _final_parts = '*final-', '*final' |
334 | + |
335 | + def _final_version(parsed_version): |
336 | + for part in parsed_version: |
337 | + if (part[:1] == '*') and (part not in _final_parts): |
338 | + return False |
339 | + return True |
340 | + index = setuptools.package_index.PackageIndex( |
341 | + search_path=[setup_requirement_path]) |
342 | + if find_links: |
343 | + index.add_find_links((find_links,)) |
344 | + req = pkg_resources.Requirement.parse(requirement) |
345 | + if index.obtain(req) is not None: |
346 | + best = [] |
347 | + bestv = None |
348 | + for dist in index[req.project_name]: |
349 | + distv = dist.parsed_version |
350 | + if _final_version(distv): |
351 | + if bestv is None or distv > bestv: |
352 | + best = [dist] |
353 | + bestv = distv |
354 | + elif distv == bestv: |
355 | + best.append(dist) |
356 | + if best: |
357 | + best.sort() |
358 | + version = best[-1].version |
359 | +if version: |
360 | + requirement = '=='.join((requirement, version)) |
361 | +cmd.append(requirement) |
362 | + |
363 | +if is_jython: |
364 | + import subprocess |
365 | + exitcode = subprocess.Popen(cmd, env=env).wait() |
366 | +else: # Windows prefers this, apparently; otherwise we would prefer subprocess |
367 | + exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) |
368 | +if exitcode != 0: |
369 | + sys.stdout.flush() |
370 | + sys.stderr.flush() |
371 | + print ("An error occurred when trying to install zc.buildout. " |
372 | + "Look above this message for any errors that " |
373 | + "were output by easy_install.") |
374 | + sys.exit(exitcode) |
375 | + |
376 | +ws.add_entry(eggs_dir) |
377 | +ws.require(requirement) |
378 | +import zc.buildout.buildout |
379 | +zc.buildout.buildout.main(args) |
380 | +if not options.eggs: # clean up temporary egg directory |
381 | + shutil.rmtree(eggs_dir) |
382 | |
383 | === added file 'buildout.cfg' |
384 | --- buildout.cfg 1970-01-01 00:00:00 +0000 |
385 | +++ buildout.cfg 2012-08-24 19:57:18 +0000 |
386 | @@ -0,0 +1,36 @@ |
387 | +# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
388 | +# GNU Affero General Public License version 3 (see the file LICENSE). |
389 | + |
390 | +[buildout] |
391 | +parts = |
392 | + scripts |
393 | +unzip = true |
394 | +eggs-directory = eggs |
395 | +download-cache = download-cache |
396 | +relative-paths = true |
397 | + |
398 | +# Disable this option temporarily if you want buildout to find software |
399 | +# dependencies *other* than those in our download-cache. Once you have the |
400 | +# desired software, reenable this option (and check in the new software to |
401 | +# lp:ca-dependencies if this is going to be reviewed/merged/deployed.) |
402 | +install-from-cache = true |
403 | + |
404 | +# This also will need to be temporarily disabled or changed for package |
405 | +# upgrades. Newly-added packages should also add their desired version number |
406 | +# to versions.cfg. |
407 | +extends = versions.cfg |
408 | + |
409 | +allow-picked-versions = false |
410 | + |
411 | +prefer-final = true |
412 | + |
413 | +develop = . |
414 | + |
415 | +[scripts] |
416 | +recipe = z3c.recipe.scripts |
417 | +# Test dependencies get added here |
418 | +# python-subunit is needed for those that use testr |
419 | +eggs = pkgme |
420 | + python-subunit |
421 | +include-site-packages = false |
422 | +interpreter = py |
423 | |
424 | === added file 'buildout.mk' |
425 | --- buildout.mk 1970-01-01 00:00:00 +0000 |
426 | +++ buildout.mk 2012-08-24 19:57:18 +0000 |
427 | @@ -0,0 +1,81 @@ |
428 | +# Copyright (C) 2012 Canonical Ltd. |
429 | +# |
430 | +# This program is free software: you can redistribute it and/or modify |
431 | +# it under the terms of the GNU General Public License as published by |
432 | +# the Free Software Foundation, version 3 of the License. |
433 | +# |
434 | +# This program is distributed in the hope that it will be useful, |
435 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
436 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
437 | +# GNU General Public License for more details. |
438 | +# |
439 | +# You should have received a copy of the GNU General Public License |
440 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
441 | + |
442 | +EXTERNAL_PY?=python2.7 |
443 | +PY=./bin/py |
444 | + |
445 | +EXTERNAL_BUILDOUT?=$(EXTERNAL_PY) bootstrap.py |
446 | +BUILDOUT=./bin/buildout |
447 | + |
448 | +CA_EGGS_DIR?=../eggs |
449 | +CA_DOWNLOAD_CACHE_DIR?=../download-cache |
450 | + |
451 | +clean: |
452 | + $(RM) -r bin/buildout |
453 | + $(RM) -r bin/py |
454 | + $(RM) -r bin/discover |
455 | + $(RM) -r develop-eggs |
456 | + $(RM) -r parts |
457 | + $(RM) -r .installed.cfg |
458 | +ifeq ($(CA_EGGS_DIR),eggs) |
459 | + $(RM) -r eggs |
460 | +else |
461 | + $(RM) eggs |
462 | +endif |
463 | +ifeq ($(CA_DOWNLOAD_CACHE_DIR),download-cache) |
464 | + $(RM) -r download-cache |
465 | +else |
466 | + $(RM) download-cache |
467 | +endif |
468 | + |
469 | +download-cache: |
470 | +ifeq ($(CA_DOWNLOAD_CACHE_DIR),$@) |
471 | + bzr checkout lp:ca-download-cache $@ |
472 | +else |
473 | + [ -d $(CA_DOWNLOAD_CACHE_DIR) ] || bzr checkout lp:ca-download-cache $(CA_DOWNLOAD_CACHE_DIR) |
474 | + ln -s $(CA_DOWNLOAD_CACHE_DIR) $@ |
475 | +endif |
476 | + |
477 | +eggs: |
478 | +ifeq ($(CA_EGGS_DIR),$@) |
479 | + mkdir $@ |
480 | +else |
481 | + [ -d $(CA_EGGS_DIR) ] || mkdir $(CA_EGGS_DIR) |
482 | + ln -s $(CA_EGGS_DIR) $@ |
483 | +endif |
484 | + |
485 | +$(BUILDOUT): bootstrap.py buildout.cfg setup.py versions.cfg eggs download-cache |
486 | + $(EXTERNAL_BUILDOUT) --distribute --version 1.5.1 \ |
487 | + --download-base=download-cache/dist --eggs=eggs \ |
488 | + --setup-source distribute_setup.py |
489 | + touch --no-create $@ |
490 | + |
491 | +$(PY): $(BUILDOUT) |
492 | + $(BUILDOUT) |
493 | + touch --no-create $@ |
494 | + |
495 | +bootstrap: clean $(PY) |
496 | + |
497 | +test: $(PY) |
498 | + $(TEST_COMMAND) |
499 | + |
500 | +check: test |
501 | + |
502 | +# Can be used to update the dependencies when you change something |
503 | +# in versions.cfg. |
504 | +update-deps: $(BUILDOUT) |
505 | + $(BUILDOUT) buildout:install-from-cache=false buildout:allow-picked-versions=true |
506 | + |
507 | +.PHONY: bootstrap check clean test update-deps |
508 | +.DEFAULT_GOAL := $(PY) |
509 | |
510 | === modified file 'distribute_setup.py' |
511 | --- distribute_setup.py 2012-08-03 14:30:04 +0000 |
512 | +++ distribute_setup.py 2012-08-24 19:57:18 +0000 |
513 | @@ -46,7 +46,7 @@ |
514 | args = [quote(arg) for arg in args] |
515 | return os.spawnl(os.P_WAIT, sys.executable, *args) == 0 |
516 | |
517 | -DEFAULT_VERSION = "0.6.10" |
518 | +DEFAULT_VERSION = "0.6.28" |
519 | DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/" |
520 | SETUPTOOLS_FAKED_VERSION = "0.6c11" |
521 | |
522 | @@ -63,7 +63,7 @@ |
523 | """ % SETUPTOOLS_FAKED_VERSION |
524 | |
525 | |
526 | -def _install(tarball): |
527 | +def _install(tarball, install_args=()): |
528 | # extracting the tarball |
529 | tmpdir = tempfile.mkdtemp() |
530 | log.warn('Extracting in %s', tmpdir) |
531 | @@ -81,7 +81,7 @@ |
532 | |
533 | # installing |
534 | log.warn('Installing Distribute') |
535 | - if not _python_cmd('setup.py', 'install'): |
536 | + if not _python_cmd('setup.py', 'install', *install_args): |
537 | log.warn('Something went wrong during the installation.') |
538 | log.warn('See the error message above.') |
539 | finally: |
540 | @@ -144,7 +144,7 @@ |
541 | except ImportError: |
542 | return _do_download(version, download_base, to_dir, download_delay) |
543 | try: |
544 | - pkg_resources.require("distribute>="+version) |
545 | + pkg_resources.require("distribute>=" + version) |
546 | return |
547 | except pkg_resources.VersionConflict: |
548 | e = sys.exc_info()[1] |
549 | @@ -167,6 +167,7 @@ |
550 | if not no_fake: |
551 | _create_fake_setuptools_pkg_info(to_dir) |
552 | |
553 | + |
554 | def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, |
555 | to_dir=os.curdir, delay=15): |
556 | """Download distribute from a specified location and return its filename |
557 | @@ -204,6 +205,31 @@ |
558 | return os.path.realpath(saveto) |
559 | |
560 | |
561 | +def _no_sandbox(function): |
562 | + def __no_sandbox(*args, **kw): |
563 | + try: |
564 | + from setuptools.sandbox import DirectorySandbox |
565 | + if not hasattr(DirectorySandbox, '_old'): |
566 | + def violation(*args): |
567 | + pass |
568 | + DirectorySandbox._old = DirectorySandbox._violation |
569 | + DirectorySandbox._violation = violation |
570 | + patched = True |
571 | + else: |
572 | + patched = False |
573 | + except ImportError: |
574 | + patched = False |
575 | + |
576 | + try: |
577 | + return function(*args, **kw) |
578 | + finally: |
579 | + if patched: |
580 | + DirectorySandbox._violation = DirectorySandbox._old |
581 | + del DirectorySandbox._old |
582 | + |
583 | + return __no_sandbox |
584 | + |
585 | + |
586 | def _patch_file(path, content): |
587 | """Will backup the file then patch it""" |
588 | existing_content = open(path).read() |
589 | @@ -220,38 +246,20 @@ |
590 | f.close() |
591 | return True |
592 | |
593 | +_patch_file = _no_sandbox(_patch_file) |
594 | + |
595 | |
596 | def _same_content(path, content): |
597 | return open(path).read() == content |
598 | |
599 | -def _no_sandbox(function): |
600 | - def __no_sandbox(*args, **kw): |
601 | - try: |
602 | - from setuptools.sandbox import DirectorySandbox |
603 | - def violation(*args): |
604 | - pass |
605 | - DirectorySandbox._old = DirectorySandbox._violation |
606 | - DirectorySandbox._violation = violation |
607 | - patched = True |
608 | - except ImportError: |
609 | - patched = False |
610 | - |
611 | - try: |
612 | - return function(*args, **kw) |
613 | - finally: |
614 | - if patched: |
615 | - DirectorySandbox._violation = DirectorySandbox._old |
616 | - del DirectorySandbox._old |
617 | - |
618 | - return __no_sandbox |
619 | - |
620 | -@_no_sandbox |
621 | + |
622 | def _rename_path(path): |
623 | new_name = path + '.OLD.%s' % time.time() |
624 | log.warn('Renaming %s into %s', path, new_name) |
625 | os.rename(path, new_name) |
626 | return new_name |
627 | |
628 | + |
629 | def _remove_flat_installation(placeholder): |
630 | if not os.path.isdir(placeholder): |
631 | log.warn('Unkown installation at %s', placeholder) |
632 | @@ -285,13 +293,15 @@ |
633 | 'Setuptools distribution', element) |
634 | return True |
635 | |
636 | +_remove_flat_installation = _no_sandbox(_remove_flat_installation) |
637 | + |
638 | |
639 | def _after_install(dist): |
640 | log.warn('After install bootstrap.') |
641 | placeholder = dist.get_command_obj('install').install_purelib |
642 | _create_fake_setuptools_pkg_info(placeholder) |
643 | |
644 | -@_no_sandbox |
645 | + |
646 | def _create_fake_setuptools_pkg_info(placeholder): |
647 | if not placeholder or not os.path.exists(placeholder): |
648 | log.warn('Could not find the install location') |
649 | @@ -304,6 +314,9 @@ |
650 | log.warn('%s already exists', pkg_info) |
651 | return |
652 | |
653 | + if not os.access(pkg_info, os.W_OK): |
654 | + log.warn("Don't have permissions to write %s, skipping", pkg_info) |
655 | + |
656 | log.warn('Creating %s', pkg_info) |
657 | f = open(pkg_info, 'w') |
658 | try: |
659 | @@ -319,6 +332,11 @@ |
660 | finally: |
661 | f.close() |
662 | |
663 | +_create_fake_setuptools_pkg_info = _no_sandbox( |
664 | + _create_fake_setuptools_pkg_info |
665 | +) |
666 | + |
667 | + |
668 | def _patch_egg_dir(path): |
669 | # let's check if it's already patched |
670 | pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') |
671 | @@ -337,6 +355,8 @@ |
672 | f.close() |
673 | return True |
674 | |
675 | +_patch_egg_dir = _no_sandbox(_patch_egg_dir) |
676 | + |
677 | |
678 | def _before_install(): |
679 | log.warn('Before install bootstrap.') |
680 | @@ -346,7 +366,7 @@ |
681 | def _under_prefix(location): |
682 | if 'install' not in sys.argv: |
683 | return True |
684 | - args = sys.argv[sys.argv.index('install')+1:] |
685 | + args = sys.argv[sys.argv.index('install') + 1:] |
686 | for index, arg in enumerate(args): |
687 | for option in ('--root', '--prefix'): |
688 | if arg.startswith('%s=' % option): |
689 | @@ -354,10 +374,10 @@ |
690 | return location.startswith(top_dir) |
691 | elif arg == option: |
692 | if len(args) > index: |
693 | - top_dir = args[index+1] |
694 | + top_dir = args[index + 1] |
695 | return location.startswith(top_dir) |
696 | - elif option == '--user' and USER_SITE is not None: |
697 | - return location.startswith(USER_SITE) |
698 | + if arg == '--user' and USER_SITE is not None: |
699 | + return location.startswith(USER_SITE) |
700 | return True |
701 | |
702 | |
703 | @@ -371,11 +391,14 @@ |
704 | return |
705 | ws = pkg_resources.working_set |
706 | try: |
707 | - setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools', |
708 | - replacement=False)) |
709 | + setuptools_dist = ws.find( |
710 | + pkg_resources.Requirement.parse('setuptools', replacement=False) |
711 | + ) |
712 | except TypeError: |
713 | # old distribute API |
714 | - setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools')) |
715 | + setuptools_dist = ws.find( |
716 | + pkg_resources.Requirement.parse('setuptools') |
717 | + ) |
718 | |
719 | if setuptools_dist is None: |
720 | log.warn('No setuptools distribution found') |
721 | @@ -416,6 +439,10 @@ |
722 | def _relaunch(): |
723 | log.warn('Relaunching...') |
724 | # we have to relaunch the process |
725 | + # pip marker to avoid a relaunch bug |
726 | + _cmd = ['-c', 'install', '--single-version-externally-managed'] |
727 | + if sys.argv[:3] == _cmd: |
728 | + sys.argv[0] = 'setup.py' |
729 | args = [sys.executable] + sys.argv |
730 | sys.exit(subprocess.call(args)) |
731 | |
732 | @@ -440,7 +467,7 @@ |
733 | # Extract directories with a safe mode. |
734 | directories.append(tarinfo) |
735 | tarinfo = copy.copy(tarinfo) |
736 | - tarinfo.mode = 448 # decimal for oct 0700 |
737 | + tarinfo.mode = 448 # decimal for oct 0700 |
738 | self.extract(tarinfo, path) |
739 | |
740 | # Reverse sort directories. |
741 | @@ -467,10 +494,21 @@ |
742 | self._dbg(1, "tarfile: %s" % e) |
743 | |
744 | |
745 | +def _build_install_args(argv): |
746 | + install_args = [] |
747 | + user_install = '--user' in argv |
748 | + if user_install and sys.version_info < (2, 6): |
749 | + log.warn("--user requires Python 2.6 or later") |
750 | + raise SystemExit(1) |
751 | + if user_install: |
752 | + install_args.append('--user') |
753 | + return install_args |
754 | + |
755 | + |
756 | def main(argv, version=DEFAULT_VERSION): |
757 | """Install or upgrade setuptools and EasyInstall""" |
758 | tarball = download_setuptools() |
759 | - _install(tarball) |
760 | + _install(tarball, _build_install_args(argv)) |
761 | |
762 | |
763 | if __name__ == '__main__': |
764 | |
765 | === modified file 'setup.py' |
766 | --- setup.py 2012-08-03 15:36:41 +0000 |
767 | +++ setup.py 2012-08-24 19:57:18 +0000 |
768 | @@ -65,7 +65,6 @@ |
769 | url='http://launchpad.net/pkgme', |
770 | test_suite='pkgme.tests', |
771 | install_requires = [ |
772 | - 'argparse', |
773 | 'Cheetah', |
774 | 'python_debian', |
775 | 'fixtures', |
776 | |
777 | === renamed file 'Makefile' => 'sphinx.mk' |
778 | --- Makefile 2012-08-03 14:30:04 +0000 |
779 | +++ sphinx.mk 2012-08-24 19:57:18 +0000 |
780 | @@ -11,9 +11,9 @@ |
781 | PAPEROPT_letter = -D latex_paper_size=letter |
782 | ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . |
783 | |
784 | -.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest |
785 | +.PHONY: sphinx-help clean-sphinx html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest |
786 | |
787 | -help: |
788 | +sphinx-help: |
789 | @echo "Please use \`make <target>' where <target> is one of" |
790 | @echo " html to make standalone HTML files" |
791 | @echo " dirhtml to make HTML files named index.html in directories" |
792 | @@ -26,7 +26,7 @@ |
793 | @echo " linkcheck to check all external links for integrity" |
794 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" |
795 | |
796 | -clean: |
797 | +clean-sphinx: |
798 | -rm -rf _build/* |
799 | |
800 | html: |
801 | |
802 | === modified file 'tarmac_tests.sh' |
803 | --- tarmac_tests.sh 2012-08-03 14:30:04 +0000 |
804 | +++ tarmac_tests.sh 2012-08-24 19:57:18 +0000 |
805 | @@ -2,7 +2,10 @@ |
806 | |
807 | set -e |
808 | |
809 | -virtualenv --no-site-packages virtualenv > log |
810 | -. virtualenv/bin/activate >> log |
811 | -python setup.py develop >> log |
812 | -python -m testtools.run pkgme.tests.test_suite |
813 | +LOG_FILE=log |
814 | + |
815 | +echo "Running pkgme tests in tarmac" > $LOG_FILE |
816 | +make download-cache >> $LOG_FILE |
817 | +bzr up download-cache >> $LOG_FILE |
818 | +make bootstrap >> $LOG_FILE |
819 | +make test |
820 | |
821 | === added file 'versions.cfg' |
822 | --- versions.cfg 1970-01-01 00:00:00 +0000 |
823 | +++ versions.cfg 2012-08-24 19:57:18 +0000 |
824 | @@ -0,0 +1,34 @@ |
825 | +[buildout] |
826 | +versions = versions |
827 | + |
828 | +# Update the version number here to upgrade to a new version. |
829 | +# You'll likely want to run 'make update-deps' when you have |
830 | +# changed something here. |
831 | +# |
832 | +# If you are forking a dependency then make sure you include a pointer |
833 | +# to the branch where the fork is maintained. |
834 | +# |
835 | +# Alphabetical, case-insensitive, please! :-) |
836 | +[versions] |
837 | +Cheetah = 2.4.4 |
838 | +distribute = 0.6.28 |
839 | +fixtures = 0.3.9 |
840 | +httplib2 = 0.7.4 |
841 | +keyring = 0.9.2 |
842 | +launchpadlib = 1.10.2 |
843 | +lazr.authentication = 0.1.2 |
844 | +lazr.restfulclient = 0.13.0 |
845 | +lazr.uri = 1.0.3 |
846 | +Markdown = 2.2.0 |
847 | +oauth = 1.0.1 |
848 | +python-debian = 0.1.16 |
849 | +python-subunit = 0.0.8 |
850 | +simplejson = 2.6.1 |
851 | +testresources = 0.2.5 |
852 | +testtools = 0.9.15 |
853 | +wadllib = 1.3.1 |
854 | +wsgi-intercept = 0.5.1 |
855 | +z3c.recipe.scripts = 1.0.1 |
856 | +zc.buildout = 1.5.1 |
857 | +zc.recipe.egg = 1.3.2 |
858 | +zope.interface = 4.0.1 |
Hurrah!