[pypy-commit] pypy default: Tweak the build_cffi_imports output: clarify the status in case of
arigo
pypy.commits at gmail.com
Tue Sep 27 05:27:12 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r87412:70287b5cb024
Date: 2016-09-27 11:26 +0200
http://bitbucket.org/pypy/pypy/changeset/70287b5cb024/
Log: Tweak the build_cffi_imports output: clarify the status in case of
errors, remove any message in case everything works, and make sure
we get the same explanations when running rpython from the Makefile
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -40,4 +40,4 @@
# http://lists.gnu.org/archive/html/help-make/2010-08/msg00106.html
cffi_imports: pypy-c
- PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py
+ PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py || /bin/true
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -303,37 +303,20 @@
# HACKHACKHACK
# ugly hack to modify target goal from compile_* to build_cffi_imports
# this should probably get cleaned up and merged with driver.create_exe
+ from rpython.tool.runsubprocess import run_subprocess
from rpython.translator.driver import taskdef
import types
- class Options(object):
- pass
-
-
- def mkexename(name):
- if sys.platform == 'win32':
- name = name.new(ext='exe')
- return name
-
compile_goal, = driver.backend_select_goals(['compile'])
@taskdef([compile_goal], "Create cffi bindings for modules")
def task_build_cffi_imports(self):
- 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
- while not basedir.join('include').exists():
- _basedir = basedir.dirpath()
- if _basedir == basedir:
- raise ValueError('interpreter %s not inside pypy repo',
- str(exename))
- basedir = _basedir
- modules = self.config.objspace.usemodules.getpaths()
- options = Options()
- # XXX possibly adapt options using modules
- failures = create_cffi_import_libraries(exename, options, basedir)
- # if failures, they were already printed
- print >> sys.stderr, str(exename),'successfully built (errors, if any, while building the above modules are ignored)'
+ filename = os.path.join(pypydir, 'tool', 'build_cffi_imports.py')
+ status, out, err = run_subprocess(str(driver.compute_exe_name()),
+ [filename])
+ sys.stdout.write(out)
+ sys.stderr.write(err)
+ # otherwise, ignore errors
driver.task_build_cffi_imports = types.MethodType(task_build_cffi_imports, driver)
driver.tasks['build_cffi_imports'] = driver.task_build_cffi_imports, [compile_goal]
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
@@ -44,8 +44,8 @@
if __name__ == '__main__':
import py, os
if '__pypy__' not in sys.builtin_module_names:
- print 'Call with a pypy interpreter'
- sys.exit(-1)
+ print >> sys.stderr, 'Call with a pypy interpreter'
+ sys.exit(1)
class Options(object):
pass
@@ -59,18 +59,26 @@
str(exename))
basedir = _basedir
options = Options()
- 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]
+ print >> sys.stderr, '*** failed to build the CFFI modules %r' % (
+ [f[1] for f in failures],)
+ print >> sys.stderr, '''
+PyPy can still be used as long as you don't need the corresponding
+modules. If you do need them, please install the missing headers and
+libraries (see error messages just above) and then re-run the command:
+
+ %s %s
+''' % (sys.executable, ' '.join(sys.argv))
sys.exit(1)
- # 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
+ if len(sys.argv) > 1 and sys.argv[1] == '--test':
+ # 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
More information about the pypy-commit
mailing list