aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-05-03 09:53:16 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-05-03 08:59:52 +0000
commitc192b9fdbd19e3538924aa6e25e95298f937d445 (patch)
treed8ae25815bca726dcb2a91fe66234f079d0d9280 /setup.py
parent8db4d8ef585e5e3b41bf68ab76bfe9f936606da5 (diff)
Fix Python libraries to be found for macOS Python 2.6 interpreter
Change-Id: I0dbd65a23bde599f923811c74d0565f329116c93 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py58
1 files changed, 40 insertions, 18 deletions
diff --git a/setup.py b/setup.py
index fdaec4a50..070929ffc 100644
--- a/setup.py
+++ b/setup.py
@@ -585,33 +585,55 @@ class pyside_build(_build):
# be built with a non-debug Python.
lib_exts = [dbgPostfix + e for e in lib_exts] + lib_exts
+ python_library_found = False
libs_tried = []
for lib_ext in lib_exts:
lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext)
py_library = os.path.join(py_libdir, lib_name)
if os.path.exists(py_library):
+ python_library_found = True
break
libs_tried.append(py_library)
else:
- py_multiarch = get_config_var("MULTIARCH")
- if py_multiarch:
- try_py_libdir = os.path.join(py_libdir, py_multiarch)
- libs_tried = []
- for lib_ext in lib_exts:
- lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext)
- py_library = os.path.join(try_py_libdir, lib_name)
- if os.path.exists(py_library):
- py_libdir = try_py_libdir
- break
- libs_tried.append(py_library)
+ # At least on macOS 10.11, the system Python 2.6 does not include a symlink
+ # to the framework file disguised as a .dylib file, thus finding the library would
+ # fail. Manually check if a framework file "Python" exists in the Python framework
+ # bundle.
+ if sys.platform == 'darwin' and sys.version_info[:2] == (2, 6):
+ # These manipulations essentially transform
+ # /System/Library/Frameworks/Python.framework/Versions/2.6/lib
+ # to /System/Library/Frameworks/Python.framework/Versions/2.6/Python
+ possible_framework_path = os.path.realpath(os.path.join(py_libdir, '..'))
+ possible_framework_version = os.path.basename(possible_framework_path)
+ possible_framework_library = os.path.join(possible_framework_path, 'Python')
+
+ if possible_framework_version == '2.6' \
+ and os.path.exists(possible_framework_library):
+ py_library = possible_framework_library
+ python_library_found = True
else:
- raise DistutilsSetupError(
- "Failed to locate the Python library with %s" %
- ', '.join(libs_tried))
- else:
- raise DistutilsSetupError(
- "Failed to locate the Python library with %s" %
- ', '.join(libs_tried))
+ libs_tried.append(possible_framework_library)
+
+ # Try to find shared libraries which have a multi arch suffix.
+ if not python_library_found:
+ py_multiarch = get_config_var("MULTIARCH")
+ if py_multiarch and not python_library_found:
+ try_py_libdir = os.path.join(py_libdir, py_multiarch)
+ libs_tried = []
+ for lib_ext in lib_exts:
+ lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext)
+ py_library = os.path.join(try_py_libdir, lib_name)
+ if os.path.exists(py_library):
+ py_libdir = try_py_libdir
+ python_library_found = True
+ break
+ libs_tried.append(py_library)
+
+ if not python_library_found:
+ raise DistutilsSetupError(
+ "Failed to locate the Python library with %s" %
+ ', '.join(libs_tried))
+
if py_library.endswith('.a'):
# Python was compiled as a static library
log.error("Failed to locate a dynamic Python library, using %s"