Merge lp:~camptocamp/anybox.buildbot.openerp/trunk-fix_1283084-afe into lp:anybox.buildbot.openerp

Proposed by Alexandre Fayolle - camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/anybox.buildbot.openerp/trunk-fix_1283084-afe
Merge into: lp:anybox.buildbot.openerp
Diff against target: 302 lines (+73/-163)
1 file modified
buildouts/bootstrap.py (+73/-163)
To merge this branch: bzr merge lp:~camptocamp/anybox.buildbot.openerp/trunk-fix_1283084-afe
Reviewer Review Type Date Requested Status
Leonardo Pistone (community) Needs Information
Anybox Pending
Review via email: mp+207667@code.launchpad.net

Description of the change

update buildouts/bootstrap.py

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks Alexandre.

For the record, where exactly did you get the new file from?

review: Needs Information
Revision history for this message
Georges Racinet (gracinet) wrote :

Thanks for the contribution.

Did you run it with exactly the MANIFEST.cfg and the standalone buildouts from that same directory ?
As far as I remember, those actually need the old v1-style bootstrap.

For the record, I'd be glad to clean all this up, and maybe (after a clean release ?) go as far as to make the most up-to-date options for bootstrap (v 2.2.1+virtualenv) the default (makes sense now, I have to tell everyone about them all the time)

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

> Thanks for the contribution.
>
> Did you run it with exactly the MANIFEST.cfg and the standalone buildouts from
> that same directory ?
> As far as I remember, those actually need the old v1-style bootstrap.
>
> For the record, I'd be glad to clean all this up, and maybe (after a clean
> release ?) go as far as to make the most up-to-date options for bootstrap (v
> 2.2.1+virtualenv) the default (makes sense now, I have to tell everyone about
> them all the time)

Honnestly, I don't remember what I exactly did. I've been having issues with the buildbot passing options to the the slaves that were not supported by the bootstrap.py it had installed, and updating bootstrap.py in the master did fix the issue.

Unmerged revisions

299. By Alexandre Fayolle - camptocamp

