diff -urN py2exe-0.11.0.1-orig/py2exe_distutils.py py2exe-0.11.0.1/py2exe_distutils.py --- py2exe-0.11.0.1-orig/py2exe_distutils.py 2021-11-17 05:13:22.000000000 +0800 +++ py2exe-0.11.0.1/py2exe_distutils.py 2021-12-13 21:58:54.332016900 +0800 @@ -117,6 +117,13 @@ else: ext_path += ".dll" + if 'GCC' in sys.version: + if ext.name == "py2exe.run_ctypes_dll": + ext.export_symbols = [s.replace(",", " ") for s in ext.export_symbols] + ext.extra_link_args.append("-Wl,--enable-stdcall-fixup") + else: + ext.export_symbols = None + depends = sources + ext.depends if not (self.force or newer_group(depends, ext_path, 'newer')): log.debug("skipping '%s' extension (up-to-date)", ext.name) @@ -138,7 +145,7 @@ # The environment variable should take precedence, and # any sensible compiler will give precedence to later # command line args. Hence we combine them in order: - extra_args = ext.extra_compile_args or [] + extra_compile_args = ext.extra_compile_args or [] macros = ext.define_macros[:] for undef in ext.undef_macros: @@ -149,7 +156,7 @@ macros=macros, include_dirs=ext.include_dirs, debug=self.debug, - extra_postargs=extra_args, + extra_postargs=extra_compile_args, depends=ext.depends) # XXX -- this is a Vile HACK! @@ -168,7 +175,7 @@ # that go into the mix. if ext.extra_objects: objects.extend(ext.extra_objects) - extra_args = ext.extra_link_args or [] + extra_link_args = ext.extra_link_args or [] # Detect target language, if not provided ## language = ext.language or self.compiler.detect_language(sources) @@ -195,7 +202,7 @@ library_dirs=ext.library_dirs, runtime_library_dirs=ext.runtime_library_dirs, export_symbols=ext.export_symbols, - extra_postargs=extra_args, + extra_postargs=extra_link_args, debug=self.debug) @@ -209,7 +216,7 @@ fnm = os.path.join(*ext_path) if ext_path[-1] == "resources": return fnm - return '%s-py%s.%s-%s' % (fnm, sys.version_info[0], sys.version_info[1], get_platform()) + return '%s-py%s%s-%s' % (fnm, sys.version_info[0], sys.version_info[1], get_platform()) def InstallSubCommands(): diff -urN py2exe-0.11.0.1-orig/setup.py py2exe-0.11.0.1/setup.py --- py2exe-0.11.0.1-orig/setup.py 2021-11-17 05:13:22.000000000 +0800 +++ py2exe-0.11.0.1/setup.py 2021-12-13 22:24:19.957277700 +0800 @@ -25,14 +25,13 @@ python_dll_name = '\\"python%d%d.dll\\"' % sys.version_info[:2] python_dll_name_debug = '\\"python%d%d_d.dll\\"' % sys.version_info[:2] else: - python_dll_name = '\"python%d%d.dll\"' % sys.version_info[:2] - python_dll_name_debug = '\"python%d%d_d.dll\"' % sys.version_info[:2] + python_dll_name = '\"libpython%d.%d.dll\"' % sys.version_info[:2] + python_dll_name_debug = '\"libpython%d.%d_d.dll\"' % sys.version_info[:2] def _is_debug_build(): - import imp - for ext, _, _ in imp.get_suffixes(): - if ext == "_d.pyd": - return True + import importlib.machinery + if "_d.pyd" in importlib.machinery.EXTENSION_SUFFIXES: + return True return False if _is_debug_build(): @@ -49,16 +48,11 @@ extra_compile_args = [] extra_link_args = [] -extra_compile_args.append("-IC:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Include") -extra_compile_args.append("-IC:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\include") -extra_compile_args.append("-IC:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10586.0\\ucrt") - -if 0: - # enable this to debug a release build - extra_compile_args.append("/Od") - extra_compile_args.append("/Z7") - extra_link_args.append("/DEBUG") - macros.append(("VERBOSE", "1")) +platname = [] +if '64 bit' in sys.version: + platname = ["-m64"] +else: + platname = ["-m32"] run_ctypes_dll = Interpreter("py2exe.run_ctypes_dll", ["source/run_ctypes_dll.c", @@ -81,7 +75,7 @@ target_desc = "shared_library", define_macros=macros, extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args + ["/DLL"], + extra_link_args=extra_link_args + platname + ["-mwindows"], ) run = Interpreter("py2exe.run", @@ -99,7 +93,7 @@ libraries=["user32", "shell32"], define_macros=macros, extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, + extra_link_args=extra_link_args + platname + ["-mconsole", "-municode"], ) run_w = Interpreter("py2exe.run_w", @@ -117,7 +111,7 @@ libraries=["user32", "shell32"], define_macros=macros, extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, + extra_link_args=extra_link_args + platname + ["-mwindows"], ) # The py2exe.resources name is special handled in BuildInterpreters; @@ -133,7 +127,7 @@ ["source/dll.c", "source/icon.rc"], target_desc = "shared_library", - extra_link_args=["/DLL"], + extra_link_args=platname, ) interpreters = [run, run_w, resource_dll,