Issue 43974: Define Py_BUILD_CORE_MODULE in extensions instead of setup.py and Modules/Setup
Created on 2021-04-29 09:02 by christian.heimes, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 25713 | closed | christian.heimes, 2021-04-29 09:04 | |
| PR 29157 | merged | christian.heimes, 2021-10-22 12:07 | |
| Messages (8) | |||
|---|---|---|---|
| msg392293 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2021-04-29 09:02 | |
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. |
|||
| msg392295 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2021-04-29 09:22 | |
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_BUILTIN |
|||
| msg392332 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2021-04-29 16:55 | |
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. |
|||
| msg392333 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2021-04-29 16:55 | |
> 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. |
|||
| msg392587 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2021-05-01 11:34 | |
> 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. |
|||
| msg404755 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2021-10-22 11:32 | |
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. |
|||
| msg404757 - (view) | Author: Erlend E. Aasland (erlendaasland) * ![]() |
Date: 2021-10-22 12:18 | |
> 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. |
|||
| msg404768 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2021-10-22 13:36 | |
New changeset 03e9f5dc751b8c441a85f428abc3f432ffe46345 by Christian Heimes in branch 'main': bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157) https://github.com/python/cpython/commit/03e9f5dc751b8c441a85f428abc3f432ffe46345 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:44 | admin | set | github: 88140 |
| 2022-02-21 11:46:32 | vstinner | set | nosy:
- vstinner |
| 2022-02-17 16:21:05 | eric.snow | set | nosy:
+ eric.snow |
| 2021-10-22 13:37:02 | christian.heimes | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2021-10-22 13:36:37 | christian.heimes | set | messages: + msg404768 |
| 2021-10-22 12:18:16 | erlendaasland | set | nosy:
+ erlendaasland messages: + msg404757 |
| 2021-10-22 12:07:11 | christian.heimes | set | stage: patch review pull_requests: + pull_request27432 |
| 2021-10-22 11:32:51 | christian.heimes | set | 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 nosy: + brett.cannon messages: + msg404755 versions:
- Python 3.10 |
| 2021-05-01 11:34:54 | christian.heimes | set | messages: + msg392587 |
| 2021-04-29 16:55:37 | vstinner | set | messages: + msg392333 |
| 2021-04-29 16:55:05 | vstinner | set | messages: + msg392332 |
| 2021-04-29 09:22:43 | christian.heimes | set | messages:
+ msg392295 stage: patch review -> (no value) |
| 2021-04-29 09:04:49 | christian.heimes | set | keywords:
+ patch stage: patch review pull_requests: + pull_request24402 |
| 2021-04-29 09:02:26 | christian.heimes | create | |

