Skip to content

Commit 4c95fb4

Browse files
authored
bpo-45548: Fix out-of-tree and Debian builds (GH-29263)
Add Modules subdirs to SRCDIRS to generate directories for out-of-tree object files. Debian wants ncurses lib. Works on Fedora, too. Debian also needs pkg-config to detect correct flags. Remove more outdated comments. Makefile now tracks header dependencies -lintl is injected by configure when needed. Build _dbm with gdbm-compat. Group some modules by purpose. socket, select, and mmap work on Windows, too.
1 parent b1302ab commit 4c95fb4

File tree

4 files changed

+87
-57
lines changed

4 files changed

+87
-57
lines changed

.github/workflows/posix-deps-apt.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apt-get update
33

44
apt-get -yq install \
55
build-essential \
6+
pkg-config \
67
ccache \
78
gdb \
89
lcov \

Modules/Setup

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
#
3939
# <name> = <value>
4040
#
41-
# which defines a Make variable definition inserted into Makefile.in
41+
# which defines a Make variable definition inserted into Makefile.in.
42+
# You can also use any Make variable that is detected by configure and
43+
# defined in Makefile.pre.in, e.g. OpenSSL flags $(OPENSSL_INCLUDES).
4244
#
4345
# The build process works like this:
4446
#
@@ -65,6 +67,11 @@
6567
# platform should be listed below. The distribution comes with all
6668
# modules enabled that are supported by most platforms and don't
6769
# require you to download sources from elsewhere.
70+
#
71+
# NOTE: Avoid editing this file directly. Local changes should go into
72+
# Modules/Setup.local file. To enable all modules for testing, run
73+
#
74+
# sed -n -E 's/^#([a-z_\*].*)$/\1/p' Modules/Setup > Modules/Setup.local
6875

6976

7077
# Some special rules to define PYTHONPATH.
@@ -103,12 +110,12 @@ _abc _abc.c
103110
_codecs _codecsmodule.c
104111
_functools _functoolsmodule.c
105112
_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
106-
_locale _localemodule.c # -lintl
113+
_locale _localemodule.c
107114
_operator _operator.c
108115
_signal signalmodule.c
109116
_sre _sre.c
110117
_stat _stat.c
111-
_symtable symtablemodule.c # setup.py can't track the .h file that _symtable depends on.
118+
_symtable symtablemodule.c
112119
_thread _threadmodule.c
113120
_tracemalloc _tracemalloc.c # See bpo-35053 as to why this is built in.
114121
_weakref _weakref.c
@@ -129,47 +136,30 @@ time timemodule.c
129136
# Python binary, or need to specify some odd set of compiler switches,
130137
# you can uncomment the appropriate lines below.
131138

132-
# To enable all modules for testing, run
133-
# sed -n -E 's/^#([a-z_\*].*)$/\1/p' Modules/Setup > Modules/Setup.local
134-
135139
# Uncommenting the following line tells makesetup that all following
136140
# modules are to be built as shared libraries (see above for more
137141
# detail; also note that *static* or *disabled* cancels this effect):
138142

139143
#*shared*
140144

141-
# Modules that should always be present (non UNIX dependent):
145+
# Modules that should always be present (POSIX and Windows):
142146

