python - Create pypy process -


i create process runs pypy. tried following , works:

import os os.chdir('<path-to-pypy-download>/bin/') os.execl('pypy', 'pypy', '-c', 'print "hi!"') 

however, when remove chdir as:

import os os.execl('<path-to-pypy-download>/bin/pypy', 'pypy', '-c', 'print "hi!"') 

i get:

debug: warning: library path not found, using compiled-in sys.path. debug: warning: 'sys.prefix' not set. debug: warning: make sure pypy binary kept inside tree of files. debug: warning: ok create symlink somewhere else. debug: operationerror: debug:  operror-type: importerror debug:  operror-value: no module named os 

please, know how spawn pypy process without changing working directory?

this may not correct (in case i'll delete it), i'm pretty sure need is:

os.execl('<path-to-pypy-download>/bin/pypy',           '<path-to-pypy-download>/bin/pypy', '-c', 'print "hi!"') 

in other words, pass full path arg0 path.

why? well, when pypy starts up, it's got using (the rpython/compiled-to-c equivalent of) sys.argv[0] find path custom stdlib. else use? of course copied char *argv[] argument passed interpreter's main function. when let os launch program you, put full path in there. when explicitly set execl, copy whatever gave it.

it's bit more complicated this—it readlink (to allow symlinks) , abspath (to allow run relative path—as in first example). basic idea same.

as side note, might want consider using fully-installed pypy instead of run-out-of-build-tree pypy, in case sys.prefix set won't need this.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -