Commits

Anonymous committed af7588c

#343 applied patch for AIX support

  • Participants
  • Parent commits 9a13c4c
  • Branches 1.5

Comments (0)

Files changed (11)

         """
 
         if target_platform.startswith("linux") or \
-            target_platform.startswith('sun'):
+            target_platform.startswith("sun"):
             names = ('libpython%d.%d.so' % sys.version_info[:2],) 
+        elif target_platform.startswith("aix"): \
+            # Shared libs on AIX are archives with shared object members, thus the ".a" suffix.
+            names = ('libpython%d.%d.a' % sys.version_info[:2],) 
         elif target_platform.startswith("darwin"):
             names = ('Python', 'libpython%d.%d.dylib' % sys.version_info[:2])
         else:
         name = names[0]
 
         if target_platform.startswith("linux") or \
-            target_platform.startswith('sun'):
+            target_platform.startswith("sun") or \
+            target_platform.startswith("aix"):
             lib = bindepend.findLibrary(name)
             if lib is None:
                 raise IOError("Python library not found!")
 def test_TCL_TK(config):
     # TCL_root, TK_root and support/useTK.py
     print "I: Finding TCL/TK..."
+
+    if target_platform.startswith("win"):
+        pattern = r'(?i)tcl(\d\d)\.dll'
+    elif (target_platform.startswith("linux") or
+        target_platform.startswith('sun') or
+        target_platform.startswith("aix")):
+        pattern = r'libtcl(\d\.\d)?\.so'
+    elif target_platform.startswith("darwin"):
+        pattern = r'_tkinter'
+    else:
+        # If no pattern is in place for this platform, skip TCL/TK detection.
+        print "I: ... skipping TCL/TK detection on this target platform (%s)" % target_platform
+        return
+
     if not (target_iswin):
         saveexcludes = bindepend.excludes
         bindepend.excludes = {}
 
-    if target_platform.startswith("win"):
-        pattern = r'(?i)tcl(\d\d)\.dll'
-    elif target_platform.startswith("linux") or \
-        target_platform.startswith('sun'):
-        pattern = r'libtcl(\d\.\d)?\.so'
-    elif target_platform.startswith("darwin"):
-        pattern = r'_tkinter'
-
     a = mf.ImportTracker()
     a.analyze_r('Tkinter')
     binaries = []
     except ImportError, detail:
         winresource = None
 
-excludes = {
-    'KERNEL32.DLL':1,
-    'ADVAPI.DLL':1,
-    'MSVCRT.DLL':1,
-    'ADVAPI32.DLL':1,
-    'COMCTL32.DLL':1,
-    'CRTDLL.DLL':1,
-    'GDI32.DLL':1,
-    'MFC42.DLL':1,
-    'NTDLL.DLL':1,
-    'OLE32.DLL':1,
-    'OLEAUT32.DLL':1,
-    'RPCRT4.DLL':1,
-    'SHELL32.DLL':1,
-    'USER32.DLL':1,
-    'WINSPOOL.DRV':1,
-    'WS2HELP.DLL':1,
-    'WS2_32.DLL':1,
-    'WSOCK32.DLL':1,
-    'MSWSOCK.DLL':1,
-    'WINMM.DLL':1,
-    'COMDLG32.DLL':1,
-##    'ZLIB.DLL':1,   # test with python 1.5.2
-    'ODBC32.DLL':1,
-    'VERSION.DLL':1,
-    'IMM32.DLL':1,
-    'DDRAW.DLL':1,
-    'DCIMAN32.DLL':1,
-    'OPENGL32.DLL':1,
-    'GLU32.DLL':1,
-    'GLUB32.DLL':1,
-    'NETAPI32.DLL':1,
-    'MSCOREE.DLL':1,
-    'PSAPI.DLL':1,
-    'MSVCP80.DLL':1,
-    'MSVCR80.DLL':1,
-    'MSVCP90.DLL':1,
-    'MSVCR90.DLL':1,
-    'IERTUTIL.DLL':1,
-    'POWRPROF.DLL':1,
-    'SHLWAPI.DLL':1,
-    'URLMON.DLL':1,
-    'MSIMG32.DLL':1,
-    'MPR.DLL':1,
-    'DNSAPI.DLL':1,
-    'RASAPI32.DLL':1,
-    # regex excludes
-    r'/libc\.so\..*':1,
-    r'/libdl\.so\..*':1,
-    r'/libm\.so\..*':1,
-    r'/libpthread\.so\..*':1,
-    r'/librt\.so\..*':1,
-    r'/libthread_db\.so\..*':1,
-    r'/libdb-.*\.so':1,
-    # glibc regex excludes
-    r'/ld-linux\.so\..*':1,
-    r'/libBrokenLocale\.so\..*':1,
-    r'/libanl\.so\..*':1,
-    r'/libcidn\.so\..*':1,
-    r'/libcrypt\.so\..*':1,
-    r'/libnsl\.so\..*':1,
-    r'/libnss_compat.*\.so\..*':1,
-    r'/libnss_dns.*\.so\..*':1,
-    r'/libnss_files.*\.so\..*':1,
-    r'/libnss_hesiod.*\.so\..*':1,
-    r'/libnss_nis.*\.so\..*':1,
-    r'/libnss_nisplus.*\.so\..*':1,
-    r'/libresolv\.so\..*':1,
-    r'/libutil\.so\..*':1,
-    # libGL can reference some hw specific libraries (like nvidia libs)
-    r'/libGL\..*':1,
-    # MS assembly excludes
-    'Microsoft.Windows.Common-Controls':1,
-}
+if sys.platform.startswith('aix'):
+    excludes = {
+        r'/libbz2\.a':1,
+        r'/libc\.a':1,
+        r'/libC\.a':1,
+        r'/libcrypt\.a':1,
+        r'/libdl\.a':1,
+        r'/libintl\.a':1,
+        r'/libpthreads\.a':1,
+        r'/librt\\.a':1,
+        r'/librtl\.a':1,
+        r'/libz\.a':1,
+    }
+else:
+    excludes = {
+        'KERNEL32.DLL':1,
+        'ADVAPI.DLL':1,
+        'MSVCRT.DLL':1,
+        'ADVAPI32.DLL':1,
+        'COMCTL32.DLL':1,
+        'CRTDLL.DLL':1,
+        'GDI32.DLL':1,
+        'MFC42.DLL':1,
+        'NTDLL.DLL':1,
+        'OLE32.DLL':1,
+        'OLEAUT32.DLL':1,
+        'RPCRT4.DLL':1,
+        'SHELL32.DLL':1,
+        'USER32.DLL':1,
+        'WINSPOOL.DRV':1,
+        'WS2HELP.DLL':1,
+        'WS2_32.DLL':1,
+        'WSOCK32.DLL':1,
+        'MSWSOCK.DLL':1,
+        'WINMM.DLL':1,
+        'COMDLG32.DLL':1,
+    ##    'ZLIB.DLL':1,   # test with python 1.5.2
+        'ODBC32.DLL':1,
+        'VERSION.DLL':1,
+        'IMM32.DLL':1,
+        'DDRAW.DLL':1,
+        'DCIMAN32.DLL':1,
+        'OPENGL32.DLL':1,
+        'GLU32.DLL':1,
+        'GLUB32.DLL':1,
+        'NETAPI32.DLL':1,
+        'MSCOREE.DLL':1,
+        'PSAPI.DLL':1,
+        'MSVCP80.DLL':1,
+        'MSVCR80.DLL':1,
+        'MSVCP90.DLL':1,
+        'MSVCR90.DLL':1,
+        'IERTUTIL.DLL':1,
+        'POWRPROF.DLL':1,
+        'SHLWAPI.DLL':1,
+        'URLMON.DLL':1,
+        'MSIMG32.DLL':1,
+        'MPR.DLL':1,
+        'DNSAPI.DLL':1,
+        'RASAPI32.DLL':1,
+        # regex excludes
+        r'/libc\.so\..*':1,
+        r'/libdl\.so\..*':1,
+        r'/libm\.so\..*':1,
+        r'/libpthread\.so\..*':1,
+        r'/librt\.so\..*':1,
+        r'/libthread_db\.so\..*':1,
+        r'/libdb-.*\.so':1,
+        # glibc regex excludes
+        r'/ld-linux\.so\..*':1,
+        r'/libBrokenLocale\.so\..*':1,
+        r'/libanl\.so\..*':1,
+        r'/libcidn\.so\..*':1,
+        r'/libcrypt\.so\..*':1,
+        r'/libnsl\.so\..*':1,
+        r'/libnss_compat.*\.so\..*':1,
+        r'/libnss_dns.*\.so\..*':1,
+        r'/libnss_files.*\.so\..*':1,
+        r'/libnss_hesiod.*\.so\..*':1,
+        r'/libnss_nis.*\.so\..*':1,
+        r'/libnss_nisplus.*\.so\..*':1,
+        r'/libresolv\.so\..*':1,
+        r'/libutil\.so\..*':1,
+        # libGL can reference some hw specific libraries (like nvidia libs)
+        r'/libGL\..*':1,
+        # MS assembly excludes
+        'Microsoft.Windows.Common-Controls':1,
+    }
 
 # Darwin has a stable ABI for applications, so there is no need
 # to include either /usr/lib nor system frameworks.
 
         This implementation is for ldd platforms"""
     rslt = []
