[Checkins] SVN: zc.buildout/branches/help-api/ - Tracebacks are now printed for internal errors (as opposed to user
Godefroid Chapelle
gotcha at bubblenet.be
Sun Mar 29 17:23:09 EDT 2009
Log message for revision 98522:
- Tracebacks are now printed for internal errors (as opposed to user
errors) even without the -D option.
- pyc and pyo files are regenerated for installed eggs so that the
stored path in code objects matches the the install location.
Changed:
U zc.buildout/branches/help-api/CHANGES.txt
U zc.buildout/branches/help-api/src/zc/buildout/buildout.py
U zc.buildout/branches/help-api/src/zc/buildout/buildout.txt
U zc.buildout/branches/help-api/src/zc/buildout/easy_install.py
U zc.buildout/branches/help-api/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/branches/help-api/CHANGES.txt
===================================================================
--- zc.buildout/branches/help-api/CHANGES.txt 2009-03-29 21:23:02 UTC (rev 98521)
+++ zc.buildout/branches/help-api/CHANGES.txt 2009-03-29 21:23:09 UTC (rev 98522)
@@ -4,12 +4,18 @@
Change History
**************
-1.1 (unreleased)
-==================
+1.1 (2008-07-19)
+================
- Added a buildout-level unzip option tp change the default policy for
unzipping zip-safe eggs.
+- Tracebacks are now printed for internal errors (as opposed to user
+ errors) even without the -D option.
+
+- pyc and pyo files are regenerated for installed eggs so that the
+ stored path in code objects matches the the install location.
+
1.0.6 (2008-06-13)
==================
Modified: zc.buildout/branches/help-api/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/buildout.py 2009-03-29 21:23:02 UTC (rev 98521)
+++ zc.buildout/branches/help-api/src/zc/buildout/buildout.py 2009-03-29 21:23:09 UTC (rev 98522)
@@ -1343,9 +1343,6 @@
_internal_error_template = """
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
-
-%s:
-%s
"""
def _check_for_unused_options_in_section(buildout, section):
@@ -1356,11 +1353,6 @@
% (section, ' '.join(map(repr, unused)))
)
-def _internal_error(v):
- sys.stderr.write(_internal_error_template % (v.__class__.__name__, v))
- sys.exit(1)
-
-
_usage = """\
Usage: buildout [options] [assignments] [command [command arguments]]
@@ -1569,9 +1561,9 @@
pass
except Exception, v:
_doing()
+ exc_info = sys.exc_info()
+ import pdb, traceback
if debug:
- exc_info = sys.exc_info()
- import pdb, traceback
traceback.print_exception(*exc_info)
sys.stderr.write('\nStarting pdb:\n')
pdb.post_mortem(exc_info[2])
@@ -1582,7 +1574,10 @@
):
_error(str(v))
else:
- _internal_error(v)
+ sys.stderr.write(_internal_error_template)
+ traceback.print_exception(*exc_info)
+ sys.exit(1)
+
finally:
logging.shutdown()
Modified: zc.buildout/branches/help-api/src/zc/buildout/buildout.txt
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/buildout.txt 2009-03-29 21:23:02 UTC (rev 98521)
+++ zc.buildout/branches/help-api/src/zc/buildout/buildout.txt 2009-03-29 21:23:09 UTC (rev 98522)
@@ -449,7 +449,7 @@
... path = foo bin
... """)
- >>> print system(buildout),
+ >>> print system(buildout), # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Installing data-dir.
@@ -460,9 +460,9 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
- <BLANKLINE>
- OSError:
- [Errno 17] File exists: '/sample-buildout/bin'
+ Traceback (most recent call last):
+ ...
+ OSError: [Errno 17] File exists: '/sample-buildout/bin'
We meant to create a directory bins, but typed bin. Now foo was
left behind.
@@ -483,7 +483,7 @@
... path = foo bins
... """)
- >>> print system(buildout),
+ >>> print system(buildout), # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Installing data-dir.
data-dir: Creating directory foo
@@ -492,9 +492,9 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
- <BLANKLINE>
- OSError:
- [Errno 17] File exists: '/sample-buildout/foo'
+ Traceback (most recent call last):
+ ...
+ OSError: [Errno 17] File exists: '/sample-buildout/foo'
Now they fail because foo exists, because it was left behind.
@@ -559,7 +559,7 @@
When we rerun the buildout:
- >>> print system(buildout),
+ >>> print system(buildout), # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Installing data-dir.
data-dir: Creating directory foo
@@ -569,9 +569,9 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
- <BLANKLINE>
- OSError:
- [Errno 17] File exists: '/sample-buildout/bin'
+ Traceback (most recent call last):
+ ...
+ OSError: [Errno 17] File exists: '/sample-buildout/bin'
we get the same error, but we don't get the directory left behind:
@@ -635,7 +635,7 @@
If we rerun the buildout, again, we'll get the error and no
directories will be created:
- >>> print system(buildout),
+ >>> print system(buildout), # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Installing data-dir.
data-dir: Creating directory foo
@@ -645,9 +645,9 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
- <BLANKLINE>
- OSError:
- [Errno 17] File exists: '/sample-buildout/bin'
+ Traceback (most recent call last):
+ ...
+ OSError: [Errno 17] File exists: '/sample-buildout/bin'
>>> os.path.exists('foo')
False
Modified: zc.buildout/branches/help-api/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/easy_install.py 2009-03-29 21:23:02 UTC (rev 98521)
+++ zc.buildout/branches/help-api/src/zc/buildout/easy_install.py 2009-03-29 21:23:09 UTC (rev 98522)
@@ -20,13 +20,22 @@
$Id$
"""
-import glob, logging, os, re, shutil, sys, tempfile, urlparse, zipimport
import distutils.errors
+import glob
+import logging
+import os
import pkg_resources
+import py_compile
+import re
+import setuptools.archive_util
import setuptools.command.setopt
import setuptools.package_index
-import setuptools.archive_util
+import shutil
+import sys
+import tempfile
+import urlparse
import zc.buildout
+import zipimport
_oprp = getattr(os.path, 'realpath', lambda path: path)
def realpath(path):
@@ -570,6 +579,7 @@
if ws.find(requirement) is None:
for dist in self._get_dist(requirement, ws, False):
ws.add(dist)
+ redo_pyc(dist.location)
def _constrain(self, requirement):
@@ -607,6 +617,7 @@
for requirement in requirements:
for dist in self._get_dist(requirement, ws, self._always_unzip):
ws.add(dist)
+ redo_pyc(dist.location)
self._maybe_add_setuptools(ws, dist)
# OK, we have the requested distributions and they're in the working
@@ -633,6 +644,7 @@
):
ws.add(dist)
+ redo_pyc(dist.location)
self._maybe_add_setuptools(ws, dist)
except pkg_resources.VersionConflict, err:
raise VersionConflict(err, ws)
@@ -696,6 +708,9 @@
base, pkg_resources.WorkingSet(),
self._dest, dist)
+ for dist in dists:
+ redo_pyc(dist.location)
+
return [dist.location for dist in dists]
finally:
shutil.rmtree(build_tmp)
@@ -1087,3 +1102,37 @@
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
+
+def redo_pyc(egg):
+ if not os.path.isdir(egg):
+ return
+ for dirpath, dirnames, filenames in os.walk(egg):
+ for filename in filenames:
+ if not filename.endswith('.py'):
+ continue
+ filepath = os.path.join(dirpath, filename)
+ if not (os.path.exists(filepath+'c')
+ or os.path.exists(filepath+'o')):
+ # If it wasn't compiled, it may not be compilable
+ continue
+
+ # OK, it looks like we should try to compile.
+
+ # Remove old files.
+ for suffix in 'co':
+ if os.path.exists(filepath+suffix):
+ os.remove(filepath+suffix)
+
+ # Compile under current optimization
+ try:
+ py_compile.compile(filepath)
+ except py_compile.PyCompileError:
+ logger.warning("Couldn't compile %s", filepath)
+ else:
+ # Recompile under other optimization. :)
+ args = [sys.executable]
+ if __debug__:
+ args.append('-O')
+ args.extend(['-m', 'py_compile', filepath])
+ os.spawnv(os.P_WAIT, sys.executable, args)
+
Modified: zc.buildout/branches/help-api/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/tests.py 2009-03-29 21:23:02 UTC (rev 98521)
+++ zc.buildout/branches/help-api/src/zc/buildout/tests.py 2009-03-29 21:23:09 UTC (rev 98522)
@@ -1769,7 +1769,7 @@
... recipe = recipes:mkdir
... ''')
- >>> print system(buildout),
+ >>> print system(buildout), # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
While:
Installing.
@@ -1778,9 +1778,9 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
- <BLANKLINE>
- NameError:
- global name 'os' is not defined
+ Traceback (most recent call last):
+ ...
+ NameError: global name 'os' is not defined
"""
def whine_about_unused_options():
@@ -2222,7 +2222,7 @@
... recipe = zc.buildout.testexit
... ''')
- >>> call(buildout) # doctest: +NORMALIZE_WHITESPACE
+ >>> call(buildout) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Develop: '/sample-buildout/.'
While:
Installing.
@@ -2232,12 +2232,13 @@
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
+ Traceback (most recent call last):
+ ...
+ x y
+ ^
+ SyntaxError: invalid syntax
<BLANKLINE>
- SyntaxError:
- invalid syntax (testexitrecipe.py, line 2)
- <BLANKLINE>
Exit: True
-
"""
def bug_59270_recipes_always_start_in_buildout_dir():
@@ -2813,6 +2814,43 @@
"""
+def pyc_and_pyo_files_have_correct_paths():
+ r"""
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... parts = eggs
+ ... find-links = %(link_server)s
+ ... unzip = true
+ ...
+ ... [eggs]
+ ... recipe = zc.recipe.egg
+ ... eggs = demo
+ ... interpreter = py
+ ... ''' % globals())
+
+ >>> _ = system(buildout)
+
+ >>> write('t.py',
+ ... '''
+ ... import eggrecipedemo, eggrecipedemoneeded
+ ... print eggrecipedemo.main.func_code.co_filename
+ ... print eggrecipedemoneeded.f.func_code.co_filename
+ ... ''')
+
+ >>> print system(join('bin', 'py')+ ' t.py'),
+ /sample-buildout/eggs/demo-0.4c1-py2.4.egg/eggrecipedemo.py
+ /sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg/eggrecipedemoneeded.py
+
+ >>> ls('eggs', 'demoneeded-1.2c1-py2.4.egg')
+ d EGG-INFO
+ - eggrecipedemoneeded.py
+ - eggrecipedemoneeded.pyc
+ - eggrecipedemoneeded.pyo
+
+ """
+
######################################################################
def create_sample_eggs(test, executable=sys.executable):
@@ -2823,7 +2861,7 @@
write(tmp, 'README.txt', '')
for i in (0, 1, 2):
- write(tmp, 'eggrecipedemoneeded.py', 'y=%s\n' % i)
+ write(tmp, 'eggrecipedemoneeded.py', 'y=%s\ndef f():\n pass' % i)
c1 = i==2 and 'c1' or ''
write(
tmp, 'setup.py',
More information about the Checkins
mailing list