You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup #88140
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:
assignee='https://github.com/tiran'closed_at=<Date2021-10-22.13:37:02.817>created_at=<Date2021-04-29.09:02:26.399>labels= ['extension-modules', 'type-bug', 'build', '3.11']
title='Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup'updated_at=<Date2022-02-21.11:46:32.070>user='https://github.com/tiran'
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.
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
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)".
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.
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.
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
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
Activity
tiran commentedon Apr 29, 2021
CPython's setup.py contains lots of
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.
tiran commentedon 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
vstinner commentedon Apr 29, 2021
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)".
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.
vstinner commentedon Apr 29, 2021
Oh, I didn't notice.
tiran commentedon May 1, 2021
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.
tiran commentedon Oct 22, 2021
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.
[-]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[/+][-]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[/+]erlend-aasland commentedon Oct 22, 2021
+1. Explicit is nice.
tiran commentedon Oct 22, 2021
New changeset 03e9f5d by Christian Heimes in branch 'main':
bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)
03e9f5d