[Checkins] SVN: zc.buildout/branches/gary-support-system-python/ Make buildout's cfg (for zc.buildout developers) set include_site_packages = false.
Gary Poster
gary.poster at canonical.com
Thu Jul 9 21:02:25 EDT 2009
Log message for revision 101780:
Make buildout's cfg (for zc.buildout developers) set include_site_packages = false.
When I did that, I discovered that the testselectingpython.py test was pretty
fragile. I made it less so, though my fix makes the test setup conditionally
rely on the same code that the test itself is supposed to demonstrate... :-/
Changed:
U zc.buildout/branches/gary-support-system-python/buildout.cfg
U zc.buildout/branches/gary-support-system-python/src/zc/buildout/testing.py
U zc.buildout/branches/gary-support-system-python/src/zc/buildout/testselectingpython.py
-=-
Modified: zc.buildout/branches/gary-support-system-python/buildout.cfg
===================================================================
--- zc.buildout/branches/gary-support-system-python/buildout.cfg 2009-07-10 01:00:06 UTC (rev 101779)
+++ zc.buildout/branches/gary-support-system-python/buildout.cfg 2009-07-10 01:02:25 UTC (rev 101780)
@@ -1,6 +1,7 @@
[buildout]
develop = zc.recipe.egg_ .
parts = test oltest py
+include-site-packages = false
[py]
recipe = zc.recipe.egg
Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/testing.py 2009-07-10 01:00:06 UTC (rev 101779)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/testing.py 2009-07-10 01:02:25 UTC (rev 101780)
@@ -116,12 +116,19 @@
args = [zc.buildout.easy_install._safe_arg(arg)
for arg in args]
args.insert(0, '-q')
- args.append(dict(os.environ, PYTHONPATH=setuptools_location))
+ env = dict(os.environ)
+ if executable == sys.executable:
+ env['PYTHONPATH'] = setuptools_location
+ # else pass an executable that has setuptools! See testselectingpython.py.
+ args.append(env)
+
here = os.getcwd()
try:
os.chdir(d)
- os.spawnle(os.P_WAIT, executable, zc.buildout.easy_install._safe_arg (executable), setup, *args)
+ os.spawnle(os.P_WAIT, executable,
+ zc.buildout.easy_install._safe_arg(executable),
+ setup, *args)
if os.path.exists('build'):
rmtree('build')
finally:
Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/testselectingpython.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/testselectingpython.py 2009-07-10 01:00:06 UTC (rev 101779)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/testselectingpython.py 2009-07-10 01:02:25 UTC (rev 101780)
@@ -11,8 +11,9 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-import os, re, sys, unittest
+import os, re, subprocess, sys, textwrap, unittest
from zope.testing import doctest, renormalizing
+import zc.buildout.easy_install
import zc.buildout.tests
import zc.buildout.testing
@@ -25,13 +26,14 @@
test_selecting_python_via_easy_install=
"""\
-We can specify an specific Python executable.
+We can specify a specific Python executable.
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/',
- ... always_unzip=True, executable= other_executable)
+ ... always_unzip=True, executable= other_executable,
+ ... include_site_packages=False)
>>> ls(dest)
d demo-0.3-py%(other_version)s.egg
@@ -43,6 +45,31 @@
def multi_python(test):
other_executable = zc.buildout.testing.find_python(other_version)
+ command = textwrap.dedent('''\
+ try:
+ import setuptools
+ except ImportError:
+ import sys
+ sys.exit(1)
+ ''')
+ if subprocess.call([other_executable, '-c', command],
+ env=os.environ):
+ # the other executable does not have setuptools. Get setuptools.
+ # We will do this using the same tools we are testing, for better or
+ # worse. Alternatively, we could try using bootstrap.
+ executable_dir = test.globs['tmpdir']('executable_dir')
+ ws = zc.buildout.easy_install.install(
+ ['setuptools'], executable_dir,
+ index='http://www.python.org/pypi/',
+ always_unzip=True, executable=other_executable)
+ zc.buildout.easy_install.scripts(
+ ['setuptools'], ws, other_executable, executable_dir,
+ interpreter='py')
+ original_executable = other_executable
+ other_executable = os.path.join(executable_dir, 'py')
+ assert not subprocess.call(
+ [other_executable, '-c', command], env=os.environ), (
+ 'test set up failed')
sample_eggs = test.globs['tmpdir']('sample_eggs')
os.mkdir(os.path.join(sample_eggs, 'index'))
test.globs['sample_eggs'] = sample_eggs
More information about the Checkins
mailing list