# HG changeset patch # Parent 2945018358900b5f9ff80c201d5569394c223c8a Issue #23199: libpython27.a in amd64 release is 32-bit diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py --- a/Tools/msi/msi.py +++ b/Tools/msi/msi.py @@ -132,31 +132,29 @@ # Build the mingw import library, libpythonXY.a # This requires 'nm' and 'dlltool' executables on your PATH -def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib): +def build_mingw_lib(dll_path, def_file, dll_file, mingw_lib): warning = "WARNING: %s - libpythonXX.a not built" - nm = find_executable('nm') + gendef = find_executable('gendef') dlltool = find_executable('dlltool') - if not nm or not dlltool: - print warning % "nm and/or dlltool were not found" + if not gendef or not dlltool: + print warning % "gendef and/or dlltool were not found" return False - nm_command = '%s -Cs %s' % (nm, lib_file) + gendef_command = '%s - %s' % (gendef, dll_path) dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \ (dlltool, dll_file, def_file, mingw_lib) - export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match - + if msilib.Win64: + dlltool_command += " -m i386:x86-64" + else: + dlltool_command += " -m i386" + f = open(def_file,'w') - print >>f, "LIBRARY %s" % dll_file - print >>f, "EXPORTS" - - nm_pipe = os.popen(nm_command) - for line in nm_pipe.readlines(): - m = export_match(line) - if m: - print >>f, m.group(1) + gendef_pipe = os.popen(nm_command) + for line in gendef_pipe.readlines(): + print >>f, line f.close() - exit = nm_pipe.close() + exit = gendef_pipe.close() if exit: print warning % "nm did not run successfully" @@ -169,12 +167,12 @@ return True # Target files (.def and .a) go in PCBuild directory -lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor)) +dll_path = os.path.join(srcdir, PCBUILD, "python%s%s.dll" % (major, minor)) def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor)) dll_file = "python%s%s.dll" % (major, minor) mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor)) -have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib) +have_mingw = build_mingw_lib(dll_path, def_file, dll_file, mingw_lib) # Determine the target architecture if os.system("nmake /nologo /c /f msisupport.mak") != 0: