Skip to content

bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157) #29157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``setup.py`` no longer defines ``Py_BUILD_CORE_MODULE``. Instead every
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also mention Modules/Setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I didn't know that Modules/makesetup already uses the correct flags for build C extensions depending if it's before or after *shared* in Modules/Setup:

There is a problem with *shared*. I created https://bugs.python.org/issue45571 to track the issue.

module, that uses the internal API, defines the macro.
62 changes: 31 additions & 31 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,26 @@ PYTHONPATH=$(COREPYTHONPATH)
# cannot be built as shared!

_collections _collectionsmodule.c
_abc -DPy_BUILD_CORE_BUILTIN _abc.c
_abc _abc.c
_codecs _codecsmodule.c
_functools -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _functoolsmodule.c
_io -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
_locale -DPy_BUILD_CORE_BUILTIN _localemodule.c # -lintl
_operator -DPy_BUILD_CORE_BUILTIN _operator.c
_signal -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal signalmodule.c
_sre -DPy_BUILD_CORE_BUILTIN _sre.c
_functools _functoolsmodule.c
_io -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
_locale _localemodule.c # -lintl
_operator _operator.c
_signal signalmodule.c
_sre _sre.c
_stat _stat.c
_symtable symtablemodule.c # setup.py can't track the .h file that _symtable depends on.
_thread -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _threadmodule.c
_thread _threadmodule.c
_tracemalloc _tracemalloc.c # See bpo-35053 as to why this is built in.
_weakref _weakref.c
atexit atexitmodule.c
errno errnomodule.c
faulthandler faulthandler.c
itertools itertoolsmodule.c
posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
posix posixmodule.c
pwd pwdmodule.c
time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
time timemodule.c


# ---
Expand All @@ -139,7 +139,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c

#_asyncio _asynciomodule.c
#_bisect _bisectmodule.c
#_blake2 -DPy_BUILD_CORE_BUILTIN _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
#_codecs_cn cjkcodecs/_codecs_cn.c
#_codecs_hk cjkcodecs/_codecs_hk.c
#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
Expand All @@ -150,31 +150,31 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
#_csv _csv.c
#_datetime _datetimemodule.c
#_elementtree -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat _elementtree.c
#_heapq -DPy_BUILD_CORE_MODULE _heapqmodule.c
#_json -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _json.c
#_heapq _heapqmodule.c
#_json _json.c
#_lsprof _lsprof.c rotatingtree.c
#_md5 -DPy_BUILD_CORE_BUILTIN md5module.c
#_md5 md5module.c
#_multibytecodec cjkcodecs/multibytecodec.c
#_opcode _opcode.c
#_pickle -DPy_BUILD_CORE_MODULE _pickle.c
#_posixsubprocess -DPy_BUILD_CORE_BUILTIN _posixsubprocess.c
#_queue -DPy_BUILD_CORE_MODULE _queuemodule.c
#_random -DPy_BUILD_CORE_MODULE _randommodule.c
#_sha1 -DPy_BUILD_CORE_BUILTIN sha1module.c
#_sha256 -DPy_BUILD_CORE_BUILTIN sha256module.c
#_sha512 -DPy_BUILD_CORE_BUILTIN sha512module.c
#_sha3 -DPy_BUILD_CORE_BUILTIN _sha3/sha3module.c
#_pickle _pickle.c
#_posixsubprocess _posixsubprocess.c
#_queue _queuemodule.c
#_random _randommodule.c
#_sha1 sha1module.c
#_sha256 sha256module.c
#_sha512 sha512module.c
#_sha3 _sha3/sha3module.c
#_statistics _statisticsmodule.c
#_struct -DPy_BUILD_CORE_MODULE _struct.c
#_struct _struct.c
#_typing _typingmodule.c
#_zoneinfo -DPy_BUILD_CORE_MODULE _zoneinfo.c
#array -DPy_BUILD_CORE_MODULE arraymodule.c
#_zoneinfo _zoneinfo.c
#array arraymodule.c
#audioop audioop.c
#binascii -DPy_BUILD_CORE_MODULE binascii.c
#cmath -DPy_BUILD_CORE_MODULE cmathmodule.c _math.c # -lm
#math -DPy_BUILD_CORE_MODULE mathmodule.c _math.c # -lm
#binascii binascii.c
#cmath cmathmodule.c _math.c # -lm
#math mathmodule.c _math.c # -lm
#pyexpat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
#unicodedata -DPy_BUILD_CORE_BUILTIN unicodedata.c
#unicodedata unicodedata.c

# Modules with some UNIX dependencies -- on by default:
# (If you have a really backward UNIX, select and socket may not be
Expand Down Expand Up @@ -286,7 +286,7 @@ time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c
# provided by the ncurses library. e.g. on Linux, link with -lncurses
# instead of -lcurses).

