Commit 454b7a8b authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #327 from buildout/fix-326

Fixes #326
parents 7a1741fc 63cf3a6b
...@@ -4,7 +4,11 @@ Change History ...@@ -4,7 +4,11 @@ Change History
2.7.1 (unreleased) 2.7.1 (unreleased)
================== ==================
- Nothing changed yet. - Fixed a bug introduced in 2.6.0:
zc.buildout and its dependeoncies were reported as picked even when
their versions were fixed in a ``versions`` section. Worse, when the
``update-versions-file`` option was used, the ``versions`` section was
updated needlessly on every run.
2.7.0 (2017-01-30) 2.7.0 (2017-01-30)
......
...@@ -188,7 +188,8 @@ class Installer: ...@@ -188,7 +188,8 @@ class Installer:
newest=True, newest=True,
versions=None, versions=None,
use_dependency_links=None, use_dependency_links=None,
allow_hosts=('*',) allow_hosts=('*',),
check_picked=True,
): ):
assert executable == sys.executable, (executable, sys.executable) assert executable == sys.executable, (executable, sys.executable)
self._dest = dest self._dest = dest
...@@ -218,6 +219,7 @@ class Installer: ...@@ -218,6 +219,7 @@ class Installer:
self._env = pkg_resources.Environment(path) self._env = pkg_resources.Environment(path)
self._index = _get_index(index, links, self._allow_hosts) self._index = _get_index(index, links, self._allow_hosts)
self._requirements_and_constraints = [] self._requirements_and_constraints = []
self._check_picked = check_picked
if versions is not None: if versions is not None:
self._versions = normalize_versions(versions) self._versions = normalize_versions(versions)
...@@ -558,23 +560,25 @@ class Installer: ...@@ -558,23 +560,25 @@ class Installer:
self._links, self._links,
self._allow_hosts) self._allow_hosts)
for dist in dists: if self._check_picked:
# Check whether we picked a version and, if we did, report it: # Check whether we picked a version and, if we did, report it:
if not ( for dist in dists:
dist.precedence == pkg_resources.DEVELOP_DIST if not (
or dist.precedence == pkg_resources.DEVELOP_DIST
(len(requirement.specs) == 1 or
and (len(requirement.specs) == 1
requirement.specs[0][0] == '==') and
): requirement.specs[0][0] == '==')
logger.debug('Picked: %s = %s', ):
dist.project_name, dist.version) logger.debug('Picked: %s = %s',
self._picked_versions[dist.project_name] = dist.version dist.project_name, dist.version)
self._picked_versions[dist.project_name] = dist.version
if not self._allow_picked_versions:
raise zc.buildout.UserError( if not self._allow_picked_versions:
'Picked: %s = %s' % (dist.project_name, dist.version) raise zc.buildout.UserError(
) 'Picked: %s = %s' % (dist.project_name,
dist.version)
)
return dists return dists
...@@ -875,6 +879,7 @@ def install(specs, dest, ...@@ -875,6 +879,7 @@ def install(specs, dest,
use_dependency_links=None, allow_hosts=('*',), use_dependency_links=None, allow_hosts=('*',),
include_site_packages=None, include_site_packages=None,
allowed_eggs_from_site_packages=None, allowed_eggs_from_site_packages=None,
check_picked=True,
): ):
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
...@@ -883,14 +888,16 @@ def install(specs, dest, ...@@ -883,14 +888,16 @@ def install(specs, dest,
installer = Installer(dest, links, index, sys.executable, installer = Installer(dest, links, index, sys.executable,
always_unzip, path, always_unzip, path,
newest, versions, use_dependency_links, newest, versions, use_dependency_links,
allow_hosts=allow_hosts) allow_hosts=allow_hosts,
check_picked=check_picked)
return installer.install(specs, working_set) return installer.install(specs, working_set)
buildout_and_setuptools_dists = list(install(['zc.buildout'], None)) buildout_and_setuptools_dists = list(install(['zc.buildout'], None,
check_picked=False))
buildout_and_setuptools_path = [d.location buildout_and_setuptools_path = [d.location
for d in buildout_and_setuptools_dists] for d in buildout_and_setuptools_dists]
setuptools_path = [d.location setuptools_path = [d.location
for d in install(['setuptools'], None)] for d in install(['setuptools'], None, check_picked=False)]
setuptools_pythonpath = os.pathsep.join(setuptools_path) setuptools_pythonpath = os.pathsep.join(setuptools_path)
def build(spec, dest, build_ext, def build(spec, dest, build_ext,
......
...@@ -420,10 +420,8 @@ The versions file now contains the extra pin: ...@@ -420,10 +420,8 @@ The versions file now contains the extra pin:
And re-running buildout doesn't report any picked versions anymore: And re-running buildout doesn't report any picked versions anymore:
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS >>> 'picked' in system(buildout)
Updating foo. False
recipe v2
...
If you've enabled ``update-versions-file`` but not ``show-picked-versions``, If you've enabled ``update-versions-file`` but not ``show-picked-versions``,
buildout will append the versions to your versions file anyway (without buildout will append the versions to your versions file anyway (without
......
...@@ -3062,6 +3062,45 @@ def test_abi_tag_eggs(): ...@@ -3062,6 +3062,45 @@ def test_abi_tag_eggs():
... ...
""" """
def test_buildout_doesnt_keep_adding_itself_to_versions():
r"""
We were constantly writing to versions.cfg for buildout and setuptools
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... extends = versions.cfg
... show-picked-versions = true
... update-versions-file = versions.cfg
... extends = versions.cfg
... ''')
>>> write('versions.cfg',
... '''[versions]
... ''')
>>> _ = system(join('bin', 'buildout'))
>>> with open('versions.cfg') as f:
... versions = f.read()
>>> _ = system(join('bin', 'buildout'))
On the first run, some pins were added:
>>> cat('versions.cfg') # doctest: +ELLIPSIS
[versions]
<BLANKLINE>
# Added by buildout...
setuptools = 34.0.3
...
>>> _ = system(join('bin', 'buildout'))
>>> _ = system(join('bin', 'buildout'))
Subsequent runs didn't add additional text:
>>> with open('versions.cfg') as f:
... versions == f.read()
True
"""
if sys.platform == 'win32': if sys.platform == 'win32':
del buildout_honors_umask # umask on dohs is academic del buildout_honors_umask # umask on dohs is academic
......
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