[pypy-svn] r23930 - pypy/dist/pypy/translator/llvm
rxe at codespeak.net
rxe at codespeak.net
Thu Mar 2 19:47:42 CET 2006
Author: rxe
Date: Thu Mar 2 19:47:38 2006
New Revision: 23930
Modified:
pypy/dist/pypy/translator/llvm/buildllvm.py
pypy/dist/pypy/translator/llvm/genllvm.py
Log:
Use isolate to import modules (and run tests).
Modified: pypy/dist/pypy/translator/llvm/buildllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/buildllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/buildllvm.py Thu Mar 2 19:47:38 2006
@@ -142,21 +142,11 @@
fdump.close()
log.build(data)
raise
- # XXX do we need to do some check on fout/ferr?
- # XXX not a nice way to import a module
- if pyxfile:
- log.build("inserting path to sys.path", dirpath)
- sys.path.insert(0, '.')
- cmd = "import %(modname)s as testmodule" % locals()
- log.build(cmd)
- exec cmd
- sys.path.pop(0)
finally:
os.chdir(str(lastdir))
if pyxfile:
- log.build("modname", modname)
- return testmodule
+ return modname, str(dirpath)
if exe_name:
exe_path = str(llvmfile.dirpath().join(exe_name))
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Thu Mar 2 19:47:38 2006
@@ -1,5 +1,7 @@
import time
+from pypy.tool import isolate
+
from pypy.translator.llvm import buildllvm
from pypy.translator.llvm.database import Database
from pypy.translator.llvm.pyxwrapper import write_pyx_wrapper
@@ -249,15 +251,20 @@
basename = self.filename.purebasename + '_wrapper' + postfix + '.pyx'
pyxfile = self.filename.new(basename = basename)
write_pyx_wrapper(self, pyxfile)
- res = buildllvm.make_module_from_llvm(self, self.filename,
- pyxfile=pyxfile,
- optimize=optimize)
- wrap_fun = getattr(res, 'pypy_' + self.entry_func_name + "_wrapper")
+ info = buildllvm.make_module_from_llvm(self, self.filename,
+ pyxfile=pyxfile,
+ optimize=optimize)
+
+ mod, wrap_fun = self.isolate_module(*info)
if return_fn:
return wrap_fun
+ return mod, wrap_fun
- return res, wrap_fun
-
+ def isolate_module(self, modname, dirpath):
+ ext_module = isolate.Isolate((dirpath, modname))
+ wrap_fun = getattr(ext_module, 'pypy_' + self.entry_func_name + "_wrapper")
+ return ext_module, wrap_fun
+
def _checkpoint(self, msg=None):
if not self.logging:
return
@@ -319,7 +326,3 @@
if view or conftest.option.view:
t.view()
return genllvm(t, function, optimize=optimize, **kwds)
-
-def compile_function(function, annotation, **kwds):
- """ Helper - which get the compiled module from CPython. """
- return compile_module(function, annotation, return_fn=True, **kwds)
More information about the Pypy-commit
mailing list