8000 bpo-45573: Move mandatory core modules to Modules/Setup.bootstrap (GH… · python/cpython@7e44dc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e44dc0

Browse files
authored
bpo-45573: Move mandatory core modules to Modules/Setup.bootstrap (GH-29616)
1 parent d64659d commit 7e44dc0

File tree

8 files changed

+136
-36
lines changed

8 files changed

+136
-36
lines changed

Makefile.pre.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,12 @@ Makefile Modules/config.c: Makefile.pre \
910910
$(MAKESETUP) \
911911
$(srcdir)/Modules/Setup \
912912
Modules/Setup.local \
913+
$(srcdir)/Modules/Setup.bootstrap \
913914
Modules/Setup.stdlib
914915
$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
915916
-s Modules \
916917
Modules/Setup.local \
918+
$(srcdir)/Modules/Setup.bootstrap \
917919
$(srcdir)/Modules/Setup
918920
@mv config.c Modules
919921
@echo "The Makefile was updated, you may need to re-run make."
@@ -2167,6 +2169,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
21672169
$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
21682170
$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
21692171
$(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup
2172+
$(INSTALL_DATA) $(srcdir)/Modules/Setup.bootstrap $(DESTDIR)$(LIBPL)/Setup.bootstrap
21702173
$(INSTALL_DATA) Modules/Setup.stdlib $(DESTDIR)$(LIBPL)/Setup.stdlib
21712174
$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
21722175
$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Mandatory core modules, that are required to bootstrap Python, are now in
2+
``Modules/Setup.bootstrap``.

Modules/Setup

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,8 @@ PYTHONPATH=$(COREPYTHONPATH)
111111

112112

113113
# ---
114-
# Built-in modules required to get a functioning interpreter;
115-
# cannot be built as shared!
116-
117-
_collections _collectionsmodule.c
118-
_abc _abc.c
119-
_codecs _codecsmodule.c
120-
_functools _functoolsmodule.c
121-
_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
122-
_locale _localemodule.c
123-
_operator _operator.c
124-
_signal signalmodule.c
125-
_sre _sre.c
126-
_stat _stat.c
127-
_symtable symtablemodule.c
128-
_thread _threadmodule.c
129-
_tracemalloc _tracemalloc.c # See bpo-35053 as to why this is built in.
130-
_weakref _weakref.c
131-
atexit atexitmodule.c
132-
errno errnomodule.c
133-
faulthandler faulthandler.c
134-
itertools itertoolsmodule.c
135-
posix posixmodule.c
136-
pwd pwdmodule.c
137-
time timemodule.c
138-
114+
# Built-in modules required to get a functioning interpreter are listed in
115+
# Modules/Setup.bootstrap.
139116

140117
# ---
141118
# The rest of the modules listed in this file are all commented out by

Modules/Setup.bootstrap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- makefile -*-
2+
3+
# ---
4+
# Built-in modules required to get a functioning interpreter;
5+
# cannot be built as shared!
6+
7+
# module C APIs are used in core
8+
atexit atexitmodule.c
9+
faulthandler faulthandler.c
10+
posix posixmodule.c
11+
_signal signalmodule.c
12+
_tracemalloc _tracemalloc.c
13+
14+
# modules used by importlib, deepfreeze, freeze, runpy, and sysconfig
15+
_codecs _codecsmodule.c
16+
_collections _collectionsmodule.c
17+
errno errnomodule.c
18+
_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
19+
itertools itertoolsmodule.c
20+
_sre _sre.c
21+
_thread _threadmodule.c
22+
time timemodule.c
23+
_weakref _weakref.c
24+
25+
# commonly used core modules
26+
_abc _abc.c
27+
_functools _functoolsmodule.c
28+
_locale _localemodule.c
29+
_operator _operator.c
30+
_stat _stat.c
31+
_symtable symtablemodule.c
32+
33+
# for systems without $HOME env, used by site._getuserbase()
34+
pwd pwdmodule.c

Modules/Setup.stdlib.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
############################################################################
3030
# Modules that should always be present (POSIX and Windows):
3131

32+
# needs libm and on some platforms librt
33+
@MODULE__DATETIME_TRUE@_datetime _datetimemodule.c
34+
3235
# _decimal uses libmpdec
3336
# either static libmpdec.a from Modules/_decimal/libmpdec or libmpdec.so
3437
# with ./configure --with-system-libmpdec

configure

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,12 @@ MODULE_PYEXPAT_FALSE
634634
MODULE_PYEXPAT_TRUE
635635
MODULE_OSSAUDIODEV_FALSE
636636
MODULE_OSSAUDIODEV_TRUE
637+
MODULE__DATETIME_FALSE
638+
MODULE__DATETIME_TRUE
639+
MODULE_TIME_FALSE
640+
MODULE_TIME_TRUE
641+
MODULE__IO_FALSE
642+
MODULE__IO_TRUE
637643
TEST_MODULES
638644
LIBRARY_DEPS
639645
STATIC_LIBPYTHON
@@ -19456,6 +19462,52 @@ MODULE_BLOCK=
1945619462

1945719463

1945819464

19465+
19466+
19467+
if true; then
19468+
MODULE__IO_TRUE=
19469+
MODULE__IO_FALSE='#'
19470+
else
19471+
MODULE__IO_TRUE='#'
19472+
MODULE__IO_FALSE=
19473+
fi
19474+
19475+
19476+
as_fn_append MODULE_BLOCK "MODULE__IO_CFLAGS=-I\$(srcdir)/Modules/_io$as_nl"
19477+
19478+
19479+
19480+
19481+
if true; then
19482+
MODULE_TIME_TRUE=
19483+
MODULE_TIME_FALSE='#'
19484+
else
19485+
MODULE_TIME_TRUE='#'
19486+
MODULE_TIME_FALSE=
19487+
fi
19488+
19489+
19490+
19491+
as_fn_append MODULE_BLOCK "MODULE_TIME_LDFLAGS=$TIMEMODULE_LIB$as_nl"
19492+
19493+
19494+
19495+
19496+
if true; then
19497+
MODULE__DATETIME_TRUE=
19498+
MODULE__DATETIME_FALSE='#'
19499+
else
19500+
MODULE__DATETIME_TRUE='#'
19501+
MODULE__DATETIME_FALSE=
19502+
fi
19503+
19504+
19505+
19506+
as_fn_append MODULE_BLOCK "MODULE__DATETIME_LDFLAGS=$TIMEMODULE_LIB $LIBM$as_nl"
19507+
19508+
19509+
19510+
1945919511
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module ossaudiodev" >&5
1946019512
$as_echo_n "checking for stdlib extension module ossaudiodev... " >&6; }
1946119513
case $py_stdlib_not_available in #(
@@ -19828,6 +19880,18 @@ LTLIBOBJS=$ac_ltlibobjs
1982819880

1982919881

1983019882

19883+
if test -z "${MODULE__IO_TRUE}" && test -z "${MODULE__IO_FALSE}"; then
19884+
as_fn_error $? "conditional \"MODULE__IO\" was never defined.
19885+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
19886+
fi
19887+
if test -z "${MODULE_TIME_TRUE}" && test -z "${MODULE_TIME_FALSE}"; then
19888+
as_fn_error $? "conditional \"MODULE_TIME\" was never defined.
19889+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
19890+
fi
19891+
if test -z "${MODULE__DATETIME_TRUE}" && test -z "${MODULE__DATETIME_FALSE}"; then
19892+
as_fn_error $? "conditional \"MODULE__DATETIME\" was never defined.
19893+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
19894+
fi
1983119895
if test -z "${MODULE_OSSAUDIODEV_TRUE}" && test -z "${MODULE_OSSAUDIODEV_FALSE}"; then
1983219896
as_fn_error $? "conditional \"MODULE_OSSAUDIODEV\" was never defined.
1983319897
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -21068,7 +21132,7 @@ fi
2106821132
echo "creating Makefile" >&6
2106921133
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
2107021134
-s Modules \
21071-
Modules/Setup.local $srcdir/Modules/Setup
21135+
Modules/Setup.local $srcdir/Modules/Setup.bootstrap $srcdir/Modules/Setup
2107221136
mv config.c Modules
2107321137

2107421138
if test -z "$PKG_CONFIG"; then

configure.ac

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6030,6 +6030,28 @@ AC_DEFUN([PY_STDLIB_MOD], [
60306030
m4_popdef([modstate])dnl
60316031
])
60326032

6033+
dnl Define simple, always enabled stdlib extension module
6034+
dnl PY_STDLIB_MOD_SIMPLE([NAME], [CFLAGS], [LDFLAGS])
6035+
dnl cflags and ldflags are optional
6036+
AC_DEFUN([PY_STDLIB_MOD_SIMPLE], [
6037+
m4_pushdef([modcond], [MODULE_]m4_toupper([$1]))dnl
6038+
AM_CONDITIONAL(modcond, [true])
6039+
m4_ifval([$2], [
6040+
_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_CFLAGS], [$2])
6041+
])
6042+
m4_ifval([$3], [
6043+
_MODULE_BLOCK_ADD([MODULE_]m4_toupper([$1])[_LDFLAGS], [$3])
6044+
])
6045+
m4_popdef([modcond])dnl
6046+
])
6047+
6048+
dnl static modules in Modules/Setup.bootstrap
6049+
PY_STDLIB_MOD_SIMPLE([_io], [-I\$(srcdir)/Modules/_io], [])
6050+
PY_STDLIB_MOD_SIMPLE([time], [], [$TIMEMODULE_LIB])
6051+
6052+
dnl always enabled extension modules
6053+
PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM])
6054+
60336055
dnl platform specific extensions
60346056
PY_STDLIB_MOD([ossaudiodev],
60356057
[], [test "$ac_cv_header_linux_soundcard_h" = yes -o "$ac_cv_header_sys_soundcard_h" = yes])
@@ -6062,7 +6084,7 @@ fi
60626084
echo "creating Makefile" >&AS_MESSAGE_FD
60636085
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
60646086
-s Modules \
6065-
Modules/Setup.local $srcdir/Modules/Setup
6087+
Modules/Setup.local $srcdir/Modules/Setup.bootstrap $srcdir/Modules/Setup
60666088
mv config.c Modules
60676089