143147
#_asyncio _asynciomodule.c
144148
#_bisect _bisectmodule.c
145-
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
146-
#_codecs_cn cjkcodecs/_codecs_cn.c
147-
#_codecs_hk cjkcodecs/_codecs_hk.c
148-
#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
149-
#_codecs_jp cjkcodecs/_codecs_jp.c
150-
#_codecs_kr cjkcodecs/_codecs_kr.c
151-
#_codecs_tw cjkcodecs/_codecs_tw.c
152149
#_contextvars _contextvarsmodule.c
153150
#_csv _csv.c
154151
#_datetime _datetimemodule.c
155152
# UNIVERSAL: let mpdecimal.h detect settings
156153
#_decimal -DUNIVERSAL -I$(srcdir)/Modules/_decimal/libmpdec _decimal/_decimal.c _decimal/libmpdec/basearith.c _decimal/libmpdec/constants.c _decimal/libmpdec/context.c _decimal/libmpdec/convolute.c _decimal/libmpdec/crt.c _decimal/libmpdec/difradix2.c _decimal/libmpdec/fnt.c _decimal/libmpdec/fourstep.c _decimal/libmpdec/io.c _decimal/libmpdec/mpalloc.c _decimal/libmpdec/mpdecimal.c _decimal/libmpdec/numbertheory.c _decimal/libmpdec/sixstep.c _decimal/libmpdec/transpose.c
157-
#_elementtree -I$(srcdir)/Modules/expat _elementtree.c
158154
#_heapq _heapqmodule.c
159155
#_json _json.c
160156
#_lsprof _lsprof.c rotatingtree.c
161-
#_md5 md5module.c
162-
#_multibytecodec cjkcodecs/multibytecodec.c
163157
#_multiprocessing -I$(srcdir)/Modules/_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
164158
#_opcode _opcode.c
165159
#_pickle _pickle.c
166-
#_posixsubprocess _posixsubprocess.c
167160
#_queue _queuemodule.c
168161
#_random _randommodule.c
169-
#_sha1 sha1module.c
170-
#_sha256 sha256module.c
171-
#_sha512 sha512module.c
172-
#_sha3 _sha3/sha3module.c
162+
#_socket socketmodule.c
173163
#_statistics _statisticsmodule.c
174164
#_struct _struct.c
175165
#_typing _typingmodule.c
@@ -179,53 +169,65 @@ time timemodule.c
179169
#binascii binascii.c
180170
#cmath cmathmodule.c
181171
#math mathmodule.c
172+
#mmap mmapmodule.c
173+
#select selectmodule.c
174+
175+
# XML
176+
#_elementtree -I$(srcdir)/Modules/expat _elementtree.c
182177
#pyexpat -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
183-
#unicodedata unicodedata.c
184178

185-
# Modules with some UNIX dependencies -- on by default:
186-
# (If you have a really backward UNIX, select and socket may not be
187-
# supported...)
179+
# hashing builtins
180+
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
181+
#_md5 md5module.c
182+
#_sha1 sha1module.c
183+
#_sha256 sha256module.c
184+
#_sha512 sha512module.c
185+
#_sha3 _sha3/sha3module.c
188186

187+
# text encodings and unicode
188+
#_codecs_cn cjkcodecs/_codecs_cn.c
189+
#_codecs_hk cjkcodecs/_codecs_hk.c
190+
#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
191+
#_codecs_jp cjkcodecs/_codecs_jp.c
192+
#_codecs_kr cjkcodecs/_codecs_kr.c
193+
#_codecs_tw cjkcodecs/_codecs_tw.c
194+
#_multibytecodec cjkcodecs/multibytecodec.c
195+
#unicodedata unicodedata.c
196+
197+
# Modules with some UNIX dependencies
198+
199+
#_posixsubprocess _posixsubprocess.c
189200
#_posixshmem -I$(srcdir)/Modules/_multiprocessing _multiprocessing/posixshmem.c -lrt
190-
#_socket socketmodule.c # socket(2)
191-
#fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
192-
#grp grpmodule.c # grp(3)
193-
#mmap mmapmodule.c # Also works on win32.
201+
#fcntl fcntlmodule.c
202+
#grp grpmodule.c
194203
#ossaudiodev ossaudiodev.c
195-
#select selectmodule.c # select(2); not on ancient System V
196-
#spwd spwdmodule.c # spwd(3)
204+
#resource resource.c
205+
#spwd spwdmodule.c
197206
#syslog syslogmodule.c
207+
#termios termios.c
198208

199-
# Some more UNIX dependent modules -- off by default, since these
200-
# are not supported by all UNIX systems:
209+
# Modules with UNIX dependencies that require external libraries
201210

202-
#_crypt _cryptmodule.c -lcrypt # crypt(3); breaks many builds.
203-
#nis nismodule.c -I/usr/include/tirpc -lnsl -ltirpc # Sun yellow pages -- not everywhere
204-
#termios termios.c # Steen Lumholt's termios module
205-
#resource resource.c # Jeremy Hylton's rlimit interface
211+
#_crypt _cryptmodule.c -lcrypt
212+
#nis nismodule.c -I/usr/include/tirpc -lnsl -ltirpc
206213

207214
# Modules that require external libraries.
208215

