Skip to content

Commit 0af10ac

Browse files
author
Xavier de Gaye
committed
Issue python#28444: Merge with 3.6.
2 parents 0417949 + 0eacef3 commit 0af10ac

4 files changed

Lines changed: 28 additions & 23 deletions

File tree

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
# === Variables set by makesetup ===
2222

23+
MODNAMES= _MODNAMES_
2324
MODOBJS= _MODOBJS_
2425
MODLIBS= _MODLIBS_
2526

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ C API
357357
Build
358358
-----
359359

360+
- Issue #28444: Fix missing extensions modules when cross compiling.
361+
360362
- Issue #28208: Update Windows build to use SQLite 3.14.2.0.
361363

362364
- Issue #28248: Update Windows build to use OpenSSL 1.0.2j.

Modules/makesetup

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#
3030
# Copying Makefile.pre to Makefile:
3131
# - insert an identifying comment at the start
32+
# - replace _MODNAMES_ by the list of modules from Setup
3233
# - replace _MODOBJS_ by the list of objects from Setup (except for
3334
# Setup files after a -n option)
3435
# - replace _MODLIBS_ by the list of libraries from Setup
@@ -110,6 +111,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
110111
# Rules appended by makedepend
111112
" >$rulesf
112113
DEFS=
114+
NAMES=
113115
MODS=
114116
SHAREDMODS=
115117
OBJS=
@@ -181,7 +183,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
181183
*.*) echo 1>&2 "bad word $arg in $line"
182184
exit 1;;
183185
-u) skip=libs; libs="$libs -u";;
184-
[a-zA-Z_]*) mods="$mods $arg";;
186+
[a-zA-Z_]*) NAMES="$NAMES $arg"; mods="$mods $arg";;
185187
*) echo 1>&2 "bad word $arg in $line"
186188
exit 1;;
187189
esac
@@ -280,6 +282,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
280282
echo "1i\\" >$sedf
281283
str="# Generated automatically from $makepre by makesetup."
282284
echo "$str" >>$sedf
285+
echo "s%_MODNAMES_%$NAMES%" >>$sedf
283286
echo "s%_MODOBJS_%$OBJS%" >>$sedf
284287
echo "s%_MODLIBS_%$LIBS%" >>$sedf
285288
echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf

setup.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sysconfig
99

1010
from distutils import log
11-
from distutils import text_file
1211
from distutils.errors import *
1312
from distutils.core import Extension, setup
1413
from distutils.command.build_ext import build_ext
@@ -230,7 +229,12 @@ def build_extensions(self):
230229
headers = [sysconfig.get_config_h_filename()]
231230
headers += glob(os.path.join(sysconfig.get_path('include'), "*.h"))
232231

233-
for ext in self.extensions[:]:
232+
# The sysconfig variable built by makesetup, listing the already
233+
# built modules as configured by the Setup files.
234+
modnames = sysconfig.get_config_var('MODNAMES').split()
235+
236+
removed_modules = []
237+
for ext in self.extensions:
234238
ext.sources = [ find_module_file(filename, moddirlist)
235239
for filename in ext.sources ]
236240
if ext.depends is not None:
@@ -241,26 +245,14 @@ def build_extensions(self):
241245
# re-compile extensions if a header file has been changed
242246
ext.depends.extend(headers)
243247

244-
# If a module has already been built statically,
245-
# don't build it here
246-
if ext.name in sys.builtin_module_names:
247-
self.extensions.remove(ext)
248-
249-
# Parse Modules/Setup and Modules/Setup.local to figure out which
250-
# modules are turned on in the file.
251-
remove_modules = []
252-
for filename in ('Modules/Setup', 'Modules/Setup.local'):
253-
input = text_file.TextFile(filename, join_lines=1)
254-
while 1:
255-
line = input.readline()
256-
if not line: break
257-
line = line.split()
258-
remove_modules.append(line[0])
259-
input.close()
260-
261-
for ext in self.extensions[:]:
262-
if ext.name in remove_modules:
263-
self.extensions.remove(ext)
248+
# If a module has already been built by the Makefile,
249+
# don't build it here.
250+
if ext.name in modnames:
251+
removed_modules.append(ext)
252+
253+
if removed_modules:
254+
self.extensions = [x for x in self.extensions if x not in
255+
removed_modules]
264256

265257
# When you run "make CC=altcc" or something similar, you really want
266258
# those environment variables passed into the setup.py phase. Here's
@@ -303,6 +295,13 @@ def print_three_column(lst):
303295
" detect_modules() for the module's name.")
304296
print()
305297

298+
if removed_modules:
299+
print("The following modules found by detect_modules() in"
300+
" setup.py, have been")
301+
print("built by the Makefile instead, as configured by the"
302+
" Setup files:")
303+
print_three_column([ext.name for ext in removed_modules])
304+
306305
if self.failed:
307306
failed = self.failed[:]
308307
print()

0 commit comments

Comments
 (0)