From 6b4feceaafdeeaa62642d8852b6c831cf21530f3 Mon Sep 17 00:00:00 2001 From: Benedikt Morbach Date: Sun, 8 Sep 2013 17:03:21 +0200 Subject: [PATCH] make sure to pass '-L.' when building standard extensions Organization: Chocolate Cookie Conspiracy The previous check fails to pass '-L.' when cross compiling, because the build-platform's 'python' executable is used. It also failed to pass the 'LIBDIR' to third-party extensions, when the interpreter was called e.g. via a symlink (see bug #16326) For this check to break, you have to do something stupid like build/symlink your own python in $PWD --- Lib/distutils/command/build_ext.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index a6aad53..ba192a9 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -233,26 +233,26 @@ class build_ext(Command): # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + if sys.executable.startswith(os.getcwd()): + # building python standard extensions + self.library_dirs.append('.') + else: # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", "python" + get_python_version(), "config")) - else: - # building python standard extensions - self.library_dirs.append('.') # for extensions under Linux or Solaris with a shared Python library, # Python's library directory must be appended to library_dirs sysconfig.get_config_var('Py_ENABLE_SHARED') if (sys.platform.startswith(('linux', 'gnu', 'sunos')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): - # building third party extensions - self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) - else: + if sys.executable.startswith(os.getcwd()): # building python standard extensions self.library_dirs.append('.') + else: + # building third party extensions + self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) # The argument parsing will result in self.define being a string, but # it has to be a list of 2-tuples. All the preprocessor symbols -- 1.8.4