#_curses -DPy_BUILD_CORE_MODULE -lcurses -ltermcap _cursesmodule.c
#_curses -lcurses -ltermcap _cursesmodule.c

# Wrapper for the panel library that's part of ncurses and SYSV curses.
#_curses_panel -lpanel -lncurses _curses_panel.c
Expand All @@ -305,7 +305,7 @@ xxsubtype xxsubtype.c # Required for the test suite to pass!
#_testbuffer _testbuffer.c
#_testcapi _testcapimodule.c # CANNOT be statically compiled!
#_testimportmultiple _testimportmultiple.c
#_testinternalcapi -DPy_BUILD_CORE_MODULE -I$(srcdir)/Include/internal _testinternalcapi.c
#_testinternalcapi _testinternalcapi.c
#_testmultiphase _testmultiphase.c


Expand Down
3 changes: 3 additions & 0 deletions Modules/_abc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* ABCMeta implementation */
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
Expand Down
4 changes: 4 additions & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_pyerrors.h" // _PyErr_ClearExcState()
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down
4 changes: 4 additions & 0 deletions Modules/_blake2/blake2b_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* The blake2s_impl.c is autogenerated from blake2b_impl.c.
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()

Expand Down
4 changes: 4 additions & 0 deletions Modules/_blake2/blake2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* any warranty. http://creativecommons.org/publicdomain/zero/1.0/
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"

#include "impl/blake2.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_blake2/blake2s_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* The blake2s_impl.c is autogenerated from blake2s_impl.c.
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()

Expand Down
3 changes: 3 additions & 0 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ bytes(cdata)
* PyCField_Type
*
*/
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#define PY_SSIZE_T_CLEAN

Expand Down
4 changes: 4 additions & 0 deletions Modules/_ctypes/callbacks.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
Expand Down
4 changes: 4 additions & 0 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
Expand Down
4 changes: 4 additions & 0 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
// windows.h must be included before pycore internal headers
#ifdef MS_WIN32
Expand Down
4 changes: 4 additions & 0 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ static const char PyCursesVersion[] = "2.2";

/* Includes */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#define PY_SSIZE_T_CLEAN

#include "Python.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* the capsule are defined below */
#define _PY_DATETIME_IMPL

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_object.h" // _PyObject_Init()
Expand Down
3 changes: 3 additions & 0 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* SUCH DAMAGE.
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include <Python.h>
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down
4 changes: 4 additions & 0 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#endif
#define OPENSSL_NO_DEPRECATED 1

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#define PY_SSIZE_T_CLEAN

#include "Python.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_heapqmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ annotated by François Pinard, and converted to C by Raymond Hettinger.

*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_list.h" // _PyList_ITEMS()

Expand Down
4 changes: 2 additions & 2 deletions Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* and as an extension module (Py_BUILD_CORE_MODULE define) on other
* platforms. */

#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_lsprof.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_pystate.h" // _PyThreadState_GET()
Expand Down
4 changes: 4 additions & 0 deletions Modules/_math.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* Definitions of some C99 math library functions, for those platforms
that don't implement these functions already. */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include <float.h>
#include "_math.h"
Expand Down
4 changes: 2 additions & 2 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* and as an extension module (Py_BUILD_CORE_MODULE define) on other
* platforms. */

#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* Authors: Gregory P. Smith & Jeffrey Yasskin */
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_fileutils.h"
#if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
Expand Down
4 changes: 4 additions & 0 deletions Modules/_queuemodule.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "structmember.h" // PyMemberDef
Expand Down
4 changes: 4 additions & 0 deletions Modules/_randommodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@

/* ---------------------------------------------------------------*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#ifdef HAVE_PROCESS_H
Expand Down
4 changes: 4 additions & 0 deletions Modules/_sha3/sha3module.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*
*/

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()
#include "../hashlib.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
/* New version supporting byte order, alignment and size options,
character strings, and unsigned numbers */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#define PY_SSIZE_T_CLEAN

#include "Python.h"
Expand Down
4 changes: 2 additions & 2 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* C Extension module to test Python internal C APIs (Include/internal).
*/

#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE)
# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined"
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

/* Always enable assertions */
Expand Down
3 changes: 3 additions & 0 deletions Modules/_testmultiphase.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

/* Testing module for multi-phase initialization of extension modules (PEP 489)
*/
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_namespace.h" // _PyNamespace_New()
Expand Down
3 changes: 3 additions & 0 deletions Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

/* interpreters module */
/* low-level access to interpreter primitives */
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "frameobject.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"
#include "pycore_long.h" // _PyLong_GetOne()
#include "structmember.h"
Expand Down
4 changes: 4 additions & 0 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
/* An array is a uniform list -- all items have the same type.
The item type is restricted to simple C types like int or float */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_floatobject.h" // _PyFloat_Unpack4()
Expand Down
Loading