60686090
if test -z "$PKG_CONFIG"; then

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,13 +1006,9 @@ def detect_simple_extensions(self):
10061006
if lib:
10071007
time_libs.append(lib)
10081008

1009-
# time operations and variables
1010-
self.add(Extension('time', ['timemodule.c'],
1011-
libraries=time_libs))
10121009
# libm is needed by delta_new() that uses round() and by accum() that
10131010
# uses modf().
1014-
self.add(Extension('_datetime', ['_datetimemodule.c'],
1015-
libraries=['m']))
1011+
self.addext(Extension('_datetime', ['_datetimemodule.c']))
10161012
# zoneinfo module
10171013
self.add(Extension('_zoneinfo', ['_zoneinfo.c']))
10181014
# random number generator implemented in C
@@ -1034,8 +1030,6 @@ def detect_simple_extensions(self):
10341030
self.add(Extension('_opcode', ['_opcode.c']))
10351031
# asyncio speedups
10361032
self.add(Extension("_asyncio", ["_asynciomodule.c"]))
1037-
# _abc speedups
1038-
self.add(Extension("_abc", ["_abc.c"]))
10391033
# _queue module
10401034
self.add(Extension("_queue", ["_queuemodule.c"]))
10411035
# _statistics module
@@ -1054,8 +1048,6 @@ def detect_simple_extensions(self):
10541048
libs = ['bsd']
10551049
self.add(Extension('fcntl', ['fcntlmodule.c'],
10561050
libraries=libs))
1057-
# pwd(3)
1058-
self.add(Extension('pwd', ['pwdmodule.c']))
10591051
# grp(3)
10601052
if not VXWORKS:
10611053
self.add(Extension('grp', ['grpmodule.c']))
@@ -1510,6 +1502,9 @@ def detect_modules(self):
15101502
self.configure_compiler()
15111503
self.init_inc_lib_dirs()
15121504

1505+
# Some C extensions are built by entries in Modules/Setup.bootstrap.
1506+
# These are extensions are required to bootstrap the interpreter or
1507+
# build process.
15131508
self.detect_simple_extensions()
15141509
if TEST_EXTENSIONS:
15151510
self.detect_test_extensions()

0 commit comments

Comments
 (0)
0