@@ -372,6 +372,7 @@ def __init__(self, dist):
372372 self .parallel = True
373373
374374 def add (self , ext ):
375+ ext .define_macros .append (("Py_BUILD_CORE_MODULE" , None ))
375376 self .extensions .append (ext )
376377
377378 def set_srcdir (self ):
@@ -877,8 +878,7 @@ def detect_simple_extensions(self):
877878 #
878879
879880 # array objects
880- self .add (Extension ('array' , ['arraymodule.c' ],
881- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
881+ self .add (Extension ('array' , ['arraymodule.c' ]))
882882
883883 # Context Variables
884884 self .add (Extension ('_contextvars' , ['_contextvarsmodule.c' ]))
@@ -887,14 +887,12 @@ def detect_simple_extensions(self):
887887
888888 # math library functions, e.g. sin()
889889 self .add (Extension ('math' , ['mathmodule.c' ],
890- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
891890 extra_objects = [shared_math ],
892891 depends = ['_math.h' , shared_math ],
893892 libraries = ['m' ]))
894893
895894 # complex math library functions
896895 self .add (Extension ('cmath' , ['cmathmodule.c' ],
897- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
898896 extra_objects = [shared_math ],
899897 depends = ['_math.h' , shared_math ],
900898 libraries = ['m' ]))
@@ -911,43 +909,33 @@ def detect_simple_extensions(self):
911909 # libm is needed by delta_new() that uses round() and by accum() that
912910 # uses modf().
913911 self .add (Extension ('_datetime' , ['_datetimemodule.c' ],
914- libraries = ['m' ],
915- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
912+ libraries = ['m' ]))
916913 # zoneinfo module
917- self .add (Extension ('_zoneinfo' , ['_zoneinfo.c' ],
918- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
914+ self .add (Extension ('_zoneinfo' , ['_zoneinfo.c' ]))
919915 # random number generator implemented in C
920- self .add (Extension ("_random" , ["_randommodule.c" ],
921- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
916+ self .add (Extension ("_random" , ["_randommodule.c" ]))
922917 # bisect
923918 self .add (Extension ("_bisect" , ["_bisectmodule.c" ]))
924919 # heapq
925- self .add (Extension ("_heapq" , ["_heapqmodule.c" ],
926- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
920+ self .add (Extension ("_heapq" , ["_heapqmodule.c" ]))
927921 # C-optimized pickle replacement
928- self .add (Extension ("_pickle" , ["_pickle.c" ],
929- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
922+ self .add (Extension ("_pickle" , ["_pickle.c" ]))
930923 # _json speedups
931- self .add (Extension ("_json" , ["_json.c" ],
932- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
924+ self .add (Extension ("_json" , ["_json.c" ]))
933925
934926 # profiler (_lsprof is for cProfile.py)
935927 self .add (Extension ('_lsprof' , ['_lsprof.c' , 'rotatingtree.c' ]))
936928 # static Unicode character database
937929 self .add (Extension ('unicodedata' , ['unicodedata.c' ],
938- depends = ['unicodedata_db.h' , 'unicodename_db.h' ],
939- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
930+ depends = ['unicodedata_db.h' , 'unicodename_db.h' ]))
940931 # _opcode module
941932 self .add (Extension ('_opcode' , ['_opcode.c' ]))
942933 # asyncio speedups
943- self .add (Extension ("_asyncio" , ["_asynciomodule.c" ],
944- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
934+ self .add (Extension ("_asyncio" , ["_asynciomodule.c" ]))
945935 # _abc speedups
946- self .add (Extension ("_abc" , ["_abc.c" ],
947- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
936+ self .add (Extension ("_abc" , ["_abc.c" ]))
948937 # _queue module
949- self .add (Extension ("_queue" , ["_queuemodule.c" ],
950- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
938+ self .add (Extension ("_queue" , ["_queuemodule.c" ]))
951939 # _statistics module
952940 self .add (Extension ("_statistics" , ["_statisticsmodule.c" ]))
953941
@@ -1010,17 +998,15 @@ def detect_simple_extensions(self):
1010998 self .add (Extension ('_csv' , ['_csv.c' ]))
1011999
10121000 # POSIX subprocess module helper.
1013- self .add (Extension ('_posixsubprocess' , ['_posixsubprocess.c' ],
1014- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
1001+ self .add (Extension ('_posixsubprocess' , ['_posixsubprocess.c' ]))
10151002
10161003 def detect_test_extensions (self ):
10171004 # Python C API test module
10181005 self .add (Extension ('_testcapi' , ['_testcapimodule.c' ],
10191006 depends = ['testcapi_long.h' ]))
10201007
10211008 # Python Internal C API test module
1022- self .add (Extension ('_testinternalcapi' , ['_testinternalcapi.c' ],
1023- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
1009+ self .add (Extension ('_testinternalcapi' , ['_testinternalcapi.c' ]))
10241010
10251011 # Python PEP-3118 (buffer protocol) test module
10261012 self .add (Extension ('_testbuffer' , ['_testbuffer.c' ]))
@@ -1160,7 +1146,6 @@ def detect_readline_curses(self):
11601146 if curses_library .startswith ('ncurses' ):
11611147 curses_libs = [curses_library ]
11621148 self .add (Extension ('_curses' , ['_cursesmodule.c' ],
1163- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
11641149 include_dirs = curses_includes ,
11651150 define_macros = curses_defines ,
11661151 libraries = curses_libs ))
@@ -1175,7 +1160,6 @@ def detect_readline_curses(self):
11751160 curses_libs = ['curses' ]
11761161
11771162 self .add (Extension ('_curses' , ['_cursesmodule.c' ],
1178- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
11791163 define_macros = curses_defines ,
11801164 libraries = curses_libs ))
11811165 else :
@@ -2199,7 +2183,7 @@ def detect_ctypes(self):
21992183 self .use_system_libffi = '--with-system-ffi' in sysconfig .get_config_var ("CONFIG_ARGS" )
22002184
22012185 include_dirs = []
2202- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]
2186+ extra_compile_args = []
22032187 extra_link_args = []
22042188 sources = ['_ctypes/_ctypes.c' ,
22052189 '_ctypes/callbacks.c' ,
@@ -2512,14 +2496,12 @@ def detect_hash_builtins(self):
25122496 if "sha256" in configured :
25132497 self .add (Extension (
25142498 '_sha256' , ['sha256module.c' ],
2515- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
25162499 depends = ['hashlib.h' ]
25172500 ))
25182501
25192502 if "sha512" in configured :
25202503 self .add (Extension (
25212504 '_sha512' , ['sha512module.c' ],
2522- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
25232505 depends = ['hashlib.h' ]
25242506 ))
25252507
@@ -2714,9 +2696,12 @@ class DummyProcess:
27142696 'install_lib' : PyBuildInstallLib },
27152697 # The struct module is defined here, because build_ext won't be
27162698 # called unless there's at least one extension module defined.
2717- ext_modules = [Extension ('_struct' , ['_struct.c' ],
2718- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ])],
2719-
2699+ ext_modules = [
2700+ Extension (
2701+ '_struct' , ['_struct.c' ],
2702+ define_macros = [('Py_BUILD_CORE_MODULE' , None )]
2703+ )
2704+ ],
27202705 # If you change the scripts installed here, you also need to
27212706 # check the PyBuildScripts command above, and change the links
27222707 # created by the bininstall target in Makefile.pre.in
0 commit comments