[pypy-svn] r20645 - in pypy/dist/pypy: bin translator/goal
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 4 18:24:43 CET 2005
Author: arigo
Date: Sun Dec 4 18:24:42 2005
New Revision: 20645
Modified:
pypy/dist/pypy/bin/py.py
pypy/dist/pypy/translator/goal/app_main.py
Log:
Insert the dir of the script in sys.path[0]. Thanks Seo.
This initialization is rather messy at the moment, it will
need a good refactoring at one point...
Modified: pypy/dist/pypy/bin/py.py
==============================================================================
--- pypy/dist/pypy/bin/py.py (original)
+++ pypy/dist/pypy/bin/py.py Sun Dec 4 18:24:42 2005
@@ -100,6 +100,9 @@
def doit():
main.run_string(Options.command[0], space=space)
elif args:
+ scriptdir = os.path.dirname(os.path.abspath(args[0]))
+ space.call_method(space.sys.get('path'), 'insert',
+ space.wrap(0), space.wrap(scriptdir))
def doit():
main.run_file(args[0], space=space)
else:
Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py (original)
+++ pypy/dist/pypy/translator/goal/app_main.py Sun Dec 4 18:24:42 2005
@@ -173,6 +173,10 @@
exec cmd in mainmodule.__dict__
run_toplevel(run_it)
else:
+ import os
+ # XXX resolve symlinks
+ scriptdir = os.path.dirname(os.path.abspath(sys.argv[0]))
+ sys.path.insert(0, scriptdir)
run_toplevel(execfile, sys.argv[0], mainmodule.__dict__)
else:
go_interactive = True
More information about the Pypy-commit
mailing list