Commit ef12d418 authored by Maurits van Rees's avatar Maurits van Rees

Only call redo_pyc when a dist has moved.

After a dist is fetched and put into its final place, compile its
python files.  No longer wait with compiling until all dists are in
place.

This avoids calling redo_pyc at the same time by two parallel buildouts.
It might not be so bad, but it seems better (and faster) to avoid it.

See discussion at https://github.com/buildout/buildout/issues/307
parent ae6206fe
Change History Change History
************** **************
2.5.3 (unreleased) 2.6.0 (unreleased)
================== ==================
- After a dist is fetched and put into its final place, compile its
python files. No longer wait with compiling until all dists are in
place. This is related to the change below about not removing an
existing egg. [maurits]
- Do not remove an existing egg. When installing an egg to a location - Do not remove an existing egg. When installing an egg to a location
that already exists, keep the current location (directory or file). that already exists, keep the current location (directory or file).
This can only happen when the location at first did not exist and This can only happen when the location at first did not exist and
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# #
############################################################################## ##############################################################################
name = "zc.buildout" name = "zc.buildout"
version = '2.5.3.dev0' version = '2.6.0.dev0'
import os import os
from setuptools import setup from setuptools import setup
......
...@@ -397,7 +397,7 @@ class Installer: ...@@ -397,7 +397,7 @@ class Installer:
result = [] result = []
for d in dists: for d in dists:
newloc = _move_to_eggs_dir(d, dest) newloc = _move_to_eggs_dir_and_compile(d, dest)
[d] = pkg_resources.Environment([newloc])[d.project_name] [d] = pkg_resources.Environment([newloc])[d.project_name]
result.append(d) result.append(d)
...@@ -518,8 +518,7 @@ class Installer: ...@@ -518,8 +518,7 @@ class Installer:
if dist.precedence == pkg_resources.EGG_DIST: if dist.precedence == pkg_resources.EGG_DIST:
# It's already an egg, just fetch it into the dest # It's already an egg, just fetch it into the dest
newloc = _move_to_eggs_dir(dist, self._dest) newloc = _move_to_eggs_dir_and_compile(dist, self._dest)
redo_pyc(newloc)
# Getting the dist from the environment causes the # Getting the dist from the environment causes the
# distribution meta data to be read. Cloning isn't # distribution meta data to be read. Cloning isn't
...@@ -532,7 +531,6 @@ class Installer: ...@@ -532,7 +531,6 @@ class Installer:
dists = self._call_easy_install( dists = self._call_easy_install(
dist.location, ws, self._dest, dist) dist.location, ws, self._dest, dist)
for dist in dists: for dist in dists:
redo_pyc(dist.location)
if for_buildout_run: if for_buildout_run:
# ws is the global working set and we're # ws is the global working set and we're
# installing buildout, setuptools, extensions or # installing buildout, setuptools, extensions or
...@@ -773,9 +771,6 @@ class Installer: ...@@ -773,9 +771,6 @@ class Installer:
base, pkg_resources.WorkingSet(), base, pkg_resources.WorkingSet(),
self._dest, dist) self._dest, dist)
for dist in dists:
redo_pyc(dist.location)
return [dist.location for dist in dists] return [dist.location for dist in dists]
finally: finally:
shutil.rmtree(build_tmp) shutil.rmtree(build_tmp)
...@@ -1547,9 +1542,11 @@ class IncompatibleConstraintError(zc.buildout.UserError): ...@@ -1547,9 +1542,11 @@ class IncompatibleConstraintError(zc.buildout.UserError):
IncompatibleVersionError = IncompatibleConstraintError # Backward compatibility IncompatibleVersionError = IncompatibleConstraintError # Backward compatibility
def _move_to_eggs_dir(dist, dest): def _move_to_eggs_dir_and_compile(dist, dest):
"""Move distribution to the eggs destination directory. """Move distribution to the eggs destination directory.
And compile the py files, if we have actually moved the dist.
Its new location is expected not to exist there yet, otherwise we Its new location is expected not to exist there yet, otherwise we
would not be calling this function: the egg is already there. But would not be calling this function: the egg is already there. But
the new location might exist at this point if another buildout is the new location might exist at this point if another buildout is
...@@ -1604,6 +1601,10 @@ def _move_to_eggs_dir(dist, dest): ...@@ -1604,6 +1601,10 @@ def _move_to_eggs_dir(dist, dest):
"We will accept it.\n" "We will accept it.\n"
"If this contains a wrong package, please remove it yourself.", "If this contains a wrong package, please remove it yourself.",
newloc) newloc)
else:
# There were no problems during the rename.
# Do the compile step.
redo_pyc(newloc)
finally: finally:
# Remember that temporary directories must be removed # Remember that temporary directories must be removed
shutil.rmtree(tmp_dest) shutil.rmtree(tmp_dest)
......
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