Commit 243bd1c4 authored by Gary Poster's avatar Gary Poster

make the buildout script itself safe for a Python with site packages.

parent 49f0fd01
...@@ -391,9 +391,11 @@ class Buildout(UserDict.DictMixin): ...@@ -391,9 +391,11 @@ class Buildout(UserDict.DictMixin):
# Create buildout script # Create buildout script
ws = pkg_resources.WorkingSet(entries) ws = pkg_resources.WorkingSet(entries)
ws.require('zc.buildout') ws.require('zc.buildout')
zc.buildout.easy_install.scripts( partsdir = os.path.join(options['parts-directory'], 'buildout')
['zc.buildout'], ws, options['executable'], os.mkdir(partsdir)
options['bin-directory']) zc.buildout.easy_install.sitepackage_safe_scripts(
options['bin-directory'], ws, options['executable'], partsdir,
reqs=['zc.buildout'])
init = bootstrap init = bootstrap
......
...@@ -56,10 +56,9 @@ The bin directory contains scripts. ...@@ -56,10 +56,9 @@ The bin directory contains scripts.
- setuptools-0.6-py2.4.egg - setuptools-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg - zc.buildout-1.0-py2.4.egg
The develop-eggs and parts directories are initially empty: The develop-eggs directory is initially empty:
>>> ls(sample_buildout, 'develop-eggs') >>> ls(sample_buildout, 'develop-eggs')
>>> ls(sample_buildout, 'parts')
The develop-eggs directory holds egg links for software being The develop-eggs directory holds egg links for software being
developed in the buildout. We separate develop-eggs and other eggs to developed in the buildout. We separate develop-eggs and other eggs to
...@@ -69,6 +68,12 @@ directory in their home that all non-develop eggs are stored in. This ...@@ -69,6 +68,12 @@ directory in their home that all non-develop eggs are stored in. This
allows larger buildouts to be set up much more quickly and saves disk allows larger buildouts to be set up much more quickly and saves disk
space. space.
The parts directory just contains some helpers for the buildout script
itself.
>>> ls(sample_buildout, 'parts')
d buildout
The parts directory provides an area where recipes can install The parts directory provides an area where recipes can install
part data. For example, if we built a custom Python, we would part data. For example, if we built a custom Python, we would
install it in the part directory. Part data is stored in a install it in the part directory. Part data is stored in a
......
...@@ -374,19 +374,6 @@ def buildoutSetUp(test): ...@@ -374,19 +374,6 @@ def buildoutSetUp(test):
return ( return (
os.path.join(buildout, 'bin', 'py'), site_packages_dir) os.path.join(buildout, 'bin', 'py'), site_packages_dir)
buildout = os.path.join(sample, 'bin', 'buildout')
def do_build(buildout=buildout, python=None, args=()):
if python is None:
return system(buildout)
if sys.platform == 'win32':
# We need to find the "real" script.
buildout += '-script.py'
cmd = [python, buildout]
cmd.extend(args)
return system(zc.buildout.easy_install._safe_arg(
' '.join(zc.buildout.easy_install._safe_arg(arg) for arg in cmd)))
test.globs.update(dict( test.globs.update(dict(
sample_buildout = sample, sample_buildout = sample,
ls = ls, ls = ls,
...@@ -397,7 +384,6 @@ def buildoutSetUp(test): ...@@ -397,7 +384,6 @@ def buildoutSetUp(test):
tmpdir = tmpdir, tmpdir = tmpdir,
write = write, write = write,
system = system, system = system,
do_build=do_build,
call_py = call_py, call_py = call_py,
get = get, get = get,
cd = (lambda *path: os.chdir(os.path.join(*path))), cd = (lambda *path: os.chdir(os.path.join(*path))),
...@@ -405,7 +391,7 @@ def buildoutSetUp(test): ...@@ -405,7 +391,7 @@ def buildoutSetUp(test):
sdist = sdist, sdist = sdist,
bdist_egg = bdist_egg, bdist_egg = bdist_egg,
start_server = start_server, start_server = start_server,
buildout = buildout, buildout = os.path.join(sample, 'bin', 'buildout'),
wait_until = wait_until, wait_until = wait_until,
make_py = make_py make_py = make_py
)) ))
......
...@@ -420,7 +420,7 @@ Now here is the output. The lines that begin with "Egg from site-packages:" ...@@ -420,7 +420,7 @@ Now here is the output. The lines that begin with "Egg from site-packages:"
indicate the eggs from site-packages that have been selected. You'll see indicate the eggs from site-packages that have been selected. You'll see
we have two: demo 0.3 and demoneeded 1.1. we have two: demo 0.3 and demoneeded 1.1.
>>> print do_build(python=py_path, args=['-v']) >>> print system(buildout+" -v")
Installing 'zc.buildout', 'setuptools'. Installing 'zc.buildout', 'setuptools'.
We have a develop egg: zc.buildout V We have a develop egg: zc.buildout V
We have the best distribution that satisfies 'setuptools'. We have the best distribution that satisfies 'setuptools'.
......
...@@ -325,7 +325,7 @@ document do not affect this example.) ...@@ -325,7 +325,7 @@ document do not affect this example.)
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Creating directory '/sample-buildout/tmpeggs'. Creating directory '/sample-buildout/tmpeggs'.
Uninstalling py. Uninstalling py.
Installing eggs. Installing eggs.
...@@ -354,10 +354,11 @@ is not allowed to come from site-packages, and the buildout fails. ...@@ -354,10 +354,11 @@ is not allowed to come from site-packages, and the buildout fails.
... allowed-eggs-from-site-packages = ... allowed-eggs-from-site-packages =
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Creating directory '/sample-buildout/tmpeggs'. Creating directory '/sample-buildout/tmpeggs'.
Uninstalling eggs. Uninstalling eggs.
Installing eggs. Installing eggs.
Couldn't find index page for 'demoneeded' (maybe misspelled?)
Getting distribution for 'demoneeded'. Getting distribution for 'demoneeded'.
While: While:
Installing eggs. Installing eggs.
...@@ -458,6 +459,7 @@ Note that the parts/py directory has been cleaned up, and parts/python has ...@@ -458,6 +459,7 @@ Note that the parts/py directory has been cleaned up, and parts/python has
been created. been created.
>>> ls(sample_buildout, 'parts') >>> ls(sample_buildout, 'parts')
d buildout
d demo d demo
d python d python
......
...@@ -267,7 +267,7 @@ The eggs are not found. ...@@ -267,7 +267,7 @@ The eggs are not found.
... python = primed_python ... python = primed_python
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Installing eggs. Installing eggs.
Couldn't find index page for 'demoneeded' (maybe misspelled?) Couldn't find index page for 'demoneeded' (maybe misspelled?)
Getting distribution for 'demoneeded'. Getting distribution for 'demoneeded'.
...@@ -297,7 +297,7 @@ they are in the executable's path. ...@@ -297,7 +297,7 @@ they are in the executable's path.
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Installing eggs. Installing eggs.
<BLANKLINE> <BLANKLINE>
...@@ -315,7 +315,7 @@ We get an error if we specify anything but true or false: ...@@ -315,7 +315,7 @@ We get an error if we specify anything but true or false:
... eggs = other ... eggs = other
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
While: While:
Installing. Installing.
Getting section eggs. Getting section eggs.
...@@ -357,7 +357,7 @@ correctly parse a single-line value. ...@@ -357,7 +357,7 @@ correctly parse a single-line value.
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Installing eggs. Installing eggs.
<BLANKLINE> <BLANKLINE>
...@@ -383,7 +383,7 @@ parse a multi-line value. ...@@ -383,7 +383,7 @@ parse a multi-line value.
... eggs = demoneeded ... eggs = demoneeded
... ''' % globals()) ... ''' % globals())
>>> print do_build(python=py_path) >>> print system(buildout)
Uninstalling eggs. Uninstalling eggs.
Installing eggs. Installing eggs.
<BLANKLINE> <BLANKLINE>
......
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