[pypy-svn] r48265 - pypy/dist/pypy/translator/goal

arigo at codespeak.net arigo at codespeak.net
Sat Nov 3 09:18:11 CET 2007


Author: arigo
Date: Sat Nov  3 09:18:10 2007
New Revision: 48265

Modified:
   pypy/dist/pypy/translator/goal/app_main.py
Log:
This is supposedly the official way to know if we are running on NT or
Posix.  Althought I cannot find right now the code in PyPy that would
expose 'module/posix' under the name 'nt' I guess it must be done
somewhere - otherwise tons of things would break on NT.

The previous code was also untested (i.e. broken) on non-NT platforms.
There are still 3 failures in test2/test_app_main.py but I don't have
time to investigate now.


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	Sat Nov  3 09:18:10 2007
@@ -233,25 +233,19 @@
 
 AUTOSUBPATH = 'share' + os.sep + 'pypy-%d.%d'
 
-# hack to determine if we are on windows. Maybe there is a better way...
-DRIVE_LETTER_SEP = ''
-try:
-    here = os.getcwd()
-    try:
-        os.chdir('C:')
-        DRIVE_LETTER_SEP = ':'
-    finally:
-        os.chdir(here)
-except os.OSError:
-    DRIVE_LETTER_SEP = None
-IS_WINDOWS = DRIVE_LETTER_SEP is not None
-# XXX extend here
+if 'nt' in sys.builtin_module_names:
+    IS_WINDOWS = True
+    DRIVE_LETTER_SEP = ':'
+else:
+    IS_WINDOWS = False
 
 def entry_point(executable, argv):
     # find the full path to the executable, assuming that if there is no '/'
     # in the provided one then we must look along the $PATH
     os.setup() # this is the faked one
-    if os.sep not in executable and DRIVE_LETTER_SEP not in executable:
+    if os.sep in executable or (IS_WINDOWS and DRIVE_LETTER_SEP in executable):
+        pass    # the path is already more than just an executable name
+    else:
         path = os.getenv('PATH')
         if path:
             for dir in path.split(os.pathsep):



More information about the Pypy-commit mailing list