Commit 03d1e80e authored by Xavier Thompson's avatar Xavier Thompson

[feat] Add scan_any_python_version option in install

This is passed when calling `install(['zc.buildout'])` to resolve the
dists of the currently running buildout and its dependencies, as they
may not actually correspond the version of the running interpreter.

This is needed to support new slapos.rebootstrap: after compiling the
new Python interpreter, we use it to run buildout bootstrap using the
same paths to zc.buildout and dependencies as in the initial Python.
This installs the needed dists for the new Python version and creates
a new bin/buildout for the new Python interpreter.
parent 3818d40d
...@@ -279,11 +279,13 @@ class Installer(object): ...@@ -279,11 +279,13 @@ class Installer(object):
allow_hosts=('*',), allow_hosts=('*',),
check_picked=True, check_picked=True,
allow_unknown_extras=False, allow_unknown_extras=False,
scan_any_python_version=False,
): ):
assert executable == sys.executable, (executable, sys.executable) assert executable == sys.executable, (executable, sys.executable)
self._dest = dest if dest is None else pkg_resources.normalize_path(dest) self._dest = dest if dest is None else pkg_resources.normalize_path(dest)
self._allow_hosts = allow_hosts self._allow_hosts = allow_hosts
self._allow_unknown_extras = allow_unknown_extras self._allow_unknown_extras = allow_unknown_extras
self._scan_any_python_version = scan_any_python_version
if self._install_from_cache: if self._install_from_cache:
if not self._download_cache: if not self._download_cache:
...@@ -316,6 +318,9 @@ class Installer(object): ...@@ -316,6 +318,9 @@ class Installer(object):
dest = self._dest dest = self._dest
full_path = [] if dest is None else [dest] full_path = [] if dest is None else [dest]
full_path.extend(self._path) full_path.extend(self._path)
if self._scan_any_python_version:
return pkg_resources.Environment(full_path, python=None)
else:
return pkg_resources.Environment(full_path) return pkg_resources.Environment(full_path)
def _env_rescan_dest(self): def _env_rescan_dest(self):
...@@ -1059,6 +1064,7 @@ def install(specs, dest, ...@@ -1059,6 +1064,7 @@ def install(specs, dest,
check_picked=True, check_picked=True,
allow_unknown_extras=False, allow_unknown_extras=False,
patch_dict=None, patch_dict=None,
scan_any_python_version=False,
): ):
assert executable == sys.executable, (executable, sys.executable) assert executable == sys.executable, (executable, sys.executable)
assert include_site_packages is None assert include_site_packages is None
...@@ -1069,11 +1075,13 @@ def install(specs, dest, ...@@ -1069,11 +1075,13 @@ def install(specs, dest,
newest, versions, use_dependency_links, newest, versions, use_dependency_links,
allow_hosts=allow_hosts, allow_hosts=allow_hosts,
check_picked=check_picked, check_picked=check_picked,
allow_unknown_extras=allow_unknown_extras) allow_unknown_extras=allow_unknown_extras,
scan_any_python_version=scan_any_python_version)
return installer.install(specs, working_set, patch_dict=patch_dict) return installer.install(specs, working_set, patch_dict=patch_dict)
buildout_and_setuptools_dists = list(install(['zc.buildout'], None, buildout_and_setuptools_dists = list(install(['zc.buildout'], None,
check_picked=False)) check_picked=False,
scan_any_python_version=True))
buildout_and_setuptools_path = sorted({d.location buildout_and_setuptools_path = sorted({d.location
for d in buildout_and_setuptools_dists}) for d in buildout_and_setuptools_dists})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment