diff Mac/Tools/pythonw.c @ 77154:294f8aeb4d4b

Implemented PEP 405 (Python virtual environments).
author Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Sat, 26 May 2012 03:45:29 +0100
parents 81d7f78a633a
children c96dd645825e
line wrap: on
line diff
--- a/Mac/Tools/pythonw.c	Sat May 26 03:25:23 2012 +0100
+++ b/Mac/Tools/pythonw.c	Sat May 26 03:45:29 2012 +0100
@@ -150,6 +150,18 @@
 int
 main(int argc, char **argv) {
     char* exec_path = get_python_path();
+    static char path[PATH_MAX * 2];
+    static char real_path[PATH_MAX * 2];
+    int status;
+    uint32_t size = PATH_MAX * 2;
+
+    /* Set the original executable path in the environment. */
+    status = _NSGetExecutablePath(path, &size);
+    if (status == 0) {
+        if (realpath(path, real_path) != NULL) {
+            setenv("__PYTHONV_LAUNCHER__", real_path, 1);
+        }
+    }
 
     /*
      * Let argv[0] refer to the new interpreter. This is needed to