annotate bootstrap.py @ 260:0ac15efd8c17 default tip

Drop obsolete parameter to bootstrap.py in README.txt
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 29 Sep 2014 15:49:42 +0200
parents 773d9567dcb2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
1 ##############################################################################
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
2 #
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
3 # Copyright (c) 2006 Zope Foundation and Contributors.
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
4 # All Rights Reserved.
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
5 #
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
6 # This software is subject to the provisions of the Zope Public License,
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
7 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
8 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
9 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
10 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
11 # FOR A PARTICULAR PURPOSE.
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
12 #
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
13 ##############################################################################
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
14 """Bootstrap a buildout-based project
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
15
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
16 Simply run this script in a directory containing a buildout.cfg.
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
17 The script accepts buildout command-line options, so you can
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
18 use the -c option to specify an alternate configuration file.
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
19 """
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
20
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
21 import os
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
22 import shutil
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
23 import sys
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
24 import tempfile
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
25
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
26 from optparse import OptionParser
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
27
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
28 tmpeggs = tempfile.mkdtemp()
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
29
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
30 usage = '''\
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
31 [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
32
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
33 Bootstraps a buildout-based project.
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
34
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
35 Simply run this script in a directory containing a buildout.cfg, using the
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
36 Python that you want bin/buildout to use.
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
37
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
38 Note that by using --find-links to point to local resources, you can keep
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
39 this script from going over the network.
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
40 '''
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
41
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
42 parser = OptionParser(usage=usage)
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
43 parser.add_option("-v", "--version", help="use a specific zc.buildout version")
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
44
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
45 parser.add_option("-t", "--accept-buildout-test-releases",
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
46 dest='accept_buildout_test_releases',
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
47 action="store_true", default=False,
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
48 help=("Normally, if you do not specify a --version, the "
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
49 "bootstrap script and buildout gets the newest "
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
50 "*final* versions of zc.buildout and its recipes and "
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
51 "extensions for you. If you use this flag, "
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
52 "bootstrap and buildout will get the newest releases "
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
53 "even if they are alphas or betas."))
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
54 parser.add_option("-c", "--config-file",
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
55 help=("Specify the path to the buildout configuration "
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
56 "file to be used."))
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
57 parser.add_option("-f", "--find-links",
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
58 help=("Specify a URL to search for buildout releases"))
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
59 parser.add_option("--allow-site-packages",
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
60 action="store_true", default=False,
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
61 help=("Let bootstrap.py use existing site packages"))
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
62
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
63
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
64 options, args = parser.parse_args()
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
65
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
66 ######################################################################
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
67 # load/install setuptools
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
68
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
69 try:
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
70 if options.allow_site_packages:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
71 import setuptools
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
72 import pkg_resources
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
73 from urllib.request import urlopen
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
74 except ImportError:
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
75 from urllib2 import urlopen
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
76
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
77 ez = {}
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
78 exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
79
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
80 if not options.allow_site_packages:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
81 # ez_setup imports site, which adds site packages
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
82 # this will remove them from the path to ensure that incompatible versions
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
83 # of setuptools are not in the path
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
84 import site
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
85 # inside a virtualenv, there is no 'getsitepackages'.
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
86 # We can't remove these reliably
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
87 if hasattr(site, 'getsitepackages'):
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
88 for sitepackage_path in site.getsitepackages():
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
89 sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
90
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
91 setup_args = dict(to_dir=tmpeggs, download_delay=0)
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
92 ez['use_setuptools'](**setup_args)
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
93 import setuptools
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
94 import pkg_resources
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
95
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
96 # This does not (always?) update the default working set. We will
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
97 # do it.
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
98 for path in sys.path:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
99 if path not in pkg_resources.working_set.entries:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
100 pkg_resources.working_set.add_entry(path)
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
101
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
102 ######################################################################
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
103 # Install buildout
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
104
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
105 ws = pkg_resources.working_set
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
106
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
107 cmd = [sys.executable, '-c',
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
108 'from setuptools.command.easy_install import main; main()',
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
109 '-mZqNxd', tmpeggs]
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
110
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
111 find_links = os.environ.get(
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
112 'bootstrap-testing-find-links',
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
113 options.find_links or
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
114 ('http://downloads.buildout.org/'
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
115 if options.accept_buildout_test_releases else None)
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
116 )
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
117 if find_links:
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
118 cmd.extend(['-f', find_links])
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
119
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
120 setuptools_path = ws.find(
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
121 pkg_resources.Requirement.parse('setuptools')).location
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
122
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
123 requirement = 'zc.buildout'
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
124 version = options.version
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
125 if version is None and not options.accept_buildout_test_releases:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
126 # Figure out the most recent final version of zc.buildout.
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
127 import setuptools.package_index
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
128 _final_parts = '*final-', '*final'
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
129
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
130 def _final_version(parsed_version):
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
131 for part in parsed_version:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
132 if (part[:1] == '*') and (part not in _final_parts):
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
133 return False
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
134 return True
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
135 index = setuptools.package_index.PackageIndex(
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
136 search_path=[setuptools_path])
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
137 if find_links:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
138 index.add_find_links((find_links,))
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
139 req = pkg_resources.Requirement.parse(requirement)
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
140 if index.obtain(req) is not None:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
141 best = []
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
142 bestv = None
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
143 for dist in index[req.project_name]:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
144 distv = dist.parsed_version
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
145 if _final_version(distv):
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
146 if bestv is None or distv > bestv:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
147 best = [dist]
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
148 bestv = distv
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
149 elif distv == bestv:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
150 best.append(dist)
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
151 if best:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
152 best.sort()
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
153 version = best[-1].version
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
154 if version:
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
155 requirement = '=='.join((requirement, version))
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
156 cmd.append(requirement)
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
157
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
158 import subprocess
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
159 if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
160 raise Exception(
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
161 "Failed to execute command:\n%s" % repr(cmd)[1:-1])
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
162
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
163 ######################################################################
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
164 # Import and run buildout
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
165
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
166 ws.add_entry(tmpeggs)
11
66101b35a8c0 Upgrade buildout bootstrap.py to latest version.
Daniele Nicolodi <daniele@grinta.net>
parents: 0
diff changeset
167 ws.require(requirement)
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
168 import zc.buildout.buildout
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
169
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
170 if not [a for a in args if '=' not in a]:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
171 args.append('bootstrap')
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
172
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
173 # if -c was provided, we push it back into args for buildout' main function
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
174 if options.config_file is not None:
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
175 args[0:0] = ['-c', options.config_file]
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
176
0
c812c3020b63 Initial import.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
177 zc.buildout.buildout.main(args)
258
773d9567dcb2 Update to current buildout.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 11
diff changeset
178 shutil.rmtree(tmpeggs)