711 return |
711 return |
712 if isinstance(self.compiler, HackedMingw32CCompiler): |
712 if isinstance(self.compiler, HackedMingw32CCompiler): |
713 self.compiler.compiler_so = self.compiler.compiler # no -mdll |
713 self.compiler.compiler_so = self.compiler.compiler # no -mdll |
714 self.compiler.dll_libraries = [] # no -lmsrvc90 |
714 self.compiler.dll_libraries = [] # no -lmsrvc90 |
715 |
715 |
716 # Different Python installs can have different Python library |
716 pythonlib = None |
717 # names. e.g. the official CPython distribution uses pythonXY.dll |
717 |
718 # and MinGW uses libpythonX.Y.dll. |
718 if getattr(sys, 'dllhandle', None): |
719 _kernel32 = ctypes.windll.kernel32 |
719 # Different Python installs can have different Python library |
720 _kernel32.GetModuleFileNameA.argtypes = [ |
720 # names. e.g. the official CPython distribution uses pythonXY.dll |
721 ctypes.c_void_p, |
721 # and MinGW uses libpythonX.Y.dll. |
722 ctypes.c_void_p, |
722 _kernel32 = ctypes.windll.kernel32 |
723 ctypes.c_ulong, |
723 _kernel32.GetModuleFileNameA.argtypes = [ |
724 ] |
724 ctypes.c_void_p, |
725 _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong |
725 ctypes.c_void_p, |
726 size = 1000 |
726 ctypes.c_ulong, |
727 buf = ctypes.create_string_buffer(size + 1) |
727 ] |
728 filelen = _kernel32.GetModuleFileNameA( |
728 _kernel32.GetModuleFileNameA.restype = ctypes.c_ulong |
729 sys.dllhandle, ctypes.byref(buf), size |
729 size = 1000 |
730 ) |
730 buf = ctypes.create_string_buffer(size + 1) |
731 |
731 filelen = _kernel32.GetModuleFileNameA( |
732 if filelen > 0 and filelen != size: |
732 sys.dllhandle, ctypes.byref(buf), size |
733 dllbasename = os.path.basename(buf.value) |
733 ) |
734 if not dllbasename.lower().endswith(b'.dll'): |
734 |
735 raise SystemExit( |
735 if filelen > 0 and filelen != size: |
736 'Python DLL does not end with .dll: %s' % dllbasename |
736 dllbasename = os.path.basename(buf.value) |
737 ) |
737 if not dllbasename.lower().endswith(b'.dll'): |
738 pythonlib = dllbasename[:-4] |
738 raise SystemExit( |
739 else: |
739 'Python DLL does not end with .dll: %s' % dllbasename |
|
740 ) |
|
741 pythonlib = dllbasename[:-4] |
|
742 |
|
743 if not pythonlib: |
740 log.warn( |
744 log.warn( |
741 'could not determine Python DLL filename; assuming pythonXY' |
745 'could not determine Python DLL filename; assuming pythonXY' |
742 ) |
746 ) |
743 |
747 |
744 hv = sys.hexversion |
748 hv = sys.hexversion |