+    if sys.platform.startswith('aix'):
+        # Match libs of the form 'archive.a(sharedobject.so)'
+        # Will not match the fake lib '/unix'
+        lddPattern = re.compile(r"\s+(.*?)(\(.*\))")
+    else:
+        lddPattern = re.compile(r"\s+(.*?)\s+=>\s+(.*?)\s+\(.*\)")
+
     for line in os.popen('ldd "%s"' % pth).readlines():
-        m = re.search(r"\s+(.*?)\s+=>\s+(.*?)\s+\(.*\)", line)
+        m = lddPattern.search(line)
         if m:
-            name, lib = m.group(1), m.group(2)
+            if sys.platform.startswith('aix'):
+                lib = m.group(1)
+                name = os.path.basename(lib) + m.group(2)
+            else:
+                name, lib = m.group(1), m.group(2)
             if name[:10] in ('linux-gate', 'linux-vdso'):
                 # linux-gate is a fake library which does not exist and
                 # should be ignored. See also:
                 # http://www.trilithium.com/johan/2005/08/linux-gate/
                 continue
+
             if os.path.exists(lib):
-                rslt.append(lib)
+                # Add lib if it is not already found.
+                # (Should use set() instead of list but that is not in Python 2.2.)
+                if lib not in rslt:
+                    rslt.append(lib)
             else:
                 print 'E: cannot find %s in path %s (needed by %s)' % \
                       (name, lib, pth)
 
     `name`must include the prefix, e.g. ``libpython2.4.so``
     """
-    assert sys.platform == 'linux2' or sys.platform.startswith('sunos'), \
-        "Current implementation for Linux and Solaris (sunos) only"
+    "Current implementation for Linux, Solaris (sunos) and AIX only"
+    assert (sys.platform == 'linux2' or
+           sys.platform.startswith('sunos') or
+           sys.platform.startswith('aix'))
 
     lib = None
 
 
     # Look in the known safe paths
     if lib is None:
-        for path in ['/lib', '/usr/lib']:
+        paths = ['/lib', '/usr/lib']
+        if sys.platform.startswith('aix'):
+          paths.append('/opt/freeware/lib')
+        for path in paths:
             libs = glob(os.path.join(path, name + '*'))
             if libs:
                 lib = libs[0]
 
 Changes since PyInstaller 1.5.1
 -----------------------------
+ + Added experimental support for AIX (thanks to Martin Gamwell Dawids).
  + Added experimental support for Solaris (thanks to Hywel Richards).
 
 Changes since PyInstaller 1.5

source/common/launch.c

 #include <sys/stat.h>
 #include "launch.h"
 #include "zlib.h"
-/* On Solaris is missing function 'mkdtemp'. */
-#ifdef SUNOS
+
+/*
+ * Function 'mkdtemp' (make temporary directory) is missing on some *NIX platforms: 
+ * - On Solaris function 'mkdtemp' is missing.
+ * - On AIX 5.2 function 'mkdtemp' is missing. It is there in version 6.1 but we don't know
+ *   the runtime platform at compile time, so we always include our own implementation on AIX.
+ */
+#if defined(SUNOS) || defined(AIX)
 #include "mkdtemp.h"
 #endif
 
 {
 	HINSTANCE dll;
 	char dllpath[_MAX_PATH + 1];
+    int dlopenMode = RTLD_NOW | RTLD_GLOBAL;
 
 #ifdef WIN32
 	/* Determine the path */
 	mapNames(dll);
 #else
 
+    uint32_t pyvers_major;
+    uint32_t pyvers_minor;
+    const char* dllPathPrefix;
+    
+    pyvers_major = ntohl(f_cookie.pyvers) / 10;
+    pyvers_minor = ntohl(f_cookie.pyvers) % 10;
+    dllPathPrefix = f_workpath ? f_workpath : f_homepath;
+
 	/* Determine the path */
 #ifdef __APPLE__
 	struct stat sbuf;
 
-	sprintf(dllpath, "%sPython",
-		f_workpath ? f_workpath : f_homepath);
+	sprintf(dllpath, "%sPython", dllPathPrefix);
 	/* Workaround for virtualenv: it renames the Python framework. */
 	/* A proper solution would be to let Build.py found out the correct
 	 * name and embed it in the PKG as metadata. */
 	if (stat(dllpath, &sbuf) < 0) {
-		sprintf(dllpath, "%s.Python",
-			f_workpath ? f_workpath : f_homepath);
+		sprintf(dllpath, "%s.Python", dllPathPrefix);
         
         if(stat(dllpath, &sbuf) < 0) {
             /* Python might be compiled as a .dylib (using --enable-shared) so lets try that one */
             sprintf(dllpath, "%slibpython%01d.%01d.dylib",
-                    f_workpath ? f_workpath : f_homepath,
-                    ntohl(f_cookie.pyvers) / 10, ntohl(f_cookie.pyvers) % 10);
+                    dllPathPrefix,
+                    pyvers_major, pyvers_minor);
         }
     }
 #else
+
+#ifdef AIX
+    /* On AIX 'ar' archives are used for both static and shared object.
+     * To load a shared object from a library, it should be loaded like this:
+     *   dlopen("libpython2.6.a(libpython2.6.so)", RTLD_MEMBER)
+     */
+     sprintf(dllpath, "%slibpython%01d.%01d.a(libpython%01d.%01d.so)",
+             dllPathPrefix,
+             pyvers_major, pyvers_minor,
+             pyvers_major, pyvers_minor);
+     dlopenMode |= RTLD_MEMBER;
+#else
 	sprintf(dllpath, "%slibpython%01d.%01d.so.1.0",
-		f_workpath ? f_workpath : f_homepath,
-		ntohl(f_cookie.pyvers) / 10, ntohl(f_cookie.pyvers) % 10);
+		dllPathPrefix,
+		pyvers_major, pyvers_minor);
+#endif /* AIX */
+
 #endif
 
 	/* Load the DLL */
-	dll = dlopen(dllpath, RTLD_NOW|RTLD_GLOBAL);
+	dll = dlopen(dllpath, dlopenMode);
 	if (dll) {
 		VS("%s\n", dllpath);
 	}

source/linux/main.c

         /* run the "child" process, then clean up */
         setenv("_MEIPASS2", workpath, 1);
 
+#ifdef AIX
+        /* prepend workpath to LIBPATH on AIX */
+        exportWorkpath(workpath, "LIBPATH");
+#else
         /* add workpath to LD_LIBRARY_PATH */
         exportWorkpath(workpath, "LD_LIBRARY_PATH");
 #ifdef __APPLE__
         /* add workpath to DYLD_LIBRARY_PATH */
         exportWorkpath(workpath, "DYLD_LIBRARY_PATH");
-#endif
+#endif /* __APPLE__ */
+#endif /* AIX */
         pid = fork();
         if (pid == 0)
             execvp(thisfile, argv);
     if myplatform.startswith('sun'):
         conf.env.append_value('CCDEFINES', 'SUNOS')
 
+    if myplatform.startswith('aix'):
+        conf.env.append_value('CCDEFINES', 'AIX')
+
     conf.env.append_value('CPPPATH', '../common')
 
 

support/loader/Linux-32bit/run

Binary file modified.

support/loader/Linux-32bit/run_d

Binary file modified.

support/loader/Linux-32bit/runw

Binary file modified.

support/loader/Linux-32bit/runw_d

Binary file modified.