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
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)
......
......@@ -188,7 +188,8 @@ class Installer:
newest=True,
versions=None,
use_dependency_links=None,
allow_hosts=('*',)
allow_hosts=('*',),
check_picked=True,
):
assert executable == sys.executable, (executable, sys.executable)
self._dest = dest
......@@ -218,6 +219,7 @@ class Installer:
self._env = pkg_resources.Environment(path)
self._index = _get_index(index, links, self._allow_hosts)
self._requirements_and_constraints = []
self._check_picked = check_picked
if versions is not None:
self._versions = normalize_versions(versions)
......@@ -558,23 +560,25 @@ class Installer:
self._links,
self._allow_hosts)
for dist in dists:
if self._check_picked:
# Check whether we picked a version and, if we did, report it:
if not (
dist.precedence == pkg_resources.DEVELOP_DIST
or
(len(requirement.specs) == 1
and
requirement.specs[0][0] == '==')
):
logger.debug('Picked: %s = %s',
dist.project_name, dist.version)
self._picked_versions[dist.project_name] = dist.version
if not self._allow_picked_versions:
raise zc.buildout.UserError(
'Picked: %s = %s' % (dist.project_name, dist.version)
)
for dist in dists:
if not (
dist.precedence == pkg_resources.DEVELOP_DIST
or
(len(requirement.specs) == 1
and
requirement.specs[0][0] == '==')
):
logger.debug('Picked: %s = %s',
dist.project_name, dist.version)
self._picked_versions[dist.project_name] = dist.version
if not self._allow_picked_versions:
raise zc.buildout.UserError(
'Picked: %s = %s' % (dist.project_name,
dist.version)
)
return dists
......@@ -875,6 +879,7 @@ def install(specs, dest,
use_dependency_links=None, allow_hosts=('*',),
include_site_packages=None,
allowed_eggs_from_site_packages=None,
check_picked=True,
):
assert executable == sys.executable, (executable, sys.executable)
assert include_site_packages is None
......@@ -883,14 +888,16 @@ def install(specs, dest,
installer = Installer(dest, links, index, sys.executable,
always_unzip, path,
newest, versions, use_dependency_links,
allow_hosts=allow_hosts)
allow_hosts=allow_hosts,
check_picked=check_picked)
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
for d in buildout_and_setuptools_dists]
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)
def build(spec, dest, build_ext,
......
......@@ -420,10 +420,8 @@ The versions file now contains the extra pin:
And re-running buildout doesn't report any picked versions anymore:
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo.
recipe v2
...
>>> 'picked' in system(buildout)
False
If you've enabled ``update-versions-file`` but not ``show-picked-versions``,
buildout will append the versions to your versions file anyway (without
......
......@@ -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':
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