Commit 6f4b5b2e authored by Gary Poster's avatar Gary Poster

add test for recent fix for buildout

parent 243bd1c4
...@@ -392,6 +392,7 @@ class Buildout(UserDict.DictMixin): ...@@ -392,6 +392,7 @@ class Buildout(UserDict.DictMixin):
ws = pkg_resources.WorkingSet(entries) ws = pkg_resources.WorkingSet(entries)
ws.require('zc.buildout') ws.require('zc.buildout')
partsdir = os.path.join(options['parts-directory'], 'buildout') partsdir = os.path.join(options['parts-directory'], 'buildout')
if not os.path.exists(partsdir):
os.mkdir(partsdir) os.mkdir(partsdir)
zc.buildout.easy_install.sitepackage_safe_scripts( zc.buildout.easy_install.sitepackage_safe_scripts(
options['bin-directory'], ws, options['executable'], partsdir, options['bin-directory'], ws, options['executable'], partsdir,
...@@ -565,7 +566,7 @@ class Buildout(UserDict.DictMixin): ...@@ -565,7 +566,7 @@ class Buildout(UserDict.DictMixin):
if installed_files is None: if installed_files is None:
self._logger.warning( self._logger.warning(
"The %s install returned None. A path or " "The %s install returned None. A path or "
"iterable os paths should be returned.", "iterable of paths should be returned.",
part) part)
installed_files = () installed_files = ()
elif isinstance(installed_files, str): elif isinstance(installed_files, str):
......
...@@ -244,7 +244,7 @@ def set_installer_values(values): ...@@ -244,7 +244,7 @@ def set_installer_values(values):
for name, value in values.items(): for name, value in values.items():
getattr(zc.buildout.easy_install, name)(value) getattr(zc.buildout.easy_install, name)(value)
def make_buildout(): def make_buildout(executable=None):
"""Make a buildout that uses this version of zc.buildout.""" """Make a buildout that uses this version of zc.buildout."""
# Create a basic buildout.cfg to avoid a warning from buildout. # Create a basic buildout.cfg to avoid a warning from buildout.
open('buildout.cfg', 'w').write( open('buildout.cfg', 'w').write(
...@@ -254,13 +254,16 @@ def make_buildout(): ...@@ -254,13 +254,16 @@ def make_buildout():
# a Buildout will force the Buildout's defaults on the installer). # a Buildout will force the Buildout's defaults on the installer).
installer_values = get_installer_values() installer_values = get_installer_values()
# Use the buildout bootstrap command to create a buildout # Use the buildout bootstrap command to create a buildout
zc.buildout.buildout.Buildout( config = [
'buildout.cfg', ('buildout', 'log-level', 'WARNING'),
[('buildout', 'log-level', 'WARNING'),
# trick bootstrap into putting the buildout develop egg # trick bootstrap into putting the buildout develop egg
# in the eggs dir. # in the eggs dir.
('buildout', 'develop-eggs-directory', 'eggs'), ('buildout', 'develop-eggs-directory', 'eggs'),
], ]
if executable is not None:
config.append(('buildout', 'executable', executable))
zc.buildout.buildout.Buildout(
'buildout.cfg', config,
user_defaults=False, user_defaults=False,
).bootstrap([]) ).bootstrap([])
# Create the develop-eggs dir, which didn't get created the usual # Create the develop-eggs dir, which didn't get created the usual
......
...@@ -2254,6 +2254,94 @@ include-site-packages. ...@@ -2254,6 +2254,94 @@ include-site-packages.
""" """
def bootstrap_makes_buildout_that_works_with_system_python():
"""
In order to work smoothly with a system Python, bootstrapping creates
the buildout script with
zc.buildout.easy_install.sitepackage_safe_scripts. If it did not, a
variety of problems might happen. For instance, if another version of
buildout or setuptools is installed in the site-packages than is
desired, it may cause a problem.
A problem actually experienced in the field is when
a recipe wants a different version of a dependency that is installed in
site-packages. We will create a similar situation, and show that it is now
handled.
First let's write a dummy recipe.
>>> mkdir(sample_buildout, 'recipes')
>>> write(sample_buildout, 'recipes', 'dummy.py',
... '''
... import logging, os, zc.buildout
...
... class Dummy:
...
... def __init__(self, buildout, name, options):
... pass
...
... def install(self):
... return ()
...
... def update(self):
... pass
... ''')
>>> write(sample_buildout, 'recipes', 'setup.py',
... '''
... from setuptools import setup
...
... setup(
... name = "recipes",
... entry_points = {'zc.buildout': ['dummy = dummy:Dummy']},
... install_requires = 'demoneeded==1.2c1',
... )
... ''')
>>> write(sample_buildout, 'recipes', 'README.txt', " ")
Now we'll try to use it with a Python that has a different version of
demoneeded installed.
>>> py_path, site_packages_path = make_py()
>>> create_sample_sys_install(site_packages_path)
>>> rmdir('develop-eggs')
>>> from zc.buildout.testing import make_buildout
>>> make_buildout(executable=py_path)
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... develop = recipes
... parts = dummy
... find-links = %(link_server)s
... executable = %(py_path)s
...
... [dummy]
... recipe = recipes:dummy
... ''' % globals())
Now we actually run the buildout. Before the change, we got the following
error:
Develop: '/sample-buildout/recipes'
While:
Installing.
Getting section dummy.
Initializing section dummy.
Installing recipe recipes.
Error: There is a version conflict.
We already have: demoneeded 1.1
but recipes 0.0.0 requires 'demoneeded==1.2c1'.
Now, it is handled smoothly.
>>> print system(buildout)
Develop: '/sample-buildout/recipes'
Getting distribution for 'demoneeded==1.2c1'.
Got demoneeded 1.2c1.
Installing dummy.
<BLANKLINE>
"""
if sys.version_info > (2, 4): if sys.version_info > (2, 4):
def test_exit_codes(): def test_exit_codes():
""" """
......
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