diff -r a1cd431a71c6 Lib/distutils/command/build_ext.py --- a/Lib/distutils/command/build_ext.py Sun Oct 28 11:13:51 2012 -0700 +++ b/Lib/distutils/command/build_ext.py Tue Oct 30 04:43:44 2012 -0700 @@ -233,7 +233,9 @@ # 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")): + # executable may be symlinked, resolve all links + sys_executable = os.path.realpath(sys.executable) + if sys_executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions self.library_dirs.append(os.path.join(sys.prefix, "lib", "python" + get_python_version(), @@ -247,7 +249,9 @@ 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")): + # executable may be symlinked, resolve all links + sys_executable = os.path.realpath(sys.executable) + 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: