Commits

Ronald Oussoren  committed c9643fb

Fix for issue #10: --alias builds for plugins didn't work.

This patch by Virgil Dupras fixes alias builds for
plugin bundles.

  • Participants
  • Parent commits cb10ddb

Comments (0)

Files changed (10)

File doc/changelog.rst

 
 Bug fixes:
 
+- The ``--alias`` option didn't work when building a plugin
+  bundle (issue #10, fix by Virgil Dupras)
+
 - Avoid copying the __pycache__ directory in python versions
   that implement PEP 3147 (Python 3.2 and later)
 

File py2app/bundletemplate/prebuilt/main-fat

Binary file modified.

File py2app/bundletemplate/prebuilt/main-fat3

Binary file modified.

File py2app/bundletemplate/prebuilt/main-i386

Binary file modified.

File py2app/bundletemplate/prebuilt/main-intel

Binary file modified.

File py2app/bundletemplate/prebuilt/main-ppc

Binary file modified.

File py2app/bundletemplate/prebuilt/main-ppc64

Binary file modified.

File py2app/bundletemplate/prebuilt/main-universal

Binary file modified.

File py2app/bundletemplate/prebuilt/main-x86_64

Binary file modified.

File py2app/bundletemplate/src/main.m

 typedef PyObject *(*PyModule_AddObjectPtr)(PyObject *, char *, PyObject *);
 typedef PyObject *(*PyModule_GetDictPtr)(PyObject *);
 typedef void (*PyObject_SetItemPtr)(PyObject *, PyObject *, PyObject *);
-typedef void (*Py_SetPythonHomePtr)(wchar_t *);
 
 //
 // Signatures
     return mainPyPath;
 }
 
-int is_ascii_string(const char *s)
-{
-    size_t len = strlen(s);
-    int i;
-    for (i=0; i<len; i++) {
-        unsigned char c = s[i];
-        if (c > 0x7f) {
-            return 0;
-        }
+static
+BOOL getPyOption(NSDictionary *infoDictionary, NSString *optionName) {
+    NSDictionary *pyOptions = [infoDictionary objectForKey:@"PyOptions"];
+    NSNumber *optionAsNumber = [pyOptions objectForKey:optionName];
+    if (optionAsNumber == nil) {
+        return NO;
     }
-    return 1;
+    return [optionAsNumber boolValue];
 }
 
 int pyobjc_main(int argc, char * const *argv, char * const *envp) {
     LOOKUP(PyModule_AddObject);
     LOOKUP(PyModule_GetDict);
     LOOKUP(PyThreadState_Swap);
-    LOOKUP(Py_SetPythonHome);
     
     /* PyBytes / PyString lookups depend of if we're on py3k or not */
     PyBytes_AsStringPtr PyBytes_AsString = NULL;
     if (!was_initialized) {
         // $PREFIX/Python -> $PREFIX
         NSString *pythonProgramName = [pyLocation stringByDeletingLastPathComponent];
-
-	setenv("PYTHONHOME", [resourcePath fileSystemRepresentation], 1);
-
+        if (!getPyOption(infoDictionary, @"alias")) {
+            setenv("PYTHONHOME", [resourcePath fileSystemRepresentation], 1);
+        }
+        
         NSString *pyExecutableName = [infoDictionary objectForKey:@"PyExecutableName"];
         if ( !pyExecutableName ) {
             pyExecutableName = @"python";
             mbstowcs(wPythonName, [pythonProgramName fileSystemRepresentation], PATH_MAX+1);
         }
         else {
-            // Same as Py_SetPythonHome
             const char *cPythonName = [pythonProgramName fileSystemRepresentation];
             memcpy(wPythonName, cPythonName, strlen(cPythonName));
         }