Commit 46b8343b authored by Julien Muchembled's avatar Julien Muchembled

Revert "Updated to work with the latest setuptools." partially

One big issue in commit e129e187 is that the
initial value of buildout_and_setuptools_path can cause buildout to use a lot
of CPU at startup. The following change would help:

    def buildout_and_setuptools_path():
        r = [get_python_lib(standard_lib=1)]
        for d in pkg_resources.working_set:
            d = d.location
            if d not in r:
                r.append(d)
        return r[1:]
    buildout_and_setuptools_path = buildout_and_setuptools_path()

but initializing buildout_and_setuptools_dists also takes time to compute,
and it's only used for bootstrap.

Because the commit is not required anymore since setuptools 36, it's easier
for us to revert partially, so we can keep applying our patches.
parent 72267758
......@@ -439,10 +439,12 @@ class Buildout(DictMixin):
# Now copy buildout and setuptools eggs, and record destination eggs:
entries = []
for dist in zc.buildout.easy_install.buildout_and_setuptools_dists:
for name in 'zc.buildout', 'setuptools':
r = pkg_resources.Requirement.parse(name)
dist = pkg_resources.working_set.find(r)
if dist.precedence == pkg_resources.DEVELOP_DIST:
dest = os.path.join(self['buildout']['develop-eggs-directory'],
dist.key + '.egg-link')
name+'.egg-link')
open(dest, 'w').write(dist.location)
entries.append(dist.location)
else:
......@@ -1093,6 +1095,7 @@ class Buildout(DictMixin):
fd, tsetup = tempfile.mkstemp()
try:
os.write(fd, (zc.buildout.easy_install.runsetup_template % dict(
setuptools=zc.buildout.easy_install.setuptools_pythonpath,
setupdir=os.path.dirname(setup),
setup=setup,
__file__ = setup,
......
......@@ -74,11 +74,16 @@ if has_distribute and not has_setuptools:
" you have the latest version downloaded from"
" https://bootstrap.pypa.io/bootstrap-buildout.py")
# Include buildout and setuptools eggs in paths. We get this
# initially from the entire working set. Later, we'll use the install
# function to narrow to just the buildout and setuptools paths.
buildout_and_setuptools_path = [d.location for d in pkg_resources.working_set]
setuptools_path = buildout_and_setuptools_path
setuptools_pythonpath = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('setuptools')
).location
# Include buildout and setuptools eggs in paths
buildout_and_setuptools_path = [
pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.buildout')).location,
setuptools_pythonpath,
]
FILE_SCHEME = re.compile('file://', re.I).match
DUNDER_FILE_PATTERN = re.compile(r"__file__ = '(?P<filename>.+)'$")
......@@ -336,10 +341,10 @@ class Installer:
tmp = tempfile.mkdtemp(dir=dest)
try:
path = setuptools_path
path = setuptools_pythonpath
args = [sys.executable, '-c',
('import sys; sys.path[0:0] = %r; ' % path) +
('import sys; sys.path[0:0] = [%r]; ' % path) +
_easy_install_cmd, '-mZUNxd', tmp]
level = logger.getEffectiveLevel()
if level > 0:
......@@ -892,13 +897,6 @@ def install(specs, dest,
check_picked=check_picked)
return installer.install(specs, working_set)
buildout_and_setuptools_dists = list(install(['zc.buildout'], None,
check_picked=False))
buildout_and_setuptools_path = [d.location
for d in buildout_and_setuptools_dists]
setuptools_path = [d.location
for d in install(['setuptools'], None, check_picked=False)]
setuptools_pythonpath = os.pathsep.join(setuptools_path)
def build(spec, dest, build_ext,
links=(), index=None,
......@@ -1014,6 +1012,7 @@ def develop(setup, dest,
undo.append(lambda: os.close(fd))
os.write(fd, (runsetup_template % dict(
setuptools=setuptools_pythonpath,
setupdir=directory,
setup=setup,
__file__ = setup,
......@@ -1437,19 +1436,18 @@ if _interactive:
runsetup_template = """
import sys
sys.path.insert(0, %%(setupdir)r)
sys.path[0:0] = %r
sys.path[:0] = %(setuptools)r, %(setupdir)r
import os, setuptools
__file__ = %%(__file__)r
__file__ = %(__file__)r
os.chdir(%%(setupdir)r)
sys.argv[0] = %%(setup)r
os.chdir(%(setupdir)r)
sys.argv[0] = %(setup)r
with open(%%(setup)r, 'U') as f:
exec(compile(f.read(), %%(setup)r, 'exec'))
""" % setuptools_path
with open(%(setup)r, 'U') as f:
exec(compile(f.read(), %(setup)r, 'exec'))
"""
class VersionConflict(zc.buildout.UserError):
......
......@@ -34,6 +34,14 @@ os_path_sep = os.path.sep
if os_path_sep == '\\':
os_path_sep *= 2
def buildout_and_setuptools_dists():
# lazy or the index cache would be filled using wrong default_index_url
global buildout_and_setuptools_dists
x = list(zc.buildout.easy_install.install(
['zc.buildout'], None, check_picked=False))
buildout_and_setuptools_dists = lambda: x
return x
def develop_w_non_setuptools_setup_scripts():
"""
......@@ -2501,7 +2509,7 @@ honoring our version specification.
... eggs = foo
... ''' % ('\n'.join(
... '%s = %s' % (d.key, d.version)
... for d in zc.buildout.easy_install.buildout_and_setuptools_dists)))
... for d in buildout_and_setuptools_dists())))
>>> print_(system(buildout), end='')
Installing foo.
......@@ -3363,7 +3371,7 @@ def updateSetup(test):
test.globs['new_releases'] = new_releases
ws = getWorkingSetWithBuildoutEgg(test)
# now let's make the new releases
for dist in zc.buildout.easy_install.buildout_and_setuptools_dists:
for dist in buildout_and_setuptools_dists():
makeNewRelease(dist.key, ws, new_releases)
os.mkdir(os.path.join(new_releases, dist.key))
......
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