From 86c93395802081bdc8c7bcee679412a8b81c468d Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Fri, 10 Jan 2014 06:56:34 +0800 Subject: [PATCH] distutils: fix build_ext check to find whether we're building Python or not The build_ext logic uses sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")) to determine whether we're building a third-party Python extension, or a built-in Python extension. However, this check is wrong in cross-compilation mode, because the host Python interpreter might very well be installed in its prefix, when it is used to cross-compile the target modules and extensions. The current check would mis-detect this as we're building third-party Python modules, while we are in fact building the internal Python modules of the target Python. Therefore, use the existing sysconfig.python_build variable, which provides the information of whether we're building Python itself or not in a correct way. Signed-off-by: Thomas Petazzoni --- Lib/distutils/command/build_ext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index 9be5923..ab020da 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -246,7 +246,7 @@ class build_ext(Command): # Python's library directory must be appended to library_dirs # See Issues: #1600860, #4366 if (sysconfig.get_config_var('Py_ENABLE_SHARED')): - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + if not sysconfig.python_build: # building third party extensions self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) else: -- 1.8.3.2