[Checkins] SVN: zc.buildout/branches/win/ All tests pass on windows
:)
Jim Fulton
jim at zope.com
Sun Aug 27 11:39:56 EDT 2006
Log message for revision 69799:
All tests pass on windows :)
Changed:
U zc.buildout/branches/win/bootstrap/bootstrap.py
U zc.buildout/branches/win/src/zc/buildout/buildout.py
U zc.buildout/branches/win/src/zc/buildout/buildout.txt
U zc.buildout/branches/win/src/zc/buildout/easy_install.py
U zc.buildout/branches/win/src/zc/buildout/easy_install.txt
U zc.buildout/branches/win/src/zc/buildout/testing.py
U zc.buildout/branches/win/src/zc/buildout/tests.py
U zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/README.txt
U zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/api.txt
U zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
U zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/tests.py
U zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
U zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
U zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/tests.py
-=-
Modified: zc.buildout/branches/win/bootstrap/bootstrap.py
===================================================================
--- zc.buildout/branches/win/bootstrap/bootstrap.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/bootstrap/bootstrap.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -31,14 +31,18 @@
import pkg_resources
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
ws = pkg_resources.working_set
assert os.spawnle(
os.P_WAIT, sys.executable, sys.executable,
- '-c', 'from setuptools.command.easy_install import main; main()',
- '-mqNxd', tmpeggs, 'zc.buildout',
- {'PYTHONPATH':
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- },
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ 'PYTHONPATH'=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
) == 0
ws.add_entry(tmpeggs)
Modified: zc.buildout/branches/win/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/buildout.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/buildout.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -1,4 +1,4 @@
-##############################################################################
+#############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
@@ -139,6 +139,8 @@
options['installed'] = os.path.join(options['directory'],
options['installed'])
+ self._setup_logging()
+
def _dosubs(self, section, option, value, data, converted, seen):
key = section, option
r = converted.get(key)
@@ -215,7 +217,7 @@
r = pkg_resources.Requirement.parse(name)
dist = pkg_resources.working_set.find(r)
if dist.precedence == pkg_resources.DEVELOP_DIST:
- dest = os.path.join(self['buildout']['develop-eggs-directory'],
+ dest = os.path.join(self['buildout']['eggs-directory'],
name+'.egg-link')
open(dest, 'w').write(dist.location)
entries.append(dist.location)
@@ -351,9 +353,14 @@
os.chdir(os.path.dirname(setup))
os.spawnle(
os.P_WAIT, sys.executable, sys.executable,
- setup, '-q', 'develop', '-m', '-x', '-N',
- '-f', ' '.join(self._links),
- '-d', self['buildout']['develop-eggs-directory'],
+ zc.buildout.easy_install._safe_arg(setup),
+ '-q', 'develop', '-m', '-x', '-N',
+ '-f', zc.buildout.easy_install._safe_arg(
+ ' '.join(self._links)
+ ),
+ '-d', zc.buildout.easy_install._safe_arg(
+ self['buildout']['develop-eggs-directory']
+ ),
{'PYTHONPATH':
os.path.dirname(pkg_resources.__file__)},
)
@@ -680,12 +687,6 @@
if verbosity:
options.append(('buildout', 'verbosity', str(verbosity)))
- try:
- buildout = Buildout(config_file, options)
- buildout._setup_logging()
- except UserError, v:
- _error(str(v))
-
if args:
command = args.pop(0)
if command not in ('install', 'bootstrap'):
@@ -695,6 +696,7 @@
try:
try:
+ buildout = Buildout(config_file, options)
getattr(buildout, command)(args)
except UserError, v:
_error(str(v))
Modified: zc.buildout/branches/win/src/zc/buildout/buildout.txt
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/buildout.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/buildout.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -11,7 +11,7 @@
buildout".
This document describes how to define buildouts using buildout
-configuration files and recipes. There are two ways to set up the
+configuration files and recipes. There are three ways to set up the
buildout software and create a buildout instance:
1. Install the zc.buildout egg with easy_install and use the buildout
@@ -23,6 +23,10 @@
The buildout script is installed into your buildout local scripts
area.
+3. Use a buildoput command from an already installed buildout to
+ bootstrap a new buildout. (See the section on bootstraping later
+ in this document.)
+
Often, a software project will be managed in a software repository,
such as a subversion repository, that includes some software source
directories, buildout configuration files, and a copy of the buildout
@@ -31,28 +35,27 @@
installs setuptools and zc.buildout into the checkout as well as any
parts defined.
-We have a sample buildout that has already been created for us. It
-has the absolute minimum information. We have bin, develop-eggs, eggs
-and parts directories, a configuration file, and an .installed.cfg
-that contains information about previously-installed parts:
+We have a sample buildout that we created using the bootstrap command
+of an existing buildout (method 3 above). It has the absolute minimum
+information. We have bin, develop-eggs, eggs and parts directories,
+and a configuration file:
>>> ls(sample_buildout)
- - .installed.cfg
d bin
- buildout.cfg
d develop-eggs
d eggs
d parts
-The bin directory contains scripts. In the examples shown here, we've
-used a hybrid approach for creating the buildout to ease automated
-setup. We have a buildout script in our buildout script directory,
-but the zc.buildout and setuptools eggs actually live elsewhere.
+The bin directory contains scripts.
>>> ls(sample_buildout, 'bin')
- buildout
+ - py-zc.buildout
>>> ls(sample_buildout, 'eggs')
+ - setuptools-0.6-py2.4.egg
+ - zc.buildout-1.0-py2.4.egg
The develop-eggs and parts directories are initially empty:
@@ -85,14 +88,6 @@
[buildout]
parts =
-The file .installed.cfg contains information about previously installed
-parts. Because this is a new buildout, this file isn't very
-interesting:
-
- >>> cat(sample_buildout, '.installed.cfg')
- [buildout]
- parts =
-
A part is simply something to be created by a buildout. It can be
almost anything, such as a Python package, a program, a directory, or
even a configuration file.
@@ -146,16 +141,19 @@
Any time we use data from another section, it is important to reflect
that data in the recipe's options when the recipe is constructed.
-When a buildout is run, it compares part-configuration data stored in
-the installed.cfg file and the part-configuration data loaded from the
-configuration files as modified by recipe constructors to decide if
-the configuration of a part has changed. If the configuration has
-changed, or if the recipe has changed, then the part is uninstalled
-before reinstalling it. The buildout only looks at the part's
-options, so any data used to configure the part needs to be reflected
-in the part's options. It is the job of a recipe constructor to make
-sure that the options include all rel event data.
+When buildout is run, it saves configuration data for installed parts
+in a file named installed.cfg. In subsequent runs, it compares
+part-configuration data stored in the installed.cfg file and the
+part-configuration data loaded from the configuration files as
+modified by recipe constructors to decide if the configuration of a
+part has changed. If the configuration has changed, or if the recipe
+has changed, then the part is uninstalled before reinstalling it. The
+buildout only looks at the part's options, so any data used to
+configure the part needs to be reflected in the part's options. It is
+the job of a recipe constructor to make sure that the options include
+all rel event data.
+
Of course, parts are also uninstalled if they are no-longer used.
The install method is responsible for creating the part. In this
@@ -284,8 +282,8 @@
d parts
d recipes
-In addition, .installed.cfg has been updated to reflect the part we
-installed:
+In addition, .installed.cfg has been created containing information
+about the part we installed:
>>> cat(sample_buildout, '.installed.cfg')
[buildout]
@@ -1193,17 +1191,11 @@
>>> ls(sample_bootstrapped, 'bin')
- buildout
- - py_zc.buildout
+ - py-zc.buildout
>>> ls(sample_bootstrapped, 'eggs')
- - setuptools-0.6b3-py2.3.egg
+ - setuptools-0.6-py2.3.egg
+ - zc.buildout-1.0-py2.3.egg
- >>> ls(sample_bootstrapped, 'develop-eggs')
- - zc.buildout.egg-link
-
-
-Note that, in this example, we were using a development egg for the
-buildout, and the zc.buildout egg ended up as an egg link.
-
-Also not that the buildout script was installed but not run. To run
+Note that the buildout script was installed but not run. To run
the buildout, we'd have to run the installed buildout script.
Modified: zc.buildout/branches/win/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/easy_install.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/easy_install.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -108,6 +108,19 @@
return None
+
+if sys.platform == 'win32':
+ # work around spawn lamosity on windows
+ # XXX need safe quoting (see the subproces.list2cmdline) and test
+ def _safe_arg(arg):
+ return '"%s"' % arg
+else:
+ _safe_arg = str
+
+_easy_install_cmd = _safe_arg(
+ 'from setuptools.command.easy_install import main; main()'
+ )
+
def _call_easy_install(spec, dest, links=(),
index = None,
executable=sys.executable,
@@ -115,11 +128,10 @@
):
prefix = sys.exec_prefix + os.path.sep
path = os.pathsep.join([p for p in sys.path if not p.startswith(prefix)])
- args = (
- '-c', 'from setuptools.command.easy_install import main; main()',
- '-mUNxd', dest)
+
+ args = ('-c', _easy_install_cmd, '-mUNxd', _safe_arg(dest))
if links:
- args += ('-f', ' '.join(links))
+ args += ('-f', _safe_arg(' '.join(links)))
if index:
args += ('-i', index)
if always_unzip:
@@ -135,7 +147,7 @@
if level <= logging.DEBUG:
logger.debug('Running easy_install:\n%s "%s"\npath=%s\n',
executable, '" "'.join(args), path)
-
+
args += (dict(os.environ, PYTHONPATH=path), )
sys.stdout.flush() # We want any pending output first
exit_code = os.spawnle(os.P_WAIT, executable, executable, *args)
@@ -244,9 +256,7 @@
def _editable(spec, dest, links=(), index = None, executable=sys.executable):
prefix = sys.exec_prefix + os.path.sep
path = os.pathsep.join([p for p in sys.path if not p.startswith(prefix)])
- args = (
- '-c', 'from setuptools.command.easy_install import main; main()',
- '-eb', dest)
+ args = ('-c', _easy_install_cmd, '-eb', _safe_arg(dest))
if links:
args += ('-f', ' '.join(links))
if index:
@@ -317,7 +327,8 @@
def scripts(reqs, working_set, executable, dest, scripts=None):
reqs = [pkg_resources.Requirement.parse(r) for r in reqs]
projects = [r.project_name for r in reqs]
- path = "',\n '".join([dist.location for dist in working_set])
+ path = repr([dist.location for dist in working_set])
+ path = path[1:-1].replace(',', ',\n ')
generated = []
for dist in working_set:
@@ -331,10 +342,12 @@
sname = name
sname = os.path.join(dest, sname)
- generated.append(sname)
- _script(dist, 'console_scripts', name, path, sname, executable)
+ generated.extend(
+ _script(dist, 'console_scripts', name, path, sname,
+ executable)
+ )
- name = 'py_'+dist.project_name
+ name = 'py-'+dist.project_name
if scripts is not None:
sname = scripts.get(name)
else:
@@ -342,13 +355,23 @@
if sname is not None:
sname = os.path.join(dest, sname)
- generated.append(sname)
- _pyscript(path, sname, executable)
+ generated.extend(
+ _pyscript(path, sname, executable)
+ )
return generated
def _script(dist, group, name, path, dest, executable):
entry_point = dist.get_entry_info(group, name)
+ generated = []
+ if sys.platform == 'win32':
+ # generate exe file and give the script a magic name:
+ open(dest+'.exe', 'wb').write(
+ pkg_resources.resource_string('setuptools', 'cli.exe')
+ )
+ generated.append(dest+'.exe')
+ dest += '-script.py'
+
open(dest, 'w').write(script_template % dict(
python = executable,
path = path,
@@ -361,13 +384,15 @@
os.chmod(dest, 0755)
except (AttributeError, os.error):
pass
+ generated.append(dest)
+ return generated
script_template = '''\
#!%(python)s
import sys
sys.path[0:0] = [
- '%(path)s'
+ %(path)s
]
import %(module_name)s
@@ -378,6 +403,15 @@
def _pyscript(path, dest, executable):
+ generated = []
+ if sys.platform == 'win32':
+ # generate exe file and give the script a magic name:
+ open(dest+'.exe', 'wb').write(
+ pkg_resources.resource_string('setuptools', 'cli.exe')
+ )
+ generated.append(dest+'.exe')
+ dest += '-script.py'
+
open(dest, 'w').write(py_script_template % dict(
python = executable,
path = path,
@@ -386,21 +420,36 @@
os.chmod(dest,0755)
except (AttributeError, os.error):
pass
+ generated.append(dest)
+ return generated
py_script_template = '''\
#!%(python)s
import sys
-
-if len(sys.argv) == 1:
- import os
- # Restart with -i
- os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
sys.path[0:0] = [
- '%(path)s'
+ %(path)s
]
-if len(sys.argv) > 1 and sys.argv[1:] != ['']:
- sys.argv[:] = sys.argv[1:]
- execfile(sys.argv[0])
+_interactive = True
+if len(sys.argv) > 1:
+ import getopt
+ _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _interactive = False
+ for (_opt, _val) in _options:
+ if _opt == '-i':
+ _interactive = True
+ elif _opt == '-c':
+ exec _val
+
+ if _args:
+ sys.argv[:] = _args
+ execfile(sys.argv[0])
+
+if _interactive:
+ import code
+ code.interact(banner="", local=globals())
'''
+
+
+
Modified: zc.buildout/branches/win/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/easy_install.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/easy_install.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -203,17 +203,28 @@
>>> ls(bin)
- demo
- - py_demo
+ - py-demo
The return value is a list of the scripts generated:
- >>> import os
- >>> scripts == [os.path.join(bin, 'demo'), os.path.join(bin, 'py_demo')]
+ >>> import os, sys
+ >>> if sys.platform == 'win32':
+ ... scripts == [os.path.join(bin, 'demo.exe'),
+ ... os.path.join(bin, 'demo-script.py'),
+ ... os.path.join(bin, 'py-demo.exe'),
+ ... os.path.join(bin, 'py-demo-script.py')]
+ ... else:
+ ... scripts == [os.path.join(bin, 'demo'),
+ ... os.path.join(bin, 'py-demo')]
True
The demo script run the entry point defined in the demo egg:
- >>> cat(bin, 'demo')
+ >>> if sys.platform == 'win32':
+ ... cat(bin, 'demo-script.py')
+ ... else:
+ ... cat(bin, 'demo')
+ ... # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.3
<BLANKLINE>
import sys
@@ -234,26 +245,40 @@
- The module for the script entry point is imported and the entry
point, in this case, 'main', is run.
-The py_demo script simply run the Python interactive interpreter with
+The py-demo script simply run the Python interactive interpreter with
the path set:
- >>> cat(bin, 'py_demo')
+ >>> if sys.platform == 'win32':
+ ... cat(bin, 'py-demo-script.py')
+ ... else:
+ ... cat(bin, 'py-demo')
+ ... # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4
import sys
<BLANKLINE>
- if len(sys.argv) == 1:
- import os
- # Restart with -i
- os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
- <BLANKLINE>
sys.path[0:0] = [
'/tmp/tmp5zS2Afsample-install/demo-0.3-py2.4.egg',
'/tmp/tmp5zS2Afsample-install/demoneeded-1.1-py2.4.egg'
]
<BLANKLINE>
- if len(sys.argv) > 1 and sys.argv[1:] != ['']:
- sys.argv[:] = sys.argv[1:]
- execfile(sys.argv[0])
+ _interactive = True
+ if len(sys.argv) > 1:
+ import getopt
+ _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _interactive = False
+ for (_opt, _val) in _options:
+ if _opt == '-i':
+ _interactive = True
+ elif _opt == '-c':
+ exec _val
+ <BLANKLINE>
+ if _args:
+ sys.argv[:] = _args
+ execfile(sys.argv[0])
+ <BLANKLINE>
+ if _interactive:
+ import code
+ code.interact(banner="", local=globals())
If invoked with a script name and arguments, it will run that script, instead.
@@ -264,7 +289,12 @@
>>> bin = mkdtemp()
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo==0.1'], ws, python2_4_executable, bin, dict(demo='run'))
- >>> scripts == [os.path.join(bin, 'run')]
+
+ >>> if sys.platform == 'win32':
+ ... scripts == [os.path.join(bin, 'run.exe'),
+ ... os.path.join(bin, 'run-script.py')]
+ ... else:
+ ... scripts == [os.path.join(bin, 'run')]
True
>>> ls(bin)
- run
Modified: zc.buildout/branches/win/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/testing.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/testing.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -23,6 +23,8 @@
from zope.testing import doctest, renormalizing
import pkg_resources
+import zc.buildout.buildout
+
def cat(dir, *names):
path = os.path.join(dir, *names)
print open(path).read(),
@@ -57,11 +59,10 @@
def get(url):
return urllib2.urlopen(url).read()
-def buildoutSetUp(test, clear_home=True):
- if clear_home:
- # we both need to make sure that HOME isn't set and be prepared
- # to restore whatever it was after the test.
- test.globs['_oldhome'] = os.environ.pop('HOME', None)
+def buildoutSetUp(test):
+ # we both need to make sure that HOME isn't set and be prepared
+ # to restore whatever it was after the test.
+ test.globs['_oldhome'] = os.environ.pop('HOME', None)
temporary_directories = []
def mkdtemp(*args):
@@ -70,30 +71,16 @@
return d
sample = mkdtemp('sample-buildout')
- for name in ('bin', 'eggs', 'develop-eggs', 'parts'):
- os.mkdir(os.path.join(sample, name))
- # make sure we can import zc.buildout and setuptools
- import zc.buildout, setuptools
-
- # Generate buildout script
- dest = os.path.join(sample, 'bin', 'buildout')
- open(dest, 'w').write(
- script_template % dict(python=sys.executable, path=sys.path)
- )
- try:
- os.chmod(dest, 0755)
- except (AttributeError, os.error):
- pass
-
-
+ # Create a basic buildout.cfg to avoid a warning from buildout:
open(os.path.join(sample, 'buildout.cfg'), 'w').write(
"[buildout]\nparts =\n"
)
- open(os.path.join(sample, '.installed.cfg'), 'w').write(
- "[buildout]\nparts =\n"
- )
+ # Use the buildout bootstrap command to create a buildout
+ zc.buildout.buildout.Buildout(os.path.join(sample, 'buildout.cfg'), ()
+ ).bootstrap([])
+
test.globs.update(dict(
__here = os.getcwd(),
sample_buildout = sample,
@@ -103,18 +90,17 @@
write = write,
system = system,
get = get,
- __original_wd__ = os.getcwd(),
__temporary_directories__ = temporary_directories,
__tearDown__ = [],
mkdtemp = mkdtemp,
))
def buildoutTearDown(test):
+ os.chdir(test.globs['__here'])
for d in test.globs['__temporary_directories__']:
shutil.rmtree(d)
for f in test.globs['__tearDown__']:
f()
- os.chdir(test.globs['__original_wd__'])
if test.globs.get('_oldhome') is not None:
os.environ['HOME'] = test.globs['_oldhome']
@@ -188,12 +174,45 @@
)
runsetup(sample, executable)
+def find_python(version):
+ e = os.environ.get('PYTHON%s' % version)
+ if e is not None:
+ return e
+ if sys.platform == 'win32':
+ e = '\Python%s%s\python.exe' % tuple(version.split('.'))
+ if os.path.exists(e):
+ return e
+ else:
+ i, o = os.popen4('python%s -c "import sys; print sys.executable"'
+ % version)
+ i.close()
+ e = o.read().strip()
+ o.close()
+ if os.path.exists(e):
+ return e
+ i, o = os.popen4(
+ 'python -c "import sys; print \'%s.%s\' % sys.version_info[:2]"'
+ )
+ i.close()
+ e = o.read().strip()
+ o.close()
+ if e == version:
+ i, o = os.popen4('python -c "import sys; print sys.executable"')
+ i.close()
+ e = o.read().strip()
+ o.close()
+ if os.path.exists(e):
+ return e
+
+ raise ValueError(
+ "Couldn't figure out the exectable for Python %(version)s.\n"
+ "Set the environment variable PYTHON%(version)s to the location\n"
+ "of the Python %(version)s executable before running the tests."
+ )
+
def multi_python(test):
- defaults = ConfigParser.RawConfigParser()
- defaults.readfp(open(os.path.join(os.environ['HOME'],
- '.buildout', 'default.cfg')))
- p23 = defaults.get('python2.3', 'executable')
- p24 = defaults.get('python2.4', 'executable')
+ p23 = find_python('2.3')
+ p24 = find_python('2.4')
create_sample_eggs(test, executable=p23)
create_sample_eggs(test, executable=p24)
test.globs['python2_3_executable'] = p23
@@ -205,7 +224,7 @@
#include <Python.h>
#include <extdemo.h>
-static PyMethodDef methods[] = {};
+static PyMethodDef methods[] = {NULL};
PyMODINIT_FUNC
initextdemo(void)
@@ -238,9 +257,14 @@
os.path.join(tmp, 'setup.py'), '-q', 'sdist')
os.chdir(here)
assert status == 0
+ if sys.platform == 'win32':
+ sname = 'extdemo-1.4.zip'
+ else:
+ sname = 'extdemo-1.4.tar.gz'
+
shutil.move(
- os.path.join(tmp, 'dist', 'extdemo-1.4.tar.gz'),
- os.path.join(test.globs['sample_eggs'], 'extdemo-1.4.tar.gz'),
+ os.path.join(tmp, 'dist', sname),
+ os.path.join(test.globs['sample_eggs'], sname),
)
def make_tree(test):
@@ -311,6 +335,8 @@
self.send_header('Content-Type', 'application/zip')
elif name.endswith('.gz'):
self.send_header('Content-Type', 'application/x-gzip')
+ elif name.endswith('.zip'):
+ self.send_header('Content-Type', 'application/x-gzip')
else:
self.send_header('Content-Type', 'text/html')
self.end_headers()
Modified: zc.buildout/branches/win/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/win/src/zc/buildout/tests.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/src/zc/buildout/tests.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -20,6 +20,10 @@
from zope.testing import doctest, renormalizing
import zc.buildout.testing
+os_path_sep = os.path.sep
+if os_path_sep == '\\':
+ os_path_sep *= 2
+
def buildout_error_handling():
r"""Buildout error handling
@@ -218,7 +222,7 @@
zc.buildout.testing.setUpServer(test, zc.buildout.testing.make_tree(test))
def easy_install_SetUp(test):
- zc.buildout.testing.buildoutSetUp(test, clear_home=False)
+ zc.buildout.testing.buildoutSetUp(test)
zc.buildout.testing.multi_python(test)
zc.buildout.testing.add_source_dist(test)
zc.buildout.testing.setUpServer(test, zc.buildout.testing.make_tree(test))
@@ -286,13 +290,18 @@
checker=renormalizing.RENormalizing([
(re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'),
- (re.compile('\S+sample-(\w+)%s(\S+)' % os.path.sep),
+ (re.compile('\S+sample-(\w+)%s(\S+)' % os_path_sep),
r'/sample-\1/\2'),
(re.compile('\S+sample-(\w+)'), r'/sample-\1'),
(re.compile('executable = \S+python\S*'),
'executable = python'),
(re.compile('setuptools-\S+[.]egg'), 'setuptools.egg'),
+ (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
+ 'zc.buildout.egg'),
(re.compile('creating \S*setup.cfg'), 'creating setup.cfg'),
+ (re.compile('(\n?)- ([a-zA-Z_.-]+)-script.py\n- \\2.exe\n'),
+ '\\1- \\2\n'),
+ (re.compile("(\w)%s(\w)" % os_path_sep), r"\1/\2"),
])
),
@@ -302,12 +311,20 @@
tearDown=zc.buildout.testing.buildoutTearDown,
checker=PythonNormalizing([
- (re.compile("'%(sep)s\S+sample-install%(sep)s(dist%(sep)s)?"
- % dict(sep=os.path.sep)),
+ (re.compile("'"
+ "(\w:)?"
+ "[%(sep)s/]\S+sample-install[%(sep)s/]"
+ "[%(sep)s/]?(dist"
+ "[%(sep)s/])?"
+ % dict(sep=os_path_sep)),
'/sample-eggs/'),
(re.compile("([d-] ((ext)?demo(needed)?|other)"
"-\d[.]\d-py)\d[.]\d(-[^. \t\n]+)?[.]egg"),
'\\1V.V.egg'),
+ (re.compile('(\n?)- ([a-zA-Z_.-]+)-script.py\n- \\2.exe\n'),
+ '\\1- \\2\n'),
+ (re.compile('extdemo-1[.]4[.]tar[.]gz'), 'extdemo-1.4.zip'),
+ (re.compile('#!\S+python\S+'), '#!python'),
]),
),
doctest.DocTestSuite(
Modified: zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/README.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/README.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -82,6 +82,8 @@
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demoneeded-1.1-py2.3.egg
+ - setuptools-0.6-py2.3.egg
+ - zc.buildout-1.0-py2.3.egg
We see that we got an egg for demo that met the requirement, as well
as the egg for demoneeded, wich demo requires. (We also see an egg
@@ -95,12 +97,13 @@
>>> ls(sample_buildout, 'bin')
- buildout
- demo
- - py_demo
+ - py-demo
+ - py-zc.buildout
Here, in addition to the buildout script, we see the demo script,
-demo, and we see a script, py_demo, for giving us a Python prompt with
+demo, and we see a script, py-demo, for giving us a Python prompt with
the path for demo and any eggs it depends on included in sys.path.
-This is useful for testing.
+This is useful for debugging and testing.
If we run the demo script, it prints out some minimal data:
@@ -113,14 +116,17 @@
We can also run the py_demo script. Here we'll just print out
the bits if the path added to reflect the eggs:
- >>> print system(os.path.join(sample_buildout, 'bin', 'py_demo'),
- ... """for p in sys.path[:2]:
- ... print p
+ >>> print system(os.path.join(sample_buildout, 'bin', 'py-demo'),
+ ... """import os, sys
+ ... for p in sys.path:
+ ... if 'demo' in p:
+ ... print os.path.basename(p)
+ ...
... """).replace('>>> ', '').replace('... ', ''),
... # doctest: +ELLIPSIS
+ demo-0.2-py2.4.egg
+ demoneeded-1.1-py2.4.egg
<BLANKLINE>
- /tmp/tmpcy8MvGbuildout-tests/eggs/demo-0.2-py2.3.egg
- /tmp/tmpcy8MvGbuildout-tests/eggs/demoneeded-1.0-py2.3.egg
<BLANKLINE>
The recipe gets the most recent distribution that satisfies the
@@ -145,6 +151,8 @@
- demo-0.2-py2.3.egg
- demo-0.3-py2.3.egg
- demoneeded-1.0-py2.3.egg
+ - setuptools-0.6-py2.4.egg
+ - zc.buildout-1.0-py2.4.egg
Note that we removed the eggs option, and the eggs
defaulted to the part name.
@@ -176,6 +184,7 @@
>>> ls(sample_buildout, 'bin')
- buildout
+ - py-zc.buildout
You can also control the name used for scripts:
@@ -196,6 +205,7 @@
>>> ls(sample_buildout, 'bin')
- buildout
- foo
+ - py-zc.buildout
Offline mode
------------
Modified: zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/api.txt
===================================================================
--- zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/api.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/api.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -6,10 +6,10 @@
recipe provides an API that other recipes can use.
A recipe can reuse the egg recipe, supporting the eggs, find-links,
-index, and pythonoptions. This is done by creating an egg
-recipe instance in a recipes's contructor. In the recipe's install
-script, the egg-recipe instance's working_set method to collect the
-requested eggs and working set.
+index, and python options. This is done by creating an egg recipe
+instance in a recipes's contructor. In the recipe's install script,
+the egg-recipe instance's working_set method is used to collect the
+requested eggs and working set.
To illustrate, we create a sample recipe that is a very thin layer
around the egg recipe:
@@ -53,6 +53,7 @@
... setup(
... name = "sample",
... entry_points = {'zc.buildout': ['default = sample:Sample']},
+ ... install_requires = 'zc.recipe.egg',
... )
... """)
@@ -95,6 +96,9 @@
[sample-part]
__buildout_installed__ =
__buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
+ zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==
+ setuptools-0.6-py2.4.egg
+ zc.buildout-+rYeCcmFuD1K/aB77XTj5A==
_b = /tmp/tmpb7kP9bsample-buildout/bin
_d = /tmp/tmpb7kP9bsample-buildout/develop-eggs
_e = /tmp/tmpb7kP9bsample-buildout/eggs
Modified: zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
===================================================================
--- zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -37,25 +37,17 @@
... parts = demo
... eggs-directory = eggs
...
+ ... [python2.3]
+ ... executable = %(python23)s
+ ...
... [demo]
... recipe = zc.recipe.egg
... eggs = demo <0.3
... find-links = %(server)s
... index = %(server)s/index
... python = python2.3
- ... """ % dict(server=link_server))
+ ... """ % dict(server=link_server, python23=python2_3_executable))
-In our default.cfg file in the .buildout subdirectiry of our
-directory, we have something like::
-
- [python2.3]
- executable = /usr/bin/python
-
- [python2.4]
- executable = /usr/local/bin/python2.4
-
-(Of course, the paths will vary from system to system.)
-
Now, if we run the buildout:
>>> import os
@@ -68,13 +60,20 @@
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demoneeded-1.1-py2.3.egg
+ - setuptools-0.6-py2.4.egg
+ - zc.buildout-1.0-py2.4.egg
And the generated scripts invoke Python 2.3:
- >>> f = open(os.path.join(sample_buildout, 'bin', 'demo'))
+ >>> import sys
+ >>> if sys.platform == 'win32':
+ ... script_name = 'demo-script.py'
+ ... else:
+ ... script_name = 'demo'
+ >>> f = open(os.path.join(sample_buildout, 'bin', script_name))
>>> f.readline().strip() == '#!' + python2_3_executable
True
- >>> print f.read(),
+ >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
@@ -87,26 +86,41 @@
if __name__ == '__main__':
eggrecipedemo.main()
- >>> f = open(os.path.join(sample_buildout, 'bin', 'py_demo'))
+ >>> if sys.platform == 'win32':
+ ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
+ ... else:
+ ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> f.readline().strip() == '#!' + python2_3_executable
True
- >>> print f.read(),
+ >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
import sys
<BLANKLINE>
- if len(sys.argv) == 1:
- import os
- # Restart with -i
- os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
- <BLANKLINE>
sys.path[0:0] = [
- '/tmp/tmpiIJY3Ysample-buildout/eggs/demo-0.2-py2.3.egg',
- '/tmp/tmpiIJY3Ysample-buildout/eggs/demoneeded-1.1-py2.3.egg'
+ '/tmp/tmp5zS2Afsample-buildout/eggs/demo-0.2-py2.3.egg',
+ '/tmp/tmp5zS2Afsample-buildout/eggs/demoneeded-1.1-py2.3.egg'
]
<BLANKLINE>
- if len(sys.argv) > 1 and sys.argv[1:] != ['']:
- sys.argv[:] = sys.argv[1:]
- execfile(sys.argv[0])
+ _interactive = True
+ if len(sys.argv) > 1:
+ import getopt
+ _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _interactive = False
+ for (_opt, _val) in _options:
+ if _opt == '-i':
+ _interactive = True
+ elif _opt == '-c':
+ exec _val
+ <BLANKLINE>
+ if _args:
+ sys.argv[:] = _args
+ execfile(sys.argv[0])
+ <BLANKLINE>
+ if _interactive:
+ import code
+ code.interact(banner="", local=globals())
+ >>> f.close()
+
If we change the Python version to 2.4, we'll use Python 2.4 eggs:
>>> write(sample_buildout, 'buildout.cfg',
@@ -121,7 +135,11 @@
... find-links = %(server)s
... index = %(server)s/index
... python = python2.4
- ... """ % dict(server=link_server))
+ ...
+ ... [python2.4]
+ ... executable = %(python24)s
+ ...
+ ... """ % dict(server=link_server, python24=python2_4_executable))
>>> print system(buildout),
@@ -130,11 +148,16 @@
- demo-0.2-py2.4.egg
- demoneeded-1.1-py2.3.egg
- demoneeded-1.1-py2.4.egg
+ - setuptools-0.6-py2.4.egg
+ - zc.buildout-1.0-py2.4.egg
- >>> f = open(os.path.join(sample_buildout, 'bin', 'demo'))
+ >>> if sys.platform == 'win32':
+ ... f = open(os.path.join(sample_buildout, 'bin', 'demo-script.py'))
+ ... else:
+ ... f = open(os.path.join(sample_buildout, 'bin', 'demo'))
>>> f.readline().strip() == '#!' + python2_4_executable
True
- >>> print f.read(),
+ >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
@@ -147,22 +170,39 @@
if __name__ == '__main__':
eggrecipedemo.main()
- >>> f = open(os.path.join(sample_buildout, 'bin', 'py_demo'))
+ >>> f.close()
+
+ >>> if sys.platform == 'win32':
+ ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
+ ... else:
+ ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> f.readline().strip() == '#!' + python2_4_executable
True
- >>> print f.read(),
+ >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
import sys
<BLANKLINE>
- if len(sys.argv) == 1:
- import os
- # Restart with -i
- os.execl(sys.executable, sys.executable, '-i', sys.argv[0], '')
- <BLANKLINE>
sys.path[0:0] = [
- '/tmp/tmpiIJY3Ysample-buildout/eggs/demo-0.2-py2.4.egg',
- '/tmp/tmpiIJY3Ysample-buildout/eggs/demoneeded-1.1-py2.4.egg'
+ '/tmp/tmp5zS2Afsample-buildout/eggs/demo-0.2-py2.4.egg',
+ '/tmp/tmp5zS2Afsample-buildout/eggs/demoneeded-1.1-py2.4.egg'
]
<BLANKLINE>
- if len(sys.argv) > 1 and sys.argv[1:] != ['']:
- sys.argv[:] = sys.argv[1:]
- execfile(sys.argv[0])
+ _interactive = True
+ if len(sys.argv) > 1:
+ import getopt
+ _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _interactive = False
+ for (_opt, _val) in _options:
+ if _opt == '-i':
+ _interactive = True
+ elif _opt == '-c':
+ exec _val
+ <BLANKLINE>
+ if _args:
+ sys.argv[:] = _args
+ execfile(sys.argv[0])
+ <BLANKLINE>
+ if _interactive:
+ import code
+ code.interact(banner="", local=globals())
+
+ >>> f.close()
Modified: zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/tests.py
===================================================================
--- zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/tests.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.egg_/src/zc/recipe/egg/tests.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -18,6 +18,10 @@
import unittest
from zope.testing import doctest, renormalizing
+os_path_sep = os.path.sep
+if os_path_sep == '\\':
+ os_path_sep *= 2
+
def dirname(d, level=1):
if level == 0:
return d
@@ -33,7 +37,7 @@
def setUpPython(test):
- zc.buildout.testing.buildoutSetUp(test, clear_home=False)
+ zc.buildout.testing.buildoutSetUp(test)
open(os.path.join(test.globs['sample_buildout'],
'develop-eggs', 'zc.recipe.egg.egg-link'),
@@ -61,10 +65,14 @@
checker=renormalizing.RENormalizing([
(re.compile('(\S+[/%(sep)s]| )'
'(\\w+-)[^ \t\n%(sep)s/]+.egg'
- % dict(sep=os.path.sep)
+ % dict(sep=os_path_sep)
),
'\\2-VVV-egg'),
(re.compile('-py\d[.]\d.egg'), '-py2.4.egg'),
+ (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
+ 'zc.buildout.egg'),
+ (re.compile('(\n?)- ([a-zA-Z_.-]+)-script.py\n- \\2.exe\n'),
+ '\\1- \\2\n'),
])
),
doctest.DocFileSuite(
@@ -73,8 +81,13 @@
checker=renormalizing.RENormalizing([
(re.compile('_b = \S+sample-buildout.bin'),
'_b = sample-buildout/bin'),
- (re.compile('__buildout_signature__ = \S+'),
- '__buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ=='),
+ (re.compile('__buildout_signature__ = '
+ 'sample-\S+\s+'
+ 'zc.recipe.egg-\S+\s+'
+ 'setuptools-\S+\s+'
+ 'zc.buildout-\S+\s*'
+ ),
+ '__buildout_signature__ = sample- zc.recipe.egg-'),
(re.compile('_d = \S+sample-buildout.develop-eggs'),
'_d = sample-buildout/develop-eggs'),
(re.compile('_e = \S+sample-buildout.eggs'),
@@ -93,9 +106,14 @@
'selecting-python.txt',
setUp=setUpPython, tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
- (re.compile('\S+sample-(\w+)%s(\S+)' % os.path.sep),
+ (re.compile('\S+sample-(\w+)[%(sep)s/](\S+)'
+ % dict(sep=os_path_sep)),
r'/sample-\1/\2'),
(re.compile('\S+sample-(\w+)'), r'/sample-\1'),
+ (re.compile('- ([a-zA-Z_0-9.]+)(-\S+)?[.]egg(-link)?'),
+ '\\1.egg'),
+ (re.compile(r'\\\\'), '/'),
+ (re.compile(r'/\\'), '/'),
]),
),
doctest.DocFileSuite(
@@ -105,6 +123,7 @@
(re.compile("(d ((ext)?demo(needed)?|other)"
"-\d[.]\d-py)\d[.]\d(-[^. \t\n]+)?[.]egg"),
'\\1V.V.egg'),
+ (re.compile('extdemo.c\n.+\\extdemo.exp\n'), ''),
]),
),
Modified: zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt 2006-08-27 15:39:55 UTC (rev 69799)
@@ -129,6 +129,7 @@
>>> ls(sample_buildout, 'bin')
- buildout
+ - py-zc.buildout
- test
We can run the test script to run our demo test:
@@ -163,6 +164,7 @@
>>> ls(sample_buildout, 'bin')
- buildout
+ - py-zc.buildout
- testdemo
We can run the test script to run our demo test:
Modified: zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -32,7 +32,6 @@
)
self.egg = zc.recipe.egg.Egg(buildout, name, options)
-
def install(self):
options = self.options
requirements, ws = self.egg.working_set(('zope.testing', ))
@@ -46,31 +45,43 @@
locations = [dist.location for dist in ws
if dist.project_name in project_names]
+ result = []
script = options['script']
+ if sys.platform == 'win32':
+ # generate exe file and give the script a magic name:
+ open(script+'.exe', 'wb').write(
+ pkg_resources.resource_string('setuptools', 'cli.exe')
+ )
+ result.append(script+'.exe')
+ script += '-script.py'
+
open(script, 'w').write(tests_template % dict(
PYTHON=options['executable'],
- PATH="',\n '".join(path),
- TESTPATH="',\n '--test-path', '".join(locations),
+ PATH=repr(path)[1:-1].replace(', ', ',\n '),
+ TESTPATH=repr(locations)[1:-1].replace(
+ ', ', ",\n '--test-path', "),
))
try:
os.chmod(script, 0755)
except (AttributeError, os.error):
pass
- return script
+ result.append(script)
+ return result
+
tests_template = """#!%(PYTHON)s
import sys
sys.path[0:0] = [
- '%(PATH)s',
+ %(PATH)s,
]
from zope.testing import testrunner
defaults = [
- '--test-path', '%(TESTPATH)s',
+ '--test-path', %(TESTPATH)s,
]
sys.exit(testrunner.run(defaults))
Modified: zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/tests.py
===================================================================
--- zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/tests.py 2006-08-27 14:19:31 UTC (rev 69798)
+++ zc.buildout/branches/win/zc.recipe.testrunner/src/zc/recipe/testrunner/tests.py 2006-08-27 15:39:55 UTC (rev 69799)
@@ -19,7 +19,7 @@
import unittest
import zope.testing
-from zope.testing import doctest
+from zope.testing import doctest, renormalizing
def dirname(d, level=1):
if level == 0:
@@ -50,6 +50,10 @@
doctest.DocFileSuite(
'README.txt',
setUp=setUp, tearDown=tearDown,
+ checker=renormalizing.RENormalizing([
+ (re.compile('(\n?)- ([a-zA-Z_.-]+)-script.py\n- \\2.exe\n'),
+ '\\1- \\2\n'),
+ ])
),
))
More information about the Checkins
mailing list