Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18b9b93

Browse files
author
Thomas Heller
committed
Removed the implib_dir instance variable because it is unused.
Removed get_ext_libname() because it is unused. Fixed get_libraries() to append an '_d' to the python debug import library. If MSVC is used, do not add 'pythonxx.lib' to the list of libraries, because this is handled better by a pragma in config.h. This should fix bug #115595, but it needs some more testing.
1 parent 20af317 commit 18b9b93

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

Lib/distutils/command/build_ext.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def finalize_options (self):
158158
# also Python's library directory must be appended to library_dirs
159159
if os.name == 'nt':
160160
self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs'))
161-
self.implib_dir = self.build_temp
162161
if self.debug:
163162
self.build_temp = os.path.join (self.build_temp, "Debug")
164163
else:
@@ -543,15 +542,6 @@ def get_ext_filename (self, ext_name):
543542
return apply (os.path.join, ext_path) + '_d' + so_ext
544543
return apply (os.path.join, ext_path) + so_ext
545544

546-
def get_ext_libname (self, ext_name):
547-
# create a filename for the (unneeded) lib-file.
548-
# extensions in debug_mode are named 'module_d.pyd' under windows
549-
ext_path = string.split (ext_name, '.')
550-
if os.name == 'nt' and self.debug:
551-
return apply (os.path.join, ext_path) + '_d.lib'
552-
return apply (os.path.join, ext_path) + '.lib'
553-
554-
555545
def get_export_symbols (self, ext):
556546
"""Return the list of symbols that a shared extension has to
557547
export. This either uses 'ext.export_symbols' or, if it's not
@@ -573,9 +563,15 @@ def get_libraries (self, ext):
573563
# is redundant, since the library is mentioned in a pragma in
574564
# config.h that MSVC groks. The other Windows compilers all seem
575565
# to need it mentioned explicitly, though, so that's what we do.
576-
if sys.platform == "win32":
577-
pythonlib = ("python%d%d" %
578-
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
566+
# Append '_d' to the python import library on debug builds.
567+
from distutils.msvccompiler import MSVCCompiler
568+
if sys.platform == "win32" and \
569+
not isinstance(self.compiler, MSVCCompiler):
570+
template = "python%d%d"
571+
if self.debug:
572+
template = template + '_d'
573+
pythonlib = (template %
574+
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
579575
# don't extend ext.libraries, it may be shared with other
580576
# extensions, it is a reference to the original list
581577
return ext.libraries + [pythonlib]

0 commit comments

Comments
 (0)