209216
#_bz2 _bz2module.c -lbz2
210217
#_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -ldl -lffi -DHAVE_FFI_PREP_CIF_VAR -DHAVE_FFI_PREP_CLOSURE_LOC -DHAVE_FFI_CLOSURE_ALLOC
211-
# _dbm _dbmmodule.c # -lndbm # dbm(3)
218+
# The _dbm module supports NDBM, GDBM with compat module, and Berkeley DB.
219+
#_dbm _dbmmodule.c -lgdbm_compat -DHAVE_NDBM_H
212220
#_gdbm _gdbmmodule.c -lgdbm
213221
#_lzma _lzmamodule.c -llzma
214222
#_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -lsqlite3
215223
#_uuid _uuidmodule.c -luuid
216224
#zlib zlibmodule.c -lz
217225

218-
# GNU readline. Unlike previous Python incarnations, GNU readline is
219-
# now incorporated in an optional module, configured in the Setup file
220-
# instead of by a configure script switch. You may have to insert a
221-
# -L option pointing to the directory where libreadline.* lives,
222-
# and you may have to change -ltermcap to -ltermlib or perhaps remove
223-
# it, depending on your system -- see the GNU readline instructions.
224-
# It's okay for this to be a shared library, too.
225-
226+
# The readline module also supports libeditline (-leditline).
227+
# Some systems may require -ltermcap or -ltermlib.
226228
#readline readline.c -lreadline -ltermcap
227229

228-
# To dynamically link OpenSSL:
230+
# OpenSSL bindings
229231
#_ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) $(OPENSSL_LIBS)
230232
#_hashlib _hashopenssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) -lcrypto
231233

@@ -277,13 +279,8 @@ time timemodule.c
277279
# *** Always uncomment this; X11 libraries to link with:
278280
# -lX11
279281

280-
# Curses support, requiring the System V version of curses, often
281-
# provided by the ncurses library. e.g. on Linux, link with -lncurses
282-
# instead of -lcurses).
283-
284-
#_curses -lcurses -lcursesw -ltermcap _cursesmodule.c
285-
286-
# Wrapper for the panel library that's part of ncurses and SYSV curses.
282+
# Some system have -lcurses
283+
#_curses -lncurses -lncursesw -ltermcap _cursesmodule.c
287284
#_curses_panel -lpanel -lncurses _curses_panel.c
288285

289286
# macOS specific modules

configure

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17288,7 +17288,23 @@ do
1728817288
done
1728917289

1729017290

17291-
SRCDIRS="Parser Objects Python Modules Modules/_io Programs"
17291+
SRCDIRS="\
17292+
Modules \
17293+
Modules/_blake2 \
17294+
Modules/_ctypes \
17295+
Modules/_decimal \
17296+
Modules/_decimal/libmpdec \
17297+
Modules/_io \
17298+
Modules/_multiprocessing \
17299+
Modules/_sha3 \
17300+
Modules/_sqlite \
17301+
Modules/_xxtestfuzz \
17302+
Modules/cjkcodecs \
17303+
Modules/expat \
17304+
Objects \
17305+
Parser \
17306+
Programs \
17307+
Python"
1729217308
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for build directories" >&5
1729317309
$as_echo_n "checking for build directories... " >&6; }
1729417310
for dir in $SRCDIRS; do

configure.ac

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5636,7 +5636,23 @@ do
56365636
done
56375637

56385638
AC_SUBST(SRCDIRS)
5639-
SRCDIRS="Parser Objects Python Modules Modules/_io Programs"
5639+
SRCDIRS="\
5640+
Modules \
5641+
Modules/_blake2 \
5642+
Modules/_ctypes \
5643+
Modules/_decimal \
5644+
Modules/_decimal/libmpdec \
5645+
Modules/_io \
5646+
Modules/_multiprocessing \
5647+
Modules/_sha3 \
5648+
Modules/_sqlite \
5649+
Modules/_xxtestfuzz \
5650+
Modules/cjkcodecs \
5651+
Modules/expat \
5652+
Objects \
5653+
Parser \
5654+
Programs \
5655+
Python"
56405656
AC_MSG_CHECKING(for build directories)
56415657
for dir in $SRCDIRS; do
56425658
if test ! -d $dir; then

0 commit comments

Comments
 (0)