Repository navigation
Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup #88140
Description
Activity
CPython's setup.py contains lots of
extra_compile_args = ['-DPy_BUILD_CORE_MODULE']
to mark modules as core module. Extra compiler args is the wrong option. It's also tedious and err-prone to define the macro in each and every Extension() class instance.
The compiler flag should be set automatically for all core extensions and it should use be set using the correct option define_macros.
- addedbuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes
on Apr 29, 2021 - addedbuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Apr 29, 2021 Related to the change:
It looks like we can also cleanup Modules/Setup and remove -DPy_BUILD_CORE_BUILTIN and -DPy_BUILD_CORE_MODULE. Modules/makesetup adds $PY_BUILTIN_MODULE_CFLAGS in the compile step. The variable is defined as
PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTINI would prefer to limit the usage of the internal C API in extension modules built as dynamic libraries. See bpo-41111: "[C API] Convert a few stdlib extensions to the limited C API (PEP-384)".
Also, this issue is motived by PR 25653 which requires to use the internal C API in many C extensions. But I proposed a different approach, PR 25710, which prevents that.
It looks like we can also cleanup Modules/Setup and remove -DPy_BUILD_CORE_BUILTIN and -DPy_BUILD_CORE_MODULE. Modules/makesetup adds $PY_BUILTIN_MODULE_CFLAGS in the compile step.
Oh, I didn't notice.
I would prefer to limit the usage of the internal C API in extension modules built as dynamic libraries. See bpo-41111: "[C API] Convert a few stdlib extensions to the limited C API (PEP-384)".
Let's make this a coordinated effort in 3.11. I suggest that we slowly remove functions from Py_BUILD_CORE_MODULE. For now I'm interested to clean up and simplify setup.py.
The proposal is related to Brett's ticket bpo-45548. I no longer think that we should define Py_BUILD_CORE_MODULE unconditionally. Instead I propose to move the defines into each C module. This avoids duplication of macros in setup.py and Modules/Setup.
- addedextension-modulesC modules in the Modules dirC modules in the Modules dirand removed3.10 (EOL)end of lifeend of life
on Oct 22, 2021 - changed the title
[-]setup.py should set Py_BUILD_CORE_MODULE as defined macro[/-][+]Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup[/+]on Oct 22, 2021 - addedextension-modulesC modules in the Modules dirC modules in the Modules dirand removed3.10 (EOL)end of lifeend of life
on Oct 22, 2021 - changed the title
[-]setup.py should set Py_BUILD_CORE_MODULE as defined macro[/-][+]Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup[/+]on Oct 22, 2021 I no longer think that we should define Py_BUILD_CORE_MODULE
unconditionally. Instead I propose to move the defines into each C module.+1. Explicit is nice.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: