@@ -372,6 +372,7 @@ def __init__(self, dist):
372
372
self .parallel = True
373
373
374
374
def add (self , ext ):
375
+ ext .define_macros .append (("Py_BUILD_CORE_MODULE" , None ))
375
376
self .extensions .append (ext )
376
377
377
378
def set_srcdir (self ):
@@ -877,8 +878,7 @@ def detect_simple_extensions(self):
877
878
#
878
879
879
880
# array objects
880
- self .add (Extension ('array' , ['arraymodule.c' ],
881
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
881
+ self .add (Extension ('array' , ['arraymodule.c' ]))
882
882
883
883
# Context Variables
884
884
self .add (Extension ('_contextvars' , ['_contextvarsmodule.c' ]))
@@ -887,14 +887,12 @@ def detect_simple_extensions(self):
887
887
888
888
# math library functions, e.g. sin()
889
889
self .add (Extension ('math' , ['mathmodule.c' ],
890
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
891
890
extra_objects = [shared_math ],
892
891
depends = ['_math.h' , shared_math ],
893
892
libraries = ['m' ]))
894
893
895
894
# complex math library functions
896
895
self .add (Extension ('cmath' , ['cmathmodule.c' ],
897
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
898
896
extra_objects = [shared_math ],
899
897
depends = ['_math.h' , shared_math ],
900
898
libraries = ['m' ]))
@@ -911,43 +909,33 @@ def detect_simple_extensions(self):
911
909
# libm is needed by delta_new() that uses round() and by accum() that
912
910
# uses modf().
913
911
self .add (Extension ('_datetime' , ['_datetimemodule.c' ],
914
- libraries = ['m' ],
915
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
912
+ libraries = ['m' ]))
916
913
# zoneinfo module
917
- self .add (Extension ('_zoneinfo' , ['_zoneinfo.c' ],
918
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
914
+ self .add (Extension ('_zoneinfo' , ['_zoneinfo.c' ]))
919
915
# 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" ]))
922
917
# bisect
923
918
self .add (Extension ("_bisect" , ["_bisectmodule.c" ]))
924
919
# heapq
925
- self .add (Extension ("_heapq" , ["_heapqmodule.c" ],
926
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
920
+ self .add (Extension ("_heapq" , ["_heapqmodule.c" ]))
927
921
# 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" ]))
930
923
# _json speedups
931
- self .add (Extension ("_json" , ["_json.c" ],
932
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
924
+ self .add (Extension ("_json" , ["_json.c" ]))
933
925
934
926
# profiler (_lsprof is for cProfile.py)
935
927
self .add (Extension ('_lsprof' , ['_lsprof.c' , 'rotatingtree.c' ]))
936
928
# static Unicode character database
937
929
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' ]))
940
931
# _opcode module
941
932
self .add (Extension ('_opcode' , ['_opcode.c' ]))
942
933
# asyncio speedups
943
- self .add (Extension ("_asyncio" , ["_asynciomodule.c" ],
944
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
934
+ self .add (Extension ("_asyncio" , ["_asynciomodule.c" ]))
945
935
# _abc speedups
946
- self .add (Extension ("_abc" , ["_abc.c" ],
947
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
936
+ self .add (Extension ("_abc" , ["_abc.c" ]))
948
937
# _queue module
949
- self .add (Extension ("_queue" , ["_queuemodule.c" ],
950
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]))
938
+ self .add (Extension ("_queue" , ["_queuemodule.c" ]))
951
939
# _statistics module
952
940
self .add (Extension ("_statistics" , ["_statisticsmodule.c" ]))
953
941
@@ -1010,17 +998,15 @@ def detect_simple_extensions(self):
1010
998
self .add (Extension ('_csv' , ['_csv.c' ]))
1011
999
1012
1000
# 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' ]))
1015
1002
1016
1003
def detect_test_extensions (self ):
1017
1004
# Python C API test module
1018
1005
self .add (Extension ('_testcapi' , ['_testcapimodule.c' ],
1019
1006
depends = ['testcapi_long.h' ]))
1020
1007
1021
1008
# 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' ]))
1024
1010
1025
1011
# Python PEP-3118 (buffer protocol) test module
1026
1012
self .add (Extension ('_testbuffer' , ['_testbuffer.c' ]))
@@ -1160,7 +1146,6 @@ def detect_readline_curses(self):
1160
1146
if curses_library .startswith ('ncurses' ):
1161
1147
curses_libs = [curses_library ]
1162
1148
self .add (Extension ('_curses' , ['_cursesmodule.c' ],
1163
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
1164
1149
include_dirs = curses_includes ,
1165
1150
define_macros = curses_defines ,
1166
1151
libraries = curses_libs ))
@@ -1175,7 +1160,6 @@ def detect_readline_curses(self):
1175
1160
curses_libs = ['curses' ]
1176
1161
1177
1162
self .add (Extension ('_curses' , ['_cursesmodule.c' ],
1178
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
1179
1163
define_macros = curses_defines ,
1180
1164
libraries = curses_libs ))
1181
1165
else :
@@ -2199,7 +2183,7 @@ def detect_ctypes(self):
2199
2183
self .use_system_libffi = '--with-system-ffi' in sysconfig .get_config_var ("CONFIG_ARGS" )
2200
2184
2201
2185
include_dirs = []
2202
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ]
2186
+ extra_compile_args = []
2203
2187
extra_link_args = []
2204
2188
sources = ['_ctypes/_ctypes.c' ,
2205
2189
'_ctypes/callbacks.c' ,
@@ -2512,14 +2496,12 @@ def detect_hash_builtins(self):
2512
2496
if "sha256" in configured :
2513
2497
self .add (Extension (
2514
2498
'_sha256' , ['sha256module.c' ],
2515
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
2516
2499
depends = ['hashlib.h' ]
2517
2500
))
2518
2501
2519
2502
if "sha512" in configured :
2520
2503
self .add (Extension (
2521
2504
'_sha512' , ['sha512module.c' ],
2522
- extra_compile_args = ['-DPy_BUILD_CORE_MODULE' ],
2523
2505
depends = ['hashlib.h' ]
2524
2506
))
2525
2507
@@ -2714,9 +2696,12 @@ class DummyProcess:
2714
2696
'install_lib' : PyBuildInstallLib },
2715
2697
# The struct module is defined here, because build_ext won't be
2716
2698
# 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
+ ],
2720
2705
# If you change the scripts installed here, you also need to
2721
2706
# check the PyBuildScripts command above, and change the links
2722
2707
# created by the bininstall target in Makefile.pre.in
0 commit comments