GeezerVison is showing github.com — When performing the build of MSVC or MinGW .pyd, abi3t throws an error...... There is a conflict in the macro definition · Issue #159457 · python/cpython
When performing the build of MSVC or MinGW .pyd, abi3t throws an error...... There is a conflict in the macro definition #159457DescriptionBug report
When checking the ✔Download free-threaded build checkbox, a crash occurred and the build reported an error...... Version:3.15.0 Current environment; MSVC
After my test, if Download free-threaded build is not checked, there are still abi3t-compat directories, including Include\Python.h, libs \ python3t.lib and python315t.lib. Is this a design problem?
When adding macro definitions, the complete code is as follows:
self.ext_arr.append(Extension(
mod,
sources=[fp],
define_macros=[
("Py_LIMITED_API", "0x30f0000"),
("Py_TARGET_ABI3T", "0x30f0000"),
],
))
When the first macro definition is added:("Py_LIMITED_API", "0x30f0000"),Python considers transparency and macro definition conflicts
When only retained ("Py_TARGET_ABI3T", "0x30f0000"), The same error was reported. The complete log is as follows
The same error was reported, but the logs were all the same
logging:
Compiling scripts_msvc/test.py because it changed.
[1/1] Cythonizing scripts_msvc/test.py
running build_ext
building 'test' extension
D:\SOFTWARE\sde\msvc\product\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPy_LIMITED_API=0x30f0000 -DPy_TARGET_ABI3T=0x30f0000 -ID:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include -ID:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Include -ID:\SOFTWARE\sde\msvc\product\VC\Tools\MSVC\14.29.30133\include "-IC:\msvc_sdk\Windows SDK 10.0.28000.2705_x64\Include\shared" "-IC:\msvc_sdk\Windows SDK 10.0.28000.2705_x64\Include\ucrt" "-IC:\msvc_sdk\Windows SDK 10.0.28000.2705_x64\Include\um" -ID:\SOFTWARE\sde\msvc\product\VC\Tools\MSVC\14.29.30133\include /Tcscripts_msvc/test.c /Fobuild\temp.win-amd64-cpython-315\Release\scripts_msvc\test.obj
test.c
scripts_msvc/test.c(1695): error C2061: 语法错误: 标识符“PyObject_HEAD”
scripts_msvc/test.c(1698): error C2059: 语法错误:“}”
scripts_msvc/test.c(1709): error C2061: 语法错误: 标识符“PyObject_HEAD”
scripts_msvc/test.c(1712): error C2059: 语法错误:“}”
scripts_msvc/test.c(1723): error C2061: 语法错误: 标识符“PyObject_HEAD”
scripts_msvc/test.c(1726): error C2059: 语法错误:“}”
scripts_msvc/test.c(1737): error C2061: 语法错误: 标识符“PyObject_HEAD”
scripts_msvc/test.c(1745): error C2059: 语法错误:“}”
scripts_msvc/test.c(2776): error C2061: 语法错误: 标识符“PyObject_HEAD”
scripts_msvc/test.c(2797): error C2059: 语法错误:“}”
scripts_msvc/test.c(2798): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2801): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2802): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(2802): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2802): error C2373: “__pyx_coroutine_body_t”: 重定义;不同的类型修饰符
scripts_msvc/test.c(2765): note: 参见“__pyx_coroutine_body_t”的声明
scripts_msvc/test.c(2802): error C2146: 语法错误: 缺少“;”(在标识符“body”的前面)
scripts_msvc/test.c(2802): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(2802): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(2802): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(2802): error C2371: “closure”: 重定义;不同的基类型
scripts_msvc/test.c(2778): note: 参见“closure”的声明
scripts_msvc/test.c(2803): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(2803): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(2803): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(2803): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(2803): error C2059: 语法错误:“)”
scripts_msvc/test.c(2838): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(2838): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2838): error C2059: 语法错误:“)”
scripts_msvc/test.c(2839): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(2839): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2839): error C2059: 语法错误:“)”
scripts_msvc/test.c(2840): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(2840): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(2840): error C2059: 语法错误:“)”
scripts_msvc/test.c(4763): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(4763): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(4763): error C2371: “PyThreadState”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(25): note: 参见“PyThreadState”的声明
scripts_msvc/test.c(4763): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(4763): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(4763): error C2059: 语法错误:“)”
scripts_msvc/test.c(4789): error C2037: “__pyx_genexpr_arg_0”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct__genexpr”
scripts_msvc/test.c(4790): error C2037: “__pyx_genexpr_arg_0”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct__genexpr”
scripts_msvc/test.c(4790): error C2198: “Py_INCREF”: 用于调用的参数太少
scripts_msvc/test.c(4793): error C2065: “__pyx_CoroutineObject”: 未声明的标识符
scripts_msvc/test.c(4793): error C2297: “*”: 非法,右操作数包含“int *”类型
scripts_msvc/test.c(4793): error C2065: “__pyx_gb_4test_17FileMonitorThread_3run_2generator”: 未声明的标识符
scripts_msvc/test.c(4793): warning C4312: “类型强制转换”: 从“int”转换到更大的“__pyx_coroutine_body_t”
scripts_msvc/test.c(4809): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(4809): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(4809): error C2371: “PyThreadState”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(25): note: 参见“PyThreadState”的声明
scripts_msvc/test.c(4809): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(4809): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(4809): error C2059: 语法错误:“)”
scripts_msvc/test.c(4810): error C2054: 在“__pyx_sent_value”之后应输入“(”
scripts_msvc/test.c(9418): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(9418): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(9418): error C2371: “PyThreadState”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(25): note: 参见“PyThreadState”的声明
scripts_msvc/test.c(9418): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(9418): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(9418): error C2059: 语法错误:“)”
scripts_msvc/test.c(9444): error C2037: “__pyx_genexpr_arg_0”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_2_genexpr”
scripts_msvc/test.c(9445): error C2037: “__pyx_genexpr_arg_0”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_2_genexpr”
scripts_msvc/test.c(9445): error C2198: “Py_INCREF”: 用于调用的参数太少
scripts_msvc/test.c(9448): error C2065: “__pyx_CoroutineObject”: 未声明的标识符
scripts_msvc/test.c(9448): error C2297: “*”: 非法,右操作数包含“int *”类型
scripts_msvc/test.c(9448): error C2065: “__pyx_gb_4test_10MainWindow_8on_ready_2generator1”: 未声明的标识符
scripts_msvc/test.c(9448): warning C4312: “类型强制转换”: 从“int”转换到更大的“__pyx_coroutine_body_t”
scripts_msvc/test.c(9464): error C2143: 语法错误: 缺少“)”(在“*”的前面)
scripts_msvc/test.c(9464): error C2143: 语法错误: 缺少“{”(在“*”的前面)
scripts_msvc/test.c(9464): error C2371: “PyThreadState”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(25): note: 参见“PyThreadState”的声明
scripts_msvc/test.c(9464): error C2143: 语法错误: 缺少“;”(在“*”的前面)
scripts_msvc/test.c(9464): error C2371: “PyObject”: 重定义;不同的基类型
D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\include\pytypedefs.h(19): note: 参见“PyObject”的声明
scripts_msvc/test.c(9464): error C2059: 语法错误:“)”
scripts_msvc/test.c(9465): error C2054: 在“__pyx_sent_value”之后应输入“(”
scripts_msvc/test.c(9593): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9594): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9596): error C2037: “__pyx_v_content”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9599): error C2037: “__pyx_v_content”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9665): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9666): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9666): error C2198: “Py_INCREF”: 用于调用的参数太少
scripts_msvc/test.c(9676): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9676): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9723): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9765): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9765): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9787): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9787): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9809): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9809): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9831): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9831): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9853): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9853): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9865): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9865): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9886): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9886): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9946): error C2037: “__pyx_v_content”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9967): error C2037: “__pyx_v_self”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(9967): error C2198: “PyObject_GetAttr”: 用于调用的参数太少
scripts_msvc/test.c(9970): error C2037: “__pyx_v_content”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_1_on_ready”
scripts_msvc/test.c(11368): error C2037: “__pyx_v_CreateFileW”的左侧部分指定未定义的结构/联合“__pyx_obj_4test___pyx_scope_struct_3___init__”
scripts_msvc/test.c(11368): fatal error C1003: 错误计数超过 100;正在停止编译
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
详情错误信息已记录:Traceback (most recent call last):
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 520, in compile
self.call(args)
~~~~~~~~~^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 623, in call
return super().call(cmd, env=env, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\compilers\C\base.py", line 1177, in call
subprocess.check_call(cmd, env=macos.inject_ver(env), **kwargs)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\subprocess.py", line 534, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['D:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe', '/c', '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD', '-DPy_LIMITED_API=0x30f0000', '-DPy_TARGET_ABI3T=0x30f0000', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\include', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\Include', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\shared', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\ucrt', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\um', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '/Tcscripts_msvc/test.c', '/Fobuild\\temp.win-amd64-cpython-315\\Release\\scripts_msvc\\test.obj']' returned non-zero exit status 2.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\core.py", line 184, in run_commands
dist.run_commands()
~~~~~~~~~~~~~~~~~^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\dist.py", line 1028, in run_commands
self.run_command(cmd)
~~~~~~~~~~~~~~~~^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\dist.py", line 1106, in run_command
super().run_command(command)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\dist.py", line 1047, in run_command
cmd_obj.run()
~~~~~~~~~~~^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\command\build_ext.py", line 95, in run
_build_ext.run(self)
~~~~~~~~~~~~~~^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 382, in run
self.build_extensions()
~~~~~~~~~~~~~~~~~~~~~^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 498, in build_extensions
self._build_extensions_serial()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 524, in _build_extensions_serial
self.build_extension(ext)
~~~~~~~~~~~~~~~~~~~~^^^^^
File "E:\PY转PYD项目源码\发布\Compiler_Tools\MSVC\setup_msvc.py", line 201, in build_extension
super().build_extension(ext)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\command\build_ext.py", line 260, in build_extension
_build_ext.build_extension(self, ext)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\Cython\Distutils\build_ext.py", line 140, in build_extension
super().build_extension(ext)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 585, in build_extension
objects = self.compiler.compile(
sources,
...<5 lines>...
depends=ext.depends,
)
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 522, in compile
raise CompileError(msg)
distutils.compilers.C.errors.CompileError: Command '['D:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe', '/c', '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD', '-DPy_LIMITED_API=0x30f0000', '-DPy_TARGET_ABI3T=0x30f0000', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\include', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\Include', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\shared', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\ucrt', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\um', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '/Tcscripts_msvc/test.c', '/Fobuild\\temp.win-amd64-cpython-315\\Release\\scripts_msvc\\test.obj']' returned non-zero exit status 2.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\PY转PYD项目源码\发布\Compiler_Tools\MSVC\setup_msvc.py", line 293, in build
setup(ext_modules=cythonize(self.ext_arr, compiler_directives={"language_level": 3}),cmdclass={"build_ext": CustomBuild})
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\__init__.py", line 117, in setup
return distutils.core.setup(**attrs) # type: ignore[return-value]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\core.py", line 168, in setup
return run_commands(dist)
File "D:\SOFTWARE\sde\python\python_ccompiler\python3.15.0-pip26.2.1\Lib\site-packages\setuptools\_distutils\core.py", line 198, in run_commands
raise SystemExit(f"error: {msg}")
SystemExit: error: Command '['D:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe', '/c', '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD', '-DPy_LIMITED_API=0x30f0000', '-DPy_TARGET_ABI3T=0x30f0000', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\include', '-ID:\\SOFTWARE\\sde\\python\\python_ccompiler\\python3.15.0-pip26.2.1\\Include', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\shared', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\ucrt', '-IC:\\msvc_sdk\\Windows SDK 10.0.28000.2705_x64\\Include\\um', '-ID:\\SOFTWARE\\sde\\msvc\\product\\VC\\Tools\\MSVC\\14.29.30133\\include', '/Tcscripts_msvc/test.c', '/Fobuild\\temp.win-amd64-cpython-315\\Release\\scripts_msvc\\test.obj']' returned non-zero exit status 2.
When I switched to python3.15t.exe for compilation, the MSVC compiler got stuck at > and stopped compiling. However, when I switched to Python.exe, everything in MSVC worked fine
The main point is In the provided setup.py;
self.ext_arr.append(Extension(
mod,
sources=[fp],
define_macros=[
("Py_LIMITED_API", "0x30f0000"),
("Py_TARGET_ABI3T", "0x30f0000"),
],
)) # Unsuitable parameters TypeError: init() got an unexpected keyword argument 'build_deimos,d_lump'
setup_msvc.py
Maintainers can remove if name == 'main': from the provided setup.py to facilitate troubleshooting
if __name__ == '__main__':
class PythonVersionChecker:
def __init__(self):
self.exclude_keywords = ['venv','virtualenv','.virtual','env\\','envs\\','anaconda','miniconda','conda','pipenv','poetry','uv']
self.required_version = (3,8,0)
self.python_names = ['python.exe','python3.15t.exe']
def _get_path_from_registry(self, root, subkey):
try:
with winreg.OpenKey(root, subkey) as key:
path_value, _ = winreg.QueryValueEx(key, 'PATH')
return path_value
except WindowsError:
return ''
def get_system_paths(self):
user_path = self._get_path_from_registry(winreg.HKEY_CURRENT_USER, "Environment")
system_path = self._get_path_from_registry(winreg.HKEY_LOCAL_MACHINE,r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment")
all_paths = user_path.split(';') + system_path.split(';')
system_paths = []
seen_paths = set()
for path in all_paths:
if path:
normalized_path = os.path.normpath(path).lower()
if normalized_path in seen_paths:
continue
seen_paths.add(normalized_path)
if not any(keyword in path.lower() for keyword in self.exclude_keywords):
system_paths.append(os.path.normpath(path))
return system_paths
def find_python_executables(self):
system_paths = self.get_system_paths()
python_candidates = []
found_python = set()
for path in system_paths:
python_exe = os.path.join(path, 'python.exe')
if os.path.exists(python_exe):
python_exe_normalized = os.path.normpath(python_exe).lower()
if python_exe_normalized not in found_python:
found_python.add(python_exe_normalized)
python_candidates.append(os.path.normpath(python_exe))
return python_candidates
def get_python_version(self, python_path):
try:
cmd = [python_path, '--version']
result = subprocess.run(cmd, capture_output=True, text=True, timeout=5)
if result.returncode == 0:
version_output = result.stdout.strip() or result.stderr.strip()
match = re.search(r'Python (\d+)\.(\d+)\.(\d+)', version_output)
if match:
major = int(match.group(1))
minor = int(match.group(2))
micro = int(match.group(3))
return (major, minor, micro), f"{major}.{minor}.{micro}"
return None, None
except Exception as e:
ctypes.windll.user32.MessageBoxW(0,'我们找不到你的Python,请确保安装了你的Python环境!','',0x10)
return None, None
def check_version(self, version_tuple):
if not version_tuple:
return False
return version_tuple >= self.required_version
def run(self):
print("Python版本确认 - 小智Python之路出品")
print("使用说明(如果解释器路径忘记,请使用目录下CPthon_Version.exe):")
print("1、输入 'python': 使用环境变量中的Python执行脚本")
print("2、输入路径: 使用指定路径的python.exe (路径必须存在且含python.exe/python3.15t.exe)")
print("3、输入 'exit': 退出程序")
print("4、新版本支持python3.15无abi3t-GIL")
print("-" * 60)
while True:
user_input = input("\n请输入(python/路径/exit): ").strip()
if user_input.lower() == 'exit':
print("感谢你的使用,祝你有美好的一天,再见!")
time.sleep(5)
return 0
if user_input.lower() == 'python':
python_path = 'python'
print(f"使用环境变量中的Python,✔执行编译!")
else:
if not os.path.exists(user_input):
print(f"❌ 错误: 路径 '{user_input}' 不存在,请重新输入!")
continue
if os.path.basename(user_input).lower() not in ('python.exe', 'python3.15t.exe'):
if os.path.isdir(user_input):
found = None
for name in ('python.exe', 'python3.15t.exe'):
candidate = os.path.join(user_input, name)
if os.path.exists(candidate):
found = candidate
break
if found:
user_input = found
else:
print(f"❌ 错误: '{user_input}' 目录下找不到 python.exe / python3.15t.exe!")
continue
else:
print(f"❌ 错误: 请指定 python.exe / python3.15t.exe! 文件路径")
continue
python_path = user_input
print(f"使用路径Python: {python_path},执行编译!")
version_tuple, version_str = self.get_python_version(python_path)
if version_tuple is None:
print("❌ 无法获取Python版本,请确保安装了Python环境!")
continue
if self.check_version(version_tuple):
print(f"✅ Python版本: {version_str} (符合要求 >= 3.8.0),执行编译!")
return 1
else:
print(f"❌ 拦截! Python版本: {version_str} (低于3.8.0,拒绝运行),请注意,如果你是MSVC环境,3.12及以上请使用新版本,3.11及以下请使用MSVC")
return 2
checker = PythonVersionChecker()
version_passed = checker.run()
if version_passed == 1:
print("\n✅ 版本检测通过,开始执行编译...")
CythonPydBuilder().build()
elif version_passed == 2:
print("❌ 版本检测未通过,拒绝执行构建!")
sys.exit(1)
else:
sys.exit(0)
Only the core remains.
checker = PythonVersionChecker()
version_passed = checker.run()
I know this is a huge workload. This is the setup.py I rewrote. If you have any questions, feel free to ask me at any time china xiaozhi
After checking "free-threaded", compile the abi3t extension with Python 3.15t.exe MSVC, and the compiler gets stuck at >. It works fine to switch to python.exe.
PyObject_HEAD syntax error, python readstate redefinition, __pyx_CoroutineObject not declared, and finally fatal error C1003 - error count exceeds 100.
Redefinition of PyThreadState: This indicates that the header file path of abi3t conflicts with the regular Include path, and the Py_LIMITED_API has not correctly masked the internal structure definition.The Cython internal classes such as __pyx_CoroutineObject and __pyx_scope_struct have not been correctly defined under abi3t at all, indicating that the C code generated by Cython is incompatible with the ABI requirements of abi3t.
python3.15t.exe is stuck at > : The linker cannot find the correct python3t.lib or the corresponding DLL path. However, python.exe can pass because it follows the common abi3/GIL path instead of abi3t. Reason: The Python 3.15t.exe installed by MSI in combination with setuptools Cython abi3t cannot compile extensions normally on Windows .pyd
It's always impossible to add environmental variables, right? Cure the symptoms, not the root cause, because there are still problems in the multi-grid version environment such as "d: \ python315.exe" setup.pybuild _ ext-compiler = msvc.
MinGW Warning Logging:
MingW Logging.txt
CPython versions tested on:
3.15
Operating systems tested on:
Windows Activitychanged the title [-]When checking the ✔Download free-threaded build checkbox, a crash occurred and the build reported an error......[/-] [+]When performing the build of MSVC.pyd, abi3t throws an error...... There is a conflict in the macro definition[/+] on Oct 15, 2026changed the title [-]When performing the build of MSVC.pyd, abi3t throws an error...... There is a conflict in the macro definition[/-] [+]When performing the build of MSVC or MinGW .pyd, abi3t throws an error...... There is a conflict in the macro definition[/+] on Oct 15, 2026encukou commented on Oct 15, 2026
scripts_msvc/test.c(1695): error C2061: 语法错误: 标识符“PyObject_HEAD”
I can't read that error message, but it looks like the file scripts_msvc/test.c uses PyObject_HEAD, which cannot be used with abi3t. See the migration HOWTO section on custom type definitions. encukou commented on Oct 16, 2026 Sorry, I do not understand this bug report. It does not look like you found a bug in CPython.
I suspect that sysconfig may have returned the wrong path, python315t.lib may not be found, but the file exists.
How did you call sysconfig? What path did it return, and what was the expected value? Xiaozhi-Python-Road commented on Oct 17, 2026
7. How did you call sysconfig? What path did it return, and what was the expected value?
Perhaps this has nothing to do with the expected value, because the MSVC compiler gets stuck in > when calling python3.15t.exe, and at the same time, when the Download free-thread-build option is not checked, The corresponding components such as python315t.lib still exist in the directory. If it is a compiler issue, then why is it normal for MSVC to call python.exe? So the problem of MSVC has been ruled out
cd /d %~dp0 && python setup_msvc.py build_ext --compiler=msvc" This command itself is fine because the working directory may run to System32 at any time. It is necessary to lock the current shuttle directory or use the cd command to switch and execute the compilation
Relying on environment variables to specify the PATH of the library is only a temporary bypass problem, which cannot be used as a formal solution. In the coexistence scene of multiple pythons, there are both ordinary GIL and free-thread (with T) versions locally, so it is always impossible to manually modify the environment variables every time the interpreter is switched, so "D:\python3.15t.exe" ... it is meaningless to specify the interpreter. The script should obtain the abi of the currently running interpreter itself, automatically. Because there are multiple environmental tests: Download free-thread build is not ticked, but abi3 related components without GIL free thread still exist in the directory.

MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|