Commit 89feb749 authored by Jim Fulton's avatar Jim Fulton

Always unzip!

parent 7b2fcc12
......@@ -79,7 +79,7 @@ env = dict(os.environ,
cmd = [sys.executable, '-c',
'from setuptools.command.easy_install import main; main()',
'-mqNxd', tmpeggs]
'-mZqNxd', tmpeggs]
if 'bootstrap-testing-find-links' in os.environ:
cmd.extend(['-f', os.environ['bootstrap-testing-find-links']])
......
......@@ -28,8 +28,6 @@ long_description=(
+ '\n' +
read('src', 'zc', 'buildout', 'buildout.txt')
+ '\n' +
read('src', 'zc', 'buildout', 'unzip.txt')
+ '\n' +
read('src', 'zc', 'buildout', 'repeatable.txt')
+ '\n' +
read('src', 'zc', 'buildout', 'download.txt')
......
......@@ -325,15 +325,6 @@ class Buildout(UserDict.DictMixin):
if install_from_cache == 'true':
zc.buildout.easy_install.install_from_cache(True)
always_unzip = options.get('unzip')
if always_unzip:
if always_unzip not in ('true', 'false'):
self._error('Invalid value for unzip option: %s',
always_unzip)
if always_unzip == 'true':
zc.buildout.easy_install.always_unzip(True)
# "Use" each of the defaults so they aren't reported as unused options.
for name in _buildout_default_options:
options[name]
......
......@@ -128,14 +128,13 @@ class Installer:
_prefer_final = True
_use_dependency_links = True
_allow_picked_versions = True
_always_unzip = False
def __init__(self,
dest=None,
links=(),
index=None,
executable=sys.executable,
always_unzip=None,
always_unzip=None, # Backward compat :/
path=None,
newest=True,
versions=None,
......@@ -160,8 +159,6 @@ class Installer:
links.insert(0, self._download_cache)
self._index_url = index
if always_unzip is not None:
self._always_unzip = always_unzip
path = (path and path[:] or []) + buildout_and_distribute_path
if dest is not None and dest not in path:
path.insert(0, dest)
......@@ -275,9 +272,7 @@ class Installer:
try:
path = distribute_loc
args = [sys.executable, '-c', _easy_install_cmd, '-mUNxd', tmp]
if self._always_unzip:
args.append('-Z')
args = [sys.executable, '-c', _easy_install_cmd, '-mZUNxd', tmp]
level = logger.getEffectiveLevel()
if level > 0:
args.append('-q')
......@@ -424,7 +419,7 @@ class Installer:
return dist.clone(location=new_location)
def _get_dist(self, requirement, ws, always_unzip):
def _get_dist(self, requirement, ws):
__doing__ = 'Getting distribution for %r.', str(requirement)
......@@ -467,23 +462,9 @@ class Installer:
shutil.copytree(dist.location, newloc)
else:
if self._always_unzip:
should_unzip = True
else:
metadata = pkg_resources.EggMetadata(
zipimport.zipimporter(dist.location)
)
should_unzip = (
metadata.has_metadata('not-zip-safe')
or
not metadata.has_metadata('zip-safe')
)
if should_unzip:
setuptools.archive_util.unpack_archive(
dist.location, newloc)
else:
shutil.copyfile(dist.location, newloc)
redo_pyc(newloc)
......@@ -559,7 +540,7 @@ class Installer:
pkg_resources.Requirement.parse('distribute')
)
if ws.find(requirement) is None:
for dist in self._get_dist(requirement, ws, False):
for dist in self._get_dist(requirement, ws):
ws.add(dist)
......@@ -598,7 +579,7 @@ class Installer:
ws = working_set
for requirement in requirements:
for dist in self._get_dist(requirement, ws, self._always_unzip):
for dist in self._get_dist(requirement, ws):
ws.add(dist)
self._maybe_add_distribute(ws, dist)
......@@ -622,9 +603,7 @@ class Installer:
logger.debug('Adding required %r', str(requirement))
_log_requirement(ws, requirement)
for dist in self._get_dist(requirement, ws, self._always_unzip
):
for dist in self._get_dist(requirement, ws):
ws.add(dist)
self._maybe_add_distribute(ws, dist)
except pkg_resources.VersionConflict, err:
......@@ -738,15 +717,10 @@ def allow_picked_versions(setting=None):
Installer._allow_picked_versions = bool(setting)
return old
def always_unzip(setting=None):
old = Installer._always_unzip
if setting is not None:
Installer._always_unzip = bool(setting)
return old
def install(specs, dest,
links=(), index=None,
executable=sys.executable, always_unzip=None,
executable=sys.executable,
always_unzip=None, # Backward compat :/
path=None, working_set=None, newest=True, versions=None,
use_dependency_links=None, allow_hosts=('*',)):
assert executable == sys.executable, (executable, sys.executable)
......
......@@ -57,10 +57,6 @@ path
A list of additional directories to search for locally-installed
distributions.
always_unzip
A flag indicating that newly-downloaded distributions should be
directories even if they could be installed as zip files.
working_set
An existing working set to be augmented with additional
distributions, if necessary to satisfy requirements. This allows
......@@ -135,7 +131,7 @@ We got demoneeded because it was a dependency of demo.
And the actual eggs were added to the eggs directory.
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
If we remove the version restriction on demo, but specify a false
......@@ -145,7 +141,7 @@ value for newest, no new distributions will be installed:
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... newest=False)
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
If we leave off the newest option, we'll get an update for demo:
......@@ -153,8 +149,8 @@ If we leave off the newest option, we'll get an update for demo:
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/')
>>> ls(dest)
- demo-0.2-py2.4.egg
- demo-0.3-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
Note that we didn't get the newest versions available. There were
......@@ -175,9 +171,9 @@ The old setting is returned.
demoneeded 1.2c1
>>> ls(dest)
- demo-0.2-py2.4.egg
- demo-0.3-py2.4.egg
- demo-0.4c1-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demo-0.4c1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
......@@ -201,75 +197,15 @@ dependencies. We might do this to specify a specific version.
demoneeded 1.0
>>> ls(dest)
- demo-0.2-py2.4.egg
- demo-0.3-py2.4.egg
- demo-0.4c1-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demo-0.4c1-py2.4.egg
d demoneeded-1.0-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
d other-1.0-py2.4.egg
We can request that eggs be unzipped even if they are zip safe. This
can be useful when debugging.
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... always_unzip=True)
>>> ls(dest)
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... always_unzip=False)
>>> ls(dest)
- demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
We can also set a default by calling the always_unzip function:
>>> zc.buildout.easy_install.always_unzip(True)
False
The old default is returned:
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/')
>>> ls(dest)
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
>>> zc.buildout.easy_install.always_unzip(False)
True
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/')
>>> ls(dest)
- demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... always_unzip=True)
>>> ls(dest)
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
Specifying version information independent of requirements
----------------------------------------------------------
......@@ -322,7 +258,29 @@ reporting that a version was picked automatically:
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... )
>>> print handler
>>> print handler # doctest: +ELLIPSIS
zc.buildout.easy_install DEBUG
Installing 'demo'.
zc.buildout.easy_install INFO
Getting distribution for 'demo'.
zc.buildout.easy_install INFO
Got demo 0.3.
zc.buildout.easy_install DEBUG
Picked: demo = 0.3
zc.buildout.easy_install DEBUG
Getting required 'demoneeded'
zc.buildout.easy_install DEBUG
required by demo 0.3.
zc.buildout.easy_install INFO
Getting distribution for 'demoneeded'.
zc.buildout.easy_install DEBUG
Running easy_install:...
zc.buildout.easy_install INFO
Got demoneeded 1.1.
zc.buildout.easy_install DEBUG
Picked: demoneeded = 1.1
zc.buildout.easy_install DEBUG
Installing 'demo'.
zc.buildout.easy_install DEBUG
......@@ -1007,7 +965,7 @@ The function returns the list of eggs
Now if we look in our destination directory, we see we have an extdemo egg:
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demoneeded-1.0-py2.4.egg
d demoneeded-1.1-py2.4.egg
......@@ -1048,7 +1006,7 @@ If we run build with newest set to False, we won't get an update:
['/sample-install/extdemo-1.4-py2.4-linux-i686.egg']
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demoneeded-1.0-py2.4.egg
d demoneeded-1.1-py2.4.egg
......@@ -1064,7 +1022,7 @@ get an updated egg:
['/sample-install/extdemo-1.5-py2.4-unix-i686.egg']
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demo-0.3-py2.4.egg
d demoneeded-1.0-py2.4.egg
d demoneeded-1.1-py2.4.egg
......@@ -1187,8 +1145,7 @@ Now, if we install demo, and extdemo:
>>> ws = zc.buildout.easy_install.install(
... ['demo==0.2'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
... links=[link_server], index=link_server+'index/')
GET 200 /
GET 404 /index/demo/
GET 200 /index/
......@@ -1231,8 +1188,7 @@ Now when we install the distributions:
>>> ws = zc.buildout.easy_install.install(
... ['demo==0.2'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
... links=[link_server], index=link_server+'index/')
GET 200 /
GET 404 /index/demo/
GET 200 /index/
......@@ -1257,8 +1213,7 @@ from the link server:
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
... links=[link_server], index=link_server+'index/')
GET 200 /demo-0.3-py2.4.egg
Normally, the download cache is the preferred source of downloads, but
......@@ -1299,8 +1254,7 @@ recreate the destination directory, and reinstall demo:
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
... links=[link_server], index=link_server+'index/')
>>> ls(dest)
d demo-0.2-py2.4.egg
......
......@@ -1862,7 +1862,7 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
demoneeded 1.1
>>> ls(dest)
- demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
"""
......@@ -2094,8 +2094,7 @@ def prefer_final_permutation(existing, available):
zc.buildout.easy_install.clear_index_cache()
[dist] = list(
zc.buildout.easy_install.install(['spam'], 'existing', ['available'],
always_unzip=True)
zc.buildout.easy_install.install(['spam'], 'existing', ['available'])
)
if dist.extras:
......@@ -2369,7 +2368,6 @@ def pyc_and_pyo_files_have_correct_paths():
... [buildout]
... parts = eggs
... find-links = %(link_server)s
... unzip = true
...
... [eggs]
... recipe = zc.recipe.egg
......@@ -2878,7 +2876,7 @@ def test_suite():
doctest.DocFileSuite(
'easy_install.txt', 'downloadcache.txt', 'dependencylinks.txt',
'allowhosts.txt', 'unzip.txt',
'allowhosts.txt',
setUp=easy_install_SetUp,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
......
Always unzipping eggs
=====================
By default, zc.buildout doesn't unzip zip-safe eggs.
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = eggs
... find-links = %(link_server)s
...
... [eggs]
... recipe = zc.recipe.egg
... eggs = demo
... ''' % globals())
>>> _ = system(buildout)
>>> ls('eggs')
- demo-0.4c1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
d distribute-0.6c8-py2.4.egg
- zc.buildout.egg-link
This follows the policy followed by setuptools itself. Experience shows
this policy to to be inconvenient. Zipped eggs make debugging more
difficult and often import more slowly.
You can include an unzip option in the buildout section to change the
default unzipping policy.
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = eggs
... find-links = %(link_server)s
... unzip = true
...
... [eggs]
... recipe = zc.recipe.egg
... eggs = demo
... ''' % globals())
>>> import os
>>> for name in os.listdir('eggs'):
... if name.startswith('demo'):
... remove('eggs', name)
>>> _ = system(buildout)
>>> ls('eggs')
d demo-0.4c1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
d distribute-0.6c8-py2.4.egg
- zc.buildout.egg-link
......@@ -71,10 +71,10 @@ Let's run the buildout:
Now, if we look at the buildout eggs directory:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
d demo-0.2-py2.3.egg
d demoneeded-1.2c1-py2.3.egg
- distribute-0.6-py2.3.egg
- zc.buildout-1.0-py2.3.egg
d distribute-0.6-py2.3.egg
d zc.buildout-1.0-py2.3.egg
We see that we got an egg for demo that met the requirement, as well
as the egg for demoneeded, which demo requires. (We also see an egg
......@@ -260,10 +260,10 @@ We'll also run the buildout in off-line mode:
We didn't get an update for demo:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
d demo-0.2-py2.3.egg
d demoneeded-1.2c1-py2.3.egg
- distribute-0.6-py2.3.egg
- zc.buildout-1.0-py2.3.egg
d distribute-0.6-py2.3.egg
d zc.buildout-1.0-py2.3.egg
If we run the buildout on the default online and newest modes,
we'll get an update for demo:
......@@ -277,11 +277,11 @@ we'll get an update for demo:
Then we'll get a new demo egg:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demo-0.4c1-py2.3.egg
d demo-0.2-py2.3.egg
d demo-0.4c1-py2.3.egg
d demoneeded-1.2c1-py2.3.egg
- distribute-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg
d distribute-0.6-py2.4.egg
d zc.buildout-1.0-py2.4.egg
The script is updated too:
......
......@@ -69,8 +69,6 @@ class Custom(Base):
options['_e'] = buildout['buildout']['eggs-directory']
assert options.get('unzip') in ('true', 'false', None)
if buildout['buildout'].get('offline') == 'true':
self.install = lambda: ()
......
......@@ -52,8 +52,6 @@ class Eggs(object):
] = buildout['buildout']['develop-eggs-directory']
options['_d'] = options['develop-eggs-directory'] # backward compat.
assert options.get('unzip') in ('true', 'false', None)
def working_set(self, extra=()):
"""Separate method to just get the working set
......@@ -77,18 +75,13 @@ class Eggs(object):
[options['develop-eggs-directory'], options['eggs-directory']]
)
else:
kw = {}
if options.get('unzip'):
kw['always_unzip'] = get_bool(options, 'unzip')
ws = zc.buildout.easy_install.install(
distributions, options['eggs-directory'],
links=self.links,
index=self.index,
path=[options['develop-eggs-directory']],
newest=self.buildout['buildout'].get('newest') == 'true',
allow_hosts=self.allow_hosts,
**kw)
allow_hosts=self.allow_hosts)
return orig_distributions, ws
......
......@@ -43,9 +43,9 @@ def test_suite():
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.normalize_bang,
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
(re.compile('[d-] zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'),
(re.compile('[-d] distribute-[^-]+-'), 'distribute-X-'),
(re.compile('[d-] distribute-[^-]+-'), 'distribute-X-'),
(re.compile(r'eggs\\\\demo'), 'eggs/demo'),
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'),
])
......
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