Commits

Anthony Tuininga committed c050483

Improved support for Mac OS X.

Comments (0)

Files changed (1)

cx_Freeze/freezer.py

             systemDir = cx_Freeze.util.GetSystemDir()
             windowsDir = cx_Freeze.util.GetWindowsDir()
             return [windowsDir, systemDir, os.path.join(windowsDir, "WinSxS")]
+        elif sys.platform == "darwin":
+            return ["/lib", "/usr/lib", "/System/Library/Frameworks"]
         else:
             return ["/lib", "/lib32", "/lib64", "/usr/lib", "/usr/lib32",
                     "/usr/lib64"]
                 os.environ["PATH"] = origPath
             else:
                 dependentFiles = []
-                for line in os.popen('ldd "%s"' % path):
-                    parts = line.expandtabs().strip().split(" => ")
+                if sys.platform == "darwin":
+                    command = 'otool -L "%s"' % path
+                    splitString = " (compatibility"
+                    dependentFileIndex = 0
+                else:
+                    command = 'ldd "%s"' % path
+                    splitString = " => "
+                    dependentFileIndex = 1
+                for line in os.popen(command):
+                    parts = line.expandtabs().strip().split(splitString)
                     if len(parts) != 2:
                         continue
-                    dependentFile = parts[1].strip()
+                    dependentFile = parts[dependentFileIndex].strip()
                     if dependentFile in ("not found", "(file not found)"):
                         fileName = parts[0]
-                        if fileName not in self.lddWarnings:
-                            self.lddWarnings[fileName] = None
+                        if fileName not in self.linkerWarnings:
+                            self.linkerWarnings[fileName] = None
                             message = "WARNING: cannot find %s\n" % fileName
                             sys.stdout.write(message)
                         continue
         self.excludeModules = {}
         self.dependentFiles = {}
         self.filesCopied = {}
-        self.lddWarnings = {}
+        self.linkerWarnings = {}
         import cx_Freeze.util
         cx_Freeze.util.SetOptimizeFlag(self.optimizeFlag)
         if self.createLibraryZip: