How to import rlib in an rpython program to be translated using pypy's rpython
I am trying to do some file io in a program to be compiled with pypy's translate tool. Since open and os.open are not supported, I need rlib.streamio. I tried to do import rlib
but it gives the following error
[translation:ERROR] ImportError': import statement always raises [type ImportError开发者_如何学编程: 'No module named rlib']
I translate using
$ ./pypy-1.4.1-src/pypy/translator/goal/translate.py myScript.py
How do I import rlib in myScript.py?
It's
from pypy.rlib import streamio
So it seems that pypy's translate looks for modules in the path of script (or installed modules), rather than its own system. Once I copied rlib into the current directory, I could compile it. I just had to
$ cp -r pypy-1.4.1-src/pypy/rlib .
Then
$ ./pypy-1.4.1-src/pypy/translator/goal/translate.py myScript.py
compiled successfully.
精彩评论