Author: mattip <[email protected]>
Branch: run-create_cffi_imports
Changeset: r78246:c537451c6156
Date: 2015-06-22 22:14 +0300
http://bitbucket.org/pypy/pypy/changeset/c537451c6156/
Log: create_cffi_import_libraries does not raise rather indicates which
imports failed
diff --git a/pypy/goal/targetpypystandalone.py
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -315,7 +315,7 @@
@taskdef(['compile_c'], "Create cffi bindings for modules")
def task_build_cffi_imports(self):
- from pypy.tool.build_cffi_imports import
create_cffi_import_libraries, MissingDependenciesError
+ from pypy.tool.build_cffi_imports import
create_cffi_import_libraries
''' Use cffi to compile cffi interfaces to modules'''
exename = mkexename(driver.compute_exe_name())
basedir = exename
@@ -328,10 +328,8 @@
modules = self.config.objspace.usemodules.getpaths()
options = Options()
# XXX possibly adapt options using modules
- try:
- create_cffi_import_libraries(exename, options, basedir)
- except MissingDependenciesError:
- pass
+ failures = create_cffi_import_libraries(exename, options, basedir)
+ # if failures, they were already printed
driver.task_build_cffi_imports =
types.MethodType(task_build_cffi_imports, driver)
driver.tasks['build_cffi_imports'] = driver.task_build_cffi_imports,
['compile_c']
driver.default_goal = 'build_cffi_imports'
diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py
--- a/pypy/tool/build_cffi_imports.py
+++ b/pypy/tool/build_cffi_imports.py
@@ -19,6 +19,7 @@
def create_cffi_import_libraries(pypy_c, options, basedir):
shutil.rmtree(str(basedir.join('lib_pypy', '__pycache__')),
ignore_errors=True)
+ failures = []
for key, module in sorted(cffi_build_scripts.items()):
if module is None or getattr(options, 'no_' + key, False):
continue
@@ -30,17 +31,17 @@
cwd = None
print >> sys.stderr, '*', ' '.join(args)
try:
- results = run_subprocess(str(pypy_c), args, cwd=cwd)
+ status, stdout, stderr = run_subprocess(str(pypy_c), args, cwd=cwd)
+ if status != 0:
+ print >> sys.stderr, stdout, stderr
+ failures.append((key, module))
except:
import traceback;traceback.print_exc()
- print >>sys.stderr, """!!!!!!!!!!\nBuilding {0} bindings failed.
-You can either install development headers package,
-add the --without-{0} option to skip packaging this
-binary CFFI extension, or say --without-cffi.""".format(key)
- raise MissingDependenciesError(module)
+ failures.append((key, module))
+ return failures
if __name__ == '__main__':
- import py
+ import py, os
if '__pypy__' not in sys.builtin_module_names:
print 'Call with a pypy interpreter'
sys.exit(-1)
@@ -57,4 +58,18 @@
str(exename))
basedir = _basedir
options = Options()
- create_cffi_import_libraries(exename, options, basedir)
+ print >> sys.stderr, "There should be no failures here"
+ failures = create_cffi_import_libraries(exename, options, basedir)
+ if len(failures) > 0:
+ print 'failed to build', [f[1] for f in failures]
+ assert False
+
+ # monkey patch a failure, just to test
+ print >> sys.stderr, 'This line should be followed by a traceback'
+ for k in cffi_build_scripts:
+ setattr(options, 'no_' + k, True)
+ must_fail = '_missing_build_script.py'
+ assert not os.path.exists(str(basedir.join('lib_pypy').join(must_fail)))
+ cffi_build_scripts['should_fail'] = must_fail
+ failures = create_cffi_import_libraries(exename, options, basedir)
+ assert len(failures) == 1
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -81,9 +81,13 @@
if not _fake and not pypy_runs(pypy_c):
raise OSError("Running %r failed!" % (str(pypy_c),))
if not options.no_cffi:
- try:
- create_cffi_import_libraries(pypy_c, options, basedir)
- except MissingDependenciesError:
+ failures = create_cffi_import_libraries(pypy_c, options, basedir)
+ for key, module in failures:
+ print >>sys.stderr, """!!!!!!!!!!\nBuilding {0} bindings failed.
+ You can either install development headers package,
+ add the --without-{0} option to skip packaging this
+ binary CFFI extension, or say --without-cffi.""".format(key)
+ if len(failures) > 0:
return 1, None
if sys.platform == 'win32' and not rename_pypy_c.lower().endswith('.exe'):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit