@@ -357,28 +357,26 @@ def library_option (self, lib):
357357
358358
359359 def find_library_file (self , dirs , lib , debug = 0 ):
360- # find library file
360+ # List of effective library names to try, in order of preference:
361361 # bcpp_xxx.lib is better than xxx.lib
362362 # and xxx_d.lib is better than xxx.lib if debug is set
363+ #
364+ # The "bcpp_" prefix is to handle a Python installation for people
365+ # with multiple compilers (primarily Distutils hackers, I suspect
366+ # ;-). The idea is they'd have one static library for each
367+ # compiler they care about, since (almost?) every Windows compiler
368+ # seems to have a different format for static libraries.
369+ if debug :
370+ dlib = (lib + "_d" )
371+ try_names = ("bcpp_" + dlib , "bcpp_" + lib , dlib , lib )
372+ else :
373+ try_names = ("bcpp_" + lib , lib )
374+
363375 for dir in dirs :
364- if debug :
365- libfile = os .path .join (
366- dir , self .library_filename ("bcpp_" + lib + "_d" ))
367- if os .path .exists (libfile ):
376+ for name in try_names :
377+ libfile = os .path .join (dir , self .library_filename (name ))
378+ if os .path .exists (libfile ):
368379 return libfile
369- libfile = os .path .join (
370- dir , self .library_filename ("bcpp_" + lib ))
371- if os .path .exists (libfile ):
372- return libfile
373- if debug :
374- libfile = os .path .join (
375- dir , self .library_filename (lib + '_d' ))
376- if os .path .exists (libfile ):
377- return libfile
378- libfile = os .path .join (dir , self .library_filename (lib ))
379- if os .path .exists (libfile ):
380- return libfile
381-
382380 else :
383381 # Oops, didn't find it in *any* of 'dirs'
384382 return None
0 commit comments