[FIX] buildouts/bootstrap.py : updated bootstrap.py to the latest version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'buildouts/bootstrap.py'
--- buildouts/bootstrap.py 2012-04-21 19:57:13 +0000
+++ buildouts/bootstrap.py 2014-02-21 15:02:50 +0000
@@ -18,74 +18,14 @@
18use the -c option to specify an alternate configuration file.18use the -c option to specify an alternate configuration file.
19"""19"""
2020
21import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess21import os
22import shutil
23import sys
24import tempfile
25
22from optparse import OptionParser26from optparse import OptionParser
2327
24if sys.platform == 'win32':28tmpeggs = tempfile.mkdtemp()
25 def quote(c):
26 if ' ' in c:
27 return '"%s"' % c # work around spawn lamosity on windows
28 else:
29 return c
30else:
31 quote = str
32
33# See zc.buildout.easy_install._has_broken_dash_S for motivation and comments.
34stdout, stderr = subprocess.Popen(
35 [sys.executable, '-Sc',
36 'try:\n'
37 ' import ConfigParser\n'
38 'except ImportError:\n'
39 ' print 1\n'
40 'else:\n'
41 ' print 0\n'],
42 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
43has_broken_dash_S = bool(int(stdout.strip()))
44
45# In order to be more robust in the face of system Pythons, we want to
46# run without site-packages loaded. This is somewhat tricky, in
47# particular because Python 2.6's distutils imports site, so starting
48# with the -S flag is not sufficient. However, we'll start with that:
49if not has_broken_dash_S and 'site' in sys.modules:
50 # We will restart with python -S.
51 args = sys.argv[:]
52 args[0:0] = [sys.executable, '-S']
53 args = map(quote, args)
54 os.execv(sys.executable, args)
55# Now we are running with -S. We'll get the clean sys.path, import site
56# because distutils will do it later, and then reset the path and clean
57# out any namespace packages from site-packages that might have been
58# loaded by .pth files.
59clean_path = sys.path[:]
60import site
61sys.path[:] = clean_path
62for k, v in sys.modules.items():
63 if k in ('setuptools', 'pkg_resources') or (
64 hasattr(v, '__path__') and
65 len(v.__path__)==1 and
66 not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))):
67 # This is a namespace package. Remove it.
68 sys.modules.pop(k)
69
70is_jython = sys.platform.startswith('java')
71
72setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py'
73distribute_source = 'http://python-distribute.org/distribute_setup.py'
74
75# parsing arguments
76def normalize_to_url(option, opt_str, value, parser):
77 if value:
78 if '://' not in value: # It doesn't smell like a URL.
79 value = 'file://%s' % (
80 urllib.pathname2url(
81 os.path.abspath(os.path.expanduser(value))),)
82 if opt_str == '--download-base' and not value.endswith('/'):
83 # Download base needs a trailing slash to make the world happy.
84 value += '/'
85 else:
86 value = None
87 name = opt_str[2:].replace('-', '_')
88 setattr(parser.values, name, value)
8929
90usage = '''\30usage = '''\
91[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]31[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
@@ -95,31 +35,13 @@
95Simply run this script in a directory containing a buildout.cfg, using the35Simply run this script in a directory containing a buildout.cfg, using the
96Python that you want bin/buildout to use.36Python that you want bin/buildout to use.
9737
98Note that by using --setup-source and --download-base to point to38Note that by using --find-links to point to local resources, you can keep
99local resources, you can keep this script from going over the network.39this script from going over the network.
100'''40'''
10141
102parser = OptionParser(usage=usage)42parser = OptionParser(usage=usage)
103parser.add_option("-v", "--version", dest="version",43parser.add_option("-v", "--version", help="use a specific zc.buildout version")
104 help="use a specific zc.buildout version")44
105parser.add_option("-d", "--distribute",
106 action="store_true", dest="use_distribute", default=True,
107 help="Use Distribute rather than Setuptools.")
108parser.add_option("--setup-source", action="callback", dest="setup_source",
109 callback=normalize_to_url, nargs=1, type="string",
110 help=("Specify a URL or file location for the setup file. "
111 "If you use Setuptools, this will default to " +
112 setuptools_source + "; if you use Distribute, this "
113 "will default to " + distribute_source +"."))
114parser.add_option("--download-base", action="callback", dest="download_base",
115 callback=normalize_to_url, nargs=1, type="string",
116 help=("Specify a URL or directory for downloading "
117 "zc.buildout and either Setuptools or Distribute. "
118 "Defaults to PyPI."))
119parser.add_option("--eggs",
120 help=("Specify a directory for storing eggs. Defaults to "
121 "a temporary directory that is deleted when the "
122 "bootstrap script completes."))
123parser.add_option("-t", "--accept-buildout-test-releases",45parser.add_option("-t", "--accept-buildout-test-releases",
124 dest='accept_buildout_test_releases',46 dest='accept_buildout_test_releases',
125 action="store_true", default=False,47 action="store_true", default=False,
@@ -129,49 +51,38 @@
129 "extensions for you. If you use this flag, "51 "extensions for you. If you use this flag, "
130 "bootstrap and buildout will get the newest releases "52 "bootstrap and buildout will get the newest releases "
131 "even if they are alphas or betas."))53 "even if they are alphas or betas."))
132parser.add_option("-c", None, action="store", dest="config_file",54parser.add_option("-c", "--config-file",
133 help=("Specify the path to the buildout configuration "55 help=("Specify the path to the buildout configuration "
134 "file to be used."))56 "file to be used."))
57parser.add_option("-f", "--find-links",
58 help=("Specify a URL to search for buildout releases"))
59
13560
136options, args = parser.parse_args()61options, args = parser.parse_args()
13762
138# if -c was provided, we push it back into args for buildout's main function63######################################################################
139if options.config_file is not None:64# load/install setuptools
140 args += ['-c', options.config_file]65
14166to_reload = False
142if options.eggs:
143 eggs_dir = os.path.abspath(os.path.expanduser(options.eggs))
144else:
145 eggs_dir = tempfile.mkdtemp()
146
147if options.setup_source is None:
148 if options.use_distribute:
149 options.setup_source = distribute_source
150 else:
151 options.setup_source = setuptools_source
152
153if options.accept_buildout_test_releases:
154 args.append('buildout:accept-buildout-test-releases=true')
155args.append('bootstrap')
156
157try:67try:
158 import pkg_resources68 import pkg_resources
159 import setuptools # A flag. Sometimes pkg_resources is installed alone.69 import setuptools
160 if not hasattr(pkg_resources, '_distribute'):
161 raise ImportError
162except ImportError:70except ImportError:
163 ez_code = urllib2.urlopen(
164 options.setup_source).read().replace('\r\n', '\n')
165 ez = {}71 ez = {}
166 exec ez_code in ez72
167 setup_args = dict(to_dir=eggs_dir, download_delay=0)73 try:
168 if options.download_base:74 from urllib.request import urlopen
169 setup_args['download_base'] = options.download_base75 except ImportError:
170 if options.use_distribute:76 from urllib2 import urlopen
171 setup_args['no_fake'] = True77
78 # XXX use a more permanent ez_setup.py URL when available.
79 exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
80 ).read(), ez)
81 setup_args = dict(to_dir=tmpeggs, download_delay=0)
172 ez['use_setuptools'](**setup_args)82 ez['use_setuptools'](**setup_args)
173 if 'pkg_resources' in sys.modules:83
174 reload(sys.modules['pkg_resources'])84 if to_reload:
85 reload(pkg_resources)
175 import pkg_resources86 import pkg_resources
176 # This does not (always?) update the default working set. We will87 # This does not (always?) update the default working set. We will
177 # do it.88 # do it.
@@ -179,31 +90,26 @@
179 if path not in pkg_resources.working_set.entries:90 if path not in pkg_resources.working_set.entries:
180 pkg_resources.working_set.add_entry(path)91 pkg_resources.working_set.add_entry(path)
18192
182cmd = [quote(sys.executable),93######################################################################
183 '-c',94# Install buildout
184 quote('from setuptools.command.easy_install import main; main()'),95
185 '-mqNxd',96ws = pkg_resources.working_set
186 quote(eggs_dir)]97
18798cmd = [sys.executable, '-c',
188if not has_broken_dash_S:99 'from setuptools.command.easy_install import main; main()',
189 cmd.insert(1, '-S')100 '-mZqNxd', tmpeggs]
190101
191find_links = options.download_base102find_links = os.environ.get(
192if not find_links:103 'bootstrap-testing-find-links',
193 find_links = os.environ.get('bootstrap-testing-find-links')104 options.find_links or
105 ('http://downloads.buildout.org/'
106 if options.accept_buildout_test_releases else None)
107 )
194if find_links:108if find_links:
195 cmd.extend(['-f', quote(find_links)])109 cmd.extend(['-f', find_links])
196110
197if options.use_distribute:111setuptools_path = ws.find(
198 setup_requirement = 'distribute'112 pkg_resources.Requirement.parse('setuptools')).location
199else:
200 setup_requirement = 'setuptools'
201ws = pkg_resources.working_set
202setup_requirement_path = ws.find(
203 pkg_resources.Requirement.parse(setup_requirement)).location
204env = dict(
205 os.environ,
206 PYTHONPATH=setup_requirement_path)
207113
208requirement = 'zc.buildout'114requirement = 'zc.buildout'
209version = options.version115version = options.version
@@ -211,13 +117,14 @@
211 # Figure out the most recent final version of zc.buildout.117 # Figure out the most recent final version of zc.buildout.
212 import setuptools.package_index118 import setuptools.package_index
213 _final_parts = '*final-', '*final'119 _final_parts = '*final-', '*final'
120
214 def _final_version(parsed_version):121 def _final_version(parsed_version):
215 for part in parsed_version:122 for part in parsed_version:
216 if (part[:1] == '*') and (part not in _final_parts):123 if (part[:1] == '*') and (part not in _final_parts):
217 return False124 return False
218 return True125 return True
219 index = setuptools.package_index.PackageIndex(126 index = setuptools.package_index.PackageIndex(
220 search_path=[setup_requirement_path])127 search_path=[setuptools_path])
221 if find_links:128 if find_links:
222 index.add_find_links((find_links,))129 index.add_find_links((find_links,))
223 req = pkg_resources.Requirement.parse(requirement)130 req = pkg_resources.Requirement.parse(requirement)
@@ -239,22 +146,25 @@
239 requirement = '=='.join((requirement, version))146 requirement = '=='.join((requirement, version))
240cmd.append(requirement)147cmd.append(requirement)
241148
242if is_jython:149import subprocess
243 import subprocess150if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
244 exitcode = subprocess.Popen(cmd, env=env).wait()151 raise Exception(
245else: # Windows prefers this, apparently; otherwise we would prefer subprocess152 "Failed to execute command:\n%s",
246 exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))153 repr(cmd)[1:-1])
247if exitcode != 0:154
248 sys.stdout.flush()155######################################################################
249 sys.stderr.flush()156# Import and run buildout
250 print ("An error occurred when trying to install zc.buildout. "157
251 "Look above this message for any errors that "158ws.add_entry(tmpeggs)
252 "were output by easy_install.")
253 sys.exit(exitcode)
254
255ws.add_entry(eggs_dir)
256ws.require(requirement)159ws.require(requirement)
257import zc.buildout.buildout160import zc.buildout.buildout
161
162if not [a for a in args if '=' not in a]:
163 args.append('bootstrap')
164
165# if -c was provided, we push it back into args for buildout' main function
166if options.config_file is not None:
167 args[0:0] = ['-c', options.config_file]
168
258zc.buildout.buildout.main(args)169zc.buildout.buildout.main(args)
259if not options.eggs: # clean up temporary egg directory170shutil.rmtree(tmpeggs)
260 shutil.rmtree(eggs_dir)

Subscribers

People subscribed via source and target branches

to all changes: