Merge lp:~camptocamp/anybox.buildbot.openerp/trunk-fix_1283084-afe into lp:anybox.buildbot.openerp
- trunk-fix_1283084-afe
- Merge into first
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Leonardo Pistone (community) | Needs Information | ||
Anybox | Pending | ||
Review via email: mp+207667@code.launchpad.net |
Commit message
Description of the change
update buildouts/
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)
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
1 | === modified file 'buildouts/bootstrap.py' | |||
2 | --- buildouts/bootstrap.py 2012-04-21 19:57:13 +0000 | |||
3 | +++ buildouts/bootstrap.py 2014-02-21 15:02:50 +0000 | |||
4 | @@ -18,74 +18,14 @@ | |||
5 | 18 | use the -c option to specify an alternate configuration file. | 18 | use the -c option to specify an alternate configuration file. |
6 | 19 | """ | 19 | """ |
7 | 20 | 20 | ||
9 | 21 | import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess | 21 | import os |
10 | 22 | import shutil | ||
11 | 23 | import sys | ||
12 | 24 | import tempfile | ||
13 | 25 | |||
14 | 22 | from optparse import OptionParser | 26 | from optparse import OptionParser |
15 | 23 | 27 | ||
81 | 24 | if sys.platform == 'win32': | 28 | tmpeggs = tempfile.mkdtemp() |
17 | 25 | def quote(c): | ||
18 | 26 | if ' ' in c: | ||
19 | 27 | return '"%s"' % c # work around spawn lamosity on windows | ||
20 | 28 | else: | ||
21 | 29 | return c | ||
22 | 30 | else: | ||
23 | 31 | quote = str | ||
24 | 32 | |||
25 | 33 | # See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. | ||
26 | 34 | stdout, stderr = subprocess.Popen( | ||
27 | 35 | [sys.executable, '-Sc', | ||
28 | 36 | 'try:\n' | ||
29 | 37 | ' import ConfigParser\n' | ||
30 | 38 | 'except ImportError:\n' | ||
31 | 39 | ' print 1\n' | ||
32 | 40 | 'else:\n' | ||
33 | 41 | ' print 0\n'], | ||
34 | 42 | stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() | ||
35 | 43 | has_broken_dash_S = bool(int(stdout.strip())) | ||
36 | 44 | |||
37 | 45 | # In order to be more robust in the face of system Pythons, we want to | ||
38 | 46 | # run without site-packages loaded. This is somewhat tricky, in | ||
39 | 47 | # particular because Python 2.6's distutils imports site, so starting | ||
40 | 48 | # with the -S flag is not sufficient. However, we'll start with that: | ||
41 | 49 | if not has_broken_dash_S and 'site' in sys.modules: | ||
42 | 50 | # We will restart with python -S. | ||
43 | 51 | args = sys.argv[:] | ||
44 | 52 | args[0:0] = [sys.executable, '-S'] | ||
45 | 53 | args = map(quote, args) | ||
46 | 54 | os.execv(sys.executable, args) | ||
47 | 55 | # Now we are running with -S. We'll get the clean sys.path, import site | ||
48 | 56 | # because distutils will do it later, and then reset the path and clean | ||
49 | 57 | # out any namespace packages from site-packages that might have been | ||
50 | 58 | # loaded by .pth files. | ||
51 | 59 | clean_path = sys.path[:] | ||
52 | 60 | import site | ||
53 | 61 | sys.path[:] = clean_path | ||
54 | 62 | for k, v in sys.modules.items(): | ||
55 | 63 | if k in ('setuptools', 'pkg_resources') or ( | ||
56 | 64 | hasattr(v, '__path__') and | ||
57 | 65 | len(v.__path__)==1 and | ||
58 | 66 | not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))): | ||
59 | 67 | # This is a namespace package. Remove it. | ||
60 | 68 | sys.modules.pop(k) | ||
61 | 69 | |||
62 | 70 | is_jython = sys.platform.startswith('java') | ||
63 | 71 | |||
64 | 72 | setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' | ||
65 | 73 | distribute_source = 'http://python-distribute.org/distribute_setup.py' | ||
66 | 74 | |||
67 | 75 | # parsing arguments | ||
68 | 76 | def normalize_to_url(option, opt_str, value, parser): | ||
69 | 77 | if value: | ||
70 | 78 | if '://' not in value: # It doesn't smell like a URL. | ||
71 | 79 | value = 'file://%s' % ( | ||
72 | 80 | urllib.pathname2url( | ||
73 | 81 | os.path.abspath(os.path.expanduser(value))),) | ||
74 | 82 | if opt_str == '--download-base' and not value.endswith('/'): | ||
75 | 83 | # Download base needs a trailing slash to make the world happy. | ||
76 | 84 | value += '/' | ||
77 | 85 | else: | ||
78 | 86 | value = None | ||
79 | 87 | name = opt_str[2:].replace('-', '_') | ||
80 | 88 | setattr(parser.values, name, value) | ||
82 | 89 | 29 | ||
83 | 90 | usage = '''\ | 30 | usage = '''\ |
84 | 91 | [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] | 31 | [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] |
85 | @@ -95,31 +35,13 @@ | |||
86 | 95 | Simply run this script in a directory containing a buildout.cfg, using the | 35 | Simply run this script in a directory containing a buildout.cfg, using the |
87 | 96 | Python that you want bin/buildout to use. | 36 | Python that you want bin/buildout to use. |
88 | 97 | 37 | ||
91 | 98 | Note that by using --setup-source and --download-base to point to | 38 | Note that by using --find-links to point to local resources, you can keep |
92 | 99 | local resources, you can keep this script from going over the network. | 39 | this script from going over the network. |
93 | 100 | ''' | 40 | ''' |
94 | 101 | 41 | ||
95 | 102 | parser = OptionParser(usage=usage) | 42 | parser = OptionParser(usage=usage) |
116 | 103 | parser.add_option("-v", "--version", dest="version", | 43 | parser.add_option("-v", "--version", help="use a specific zc.buildout version") |
117 | 104 | help="use a specific zc.buildout version") | 44 | |
98 | 105 | parser.add_option("-d", "--distribute", | ||
99 | 106 | action="store_true", dest="use_distribute", default=True, | ||
100 | 107 | help="Use Distribute rather than Setuptools.") | ||
101 | 108 | parser.add_option("--setup-source", action="callback", dest="setup_source", | ||
102 | 109 | callback=normalize_to_url, nargs=1, type="string", | ||
103 | 110 | help=("Specify a URL or file location for the setup file. " | ||
104 | 111 | "If you use Setuptools, this will default to " + | ||
105 | 112 | setuptools_source + "; if you use Distribute, this " | ||
106 | 113 | "will default to " + distribute_source +".")) | ||
107 | 114 | parser.add_option("--download-base", action="callback", dest="download_base", | ||
108 | 115 | callback=normalize_to_url, nargs=1, type="string", | ||
109 | 116 | help=("Specify a URL or directory for downloading " | ||
110 | 117 | "zc.buildout and either Setuptools or Distribute. " | ||
111 | 118 | "Defaults to PyPI.")) | ||
112 | 119 | parser.add_option("--eggs", | ||
113 | 120 | help=("Specify a directory for storing eggs. Defaults to " | ||
114 | 121 | "a temporary directory that is deleted when the " | ||
115 | 122 | "bootstrap script completes.")) | ||
118 | 123 | parser.add_option("-t", "--accept-buildout-test-releases", | 45 | parser.add_option("-t", "--accept-buildout-test-releases", |
119 | 124 | dest='accept_buildout_test_releases', | 46 | dest='accept_buildout_test_releases', |
120 | 125 | action="store_true", default=False, | 47 | action="store_true", default=False, |
121 | @@ -129,49 +51,38 @@ | |||
122 | 129 | "extensions for you. If you use this flag, " | 51 | "extensions for you. If you use this flag, " |
123 | 130 | "bootstrap and buildout will get the newest releases " | 52 | "bootstrap and buildout will get the newest releases " |
124 | 131 | "even if they are alphas or betas.")) | 53 | "even if they are alphas or betas.")) |
128 | 132 | parser.add_option("-c", None, action="store", dest="config_file", | 54 | parser.add_option("-c", "--config-file", |
129 | 133 | help=("Specify the path to the buildout configuration " | 55 | help=("Specify the path to the buildout configuration " |
130 | 134 | "file to be used.")) | 56 | "file to be used.")) |
131 | 57 | parser.add_option("-f", "--find-links", | ||
132 | 58 | help=("Specify a URL to search for buildout releases")) | ||
133 | 59 | |||
134 | 135 | 60 | ||
135 | 136 | options, args = parser.parse_args() | 61 | options, args = parser.parse_args() |
136 | 137 | 62 | ||
156 | 138 | # if -c was provided, we push it back into args for buildout's main function | 63 | ###################################################################### |
157 | 139 | if options.config_file is not None: | 64 | # load/install setuptools |
158 | 140 | args += ['-c', options.config_file] | 65 | |
159 | 141 | 66 | to_reload = False | |
141 | 142 | if options.eggs: | ||
142 | 143 | eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) | ||
143 | 144 | else: | ||
144 | 145 | eggs_dir = tempfile.mkdtemp() | ||
145 | 146 | |||
146 | 147 | if options.setup_source is None: | ||
147 | 148 | if options.use_distribute: | ||
148 | 149 | options.setup_source = distribute_source | ||
149 | 150 | else: | ||
150 | 151 | options.setup_source = setuptools_source | ||
151 | 152 | |||
152 | 153 | if options.accept_buildout_test_releases: | ||
153 | 154 | args.append('buildout:accept-buildout-test-releases=true') | ||
154 | 155 | args.append('bootstrap') | ||
155 | 156 | |||
160 | 157 | try: | 67 | try: |
161 | 158 | import pkg_resources | 68 | import pkg_resources |
165 | 159 | import setuptools # A flag. Sometimes pkg_resources is installed alone. | 69 | import setuptools |
163 | 160 | if not hasattr(pkg_resources, '_distribute'): | ||
164 | 161 | raise ImportError | ||
166 | 162 | except ImportError: | 70 | except ImportError: |
167 | 163 | ez_code = urllib2.urlopen( | ||
168 | 164 | options.setup_source).read().replace('\r\n', '\n') | ||
169 | 165 | ez = {} | 71 | ez = {} |
176 | 166 | exec ez_code in ez | 72 | |
177 | 167 | setup_args = dict(to_dir=eggs_dir, download_delay=0) | 73 | try: |
178 | 168 | if options.download_base: | 74 | from urllib.request import urlopen |
179 | 169 | setup_args['download_base'] = options.download_base | 75 | except ImportError: |
180 | 170 | if options.use_distribute: | 76 | from urllib2 import urlopen |
181 | 171 | setup_args['no_fake'] = True | 77 | |
182 | 78 | # XXX use a more permanent ez_setup.py URL when available. | ||
183 | 79 | exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py' | ||
184 | 80 | ).read(), ez) | ||
185 | 81 | setup_args = dict(to_dir=tmpeggs, download_delay=0) | ||
186 | 172 | ez['use_setuptools'](**setup_args) | 82 | ez['use_setuptools'](**setup_args) |
189 | 173 | if 'pkg_resources' in sys.modules: | 83 | |
190 | 174 | reload(sys.modules['pkg_resources']) | 84 | if to_reload: |
191 | 85 | reload(pkg_resources) | ||
192 | 175 | import pkg_resources | 86 | import pkg_resources |
193 | 176 | # This does not (always?) update the default working set. We will | 87 | # This does not (always?) update the default working set. We will |
194 | 177 | # do it. | 88 | # do it. |
195 | @@ -179,31 +90,26 @@ | |||
196 | 179 | if path not in pkg_resources.working_set.entries: | 90 | if path not in pkg_resources.working_set.entries: |
197 | 180 | pkg_resources.working_set.add_entry(path) | 91 | pkg_resources.working_set.add_entry(path) |
198 | 181 | 92 | ||
211 | 182 | cmd = [quote(sys.executable), | 93 | ###################################################################### |
212 | 183 | '-c', | 94 | # Install buildout |
213 | 184 | quote('from setuptools.command.easy_install import main; main()'), | 95 | |
214 | 185 | '-mqNxd', | 96 | ws = pkg_resources.working_set |
215 | 186 | quote(eggs_dir)] | 97 | |
216 | 187 | 98 | cmd = [sys.executable, '-c', | |
217 | 188 | if not has_broken_dash_S: | 99 | 'from setuptools.command.easy_install import main; main()', |
218 | 189 | cmd.insert(1, '-S') | 100 | '-mZqNxd', tmpeggs] |
219 | 190 | 101 | ||
220 | 191 | find_links = options.download_base | 102 | find_links = os.environ.get( |
221 | 192 | if not find_links: | 103 | 'bootstrap-testing-find-links', |
222 | 193 | find_links = os.environ.get('bootstrap-testing-find-links') | 104 | options.find_links or |
223 | 105 | ('http://downloads.buildout.org/' | ||
224 | 106 | if options.accept_buildout_test_releases else None) | ||
225 | 107 | ) | ||
226 | 194 | if find_links: | 108 | if find_links: |
228 | 195 | cmd.extend(['-f', quote(find_links)]) | 109 | cmd.extend(['-f', find_links]) |
229 | 196 | 110 | ||
240 | 197 | if options.use_distribute: | 111 | setuptools_path = ws.find( |
241 | 198 | setup_requirement = 'distribute' | 112 | pkg_resources.Requirement.parse('setuptools')).location |
232 | 199 | else: | ||
233 | 200 | setup_requirement = 'setuptools' | ||
234 | 201 | ws = pkg_resources.working_set | ||
235 | 202 | setup_requirement_path = ws.find( | ||
236 | 203 | pkg_resources.Requirement.parse(setup_requirement)).location | ||
237 | 204 | env = dict( | ||
238 | 205 | os.environ, | ||
239 | 206 | PYTHONPATH=setup_requirement_path) | ||
242 | 207 | 113 | ||
243 | 208 | requirement = 'zc.buildout' | 114 | requirement = 'zc.buildout' |
244 | 209 | version = options.version | 115 | version = options.version |
245 | @@ -211,13 +117,14 @@ | |||
246 | 211 | # Figure out the most recent final version of zc.buildout. | 117 | # Figure out the most recent final version of zc.buildout. |
247 | 212 | import setuptools.package_index | 118 | import setuptools.package_index |
248 | 213 | _final_parts = '*final-', '*final' | 119 | _final_parts = '*final-', '*final' |
249 | 120 | |||
250 | 214 | def _final_version(parsed_version): | 121 | def _final_version(parsed_version): |
251 | 215 | for part in parsed_version: | 122 | for part in parsed_version: |
252 | 216 | if (part[:1] == '*') and (part not in _final_parts): | 123 | if (part[:1] == '*') and (part not in _final_parts): |
253 | 217 | return False | 124 | return False |
254 | 218 | return True | 125 | return True |
255 | 219 | index = setuptools.package_index.PackageIndex( | 126 | index = setuptools.package_index.PackageIndex( |
257 | 220 | search_path=[setup_requirement_path]) | 127 | search_path=[setuptools_path]) |
258 | 221 | if find_links: | 128 | if find_links: |
259 | 222 | index.add_find_links((find_links,)) | 129 | index.add_find_links((find_links,)) |
260 | 223 | req = pkg_resources.Requirement.parse(requirement) | 130 | req = pkg_resources.Requirement.parse(requirement) |
261 | @@ -239,22 +146,25 @@ | |||
262 | 239 | requirement = '=='.join((requirement, version)) | 146 | requirement = '=='.join((requirement, version)) |
263 | 240 | cmd.append(requirement) | 147 | cmd.append(requirement) |
264 | 241 | 148 | ||
279 | 242 | if is_jython: | 149 | import subprocess |
280 | 243 | import subprocess | 150 | if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: |
281 | 244 | exitcode = subprocess.Popen(cmd, env=env).wait() | 151 | raise Exception( |
282 | 245 | else: # Windows prefers this, apparently; otherwise we would prefer subprocess | 152 | "Failed to execute command:\n%s", |
283 | 246 | exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) | 153 | repr(cmd)[1:-1]) |
284 | 247 | if exitcode != 0: | 154 | |
285 | 248 | sys.stdout.flush() | 155 | ###################################################################### |
286 | 249 | sys.stderr.flush() | 156 | # Import and run buildout |
287 | 250 | print ("An error occurred when trying to install zc.buildout. " | 157 | |
288 | 251 | "Look above this message for any errors that " | 158 | ws.add_entry(tmpeggs) |
275 | 252 | "were output by easy_install.") | ||
276 | 253 | sys.exit(exitcode) | ||
277 | 254 | |||
278 | 255 | ws.add_entry(eggs_dir) | ||
289 | 256 | ws.require(requirement) | 159 | ws.require(requirement) |
290 | 257 | import zc.buildout.buildout | 160 | import zc.buildout.buildout |
291 | 161 | |||
292 | 162 | if not [a for a in args if '=' not in a]: | ||
293 | 163 | args.append('bootstrap') | ||
294 | 164 | |||
295 | 165 | # if -c was provided, we push it back into args for buildout' main function | ||
296 | 166 | if options.config_file is not None: | ||
297 | 167 | args[0:0] = ['-c', options.config_file] | ||
298 | 168 | |||
299 | 258 | zc.buildout.buildout.main(args) | 169 | zc.buildout.buildout.main(args) |
302 | 259 | if not options.eggs: # clean up temporary egg directory | 170 | shutil.rmtree(tmpeggs) |
301 | 260 | shutil.rmtree(eggs_dir) |
Thanks Alexandre.
For the record, where exactly did you get the new file from?