1 From cbf8556ad057a402629a5be93dc77c906f3a86ab Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Wed, 23 Dec 2015 11:31:08 +0100
4 Subject: [PATCH] Add infrastructure to disable the build of certain extensions
6 Some of the extensions part of the Python core have dependencies on
7 external libraries (sqlite, tk, etc.) or are relatively big and not
8 necessarly always useful (CJK codecs for example). By extensions, we
9 mean part of Python modules that are written in C and therefore
10 compiled to binary code.
12 Therefore, we introduce a small infrastructure that allows to disable
13 some of those extensions. This can be done inside the configure.ac by
14 adding values to the DISABLED_EXTENSIONS variable (which is a
15 word-separated list of extensions).
17 The implementation works as follow :
19 * configure.ac defines a DISABLED_EXTENSIONS variable, which is
20 substituted (so that when Makefile.pre is generated from
21 Makefile.pre.in, the value of the variable is substituted). For
22 now, this DISABLED_EXTENSIONS variable is empty, later patches will
25 * Makefile.pre.in passes the DISABLED_EXTENSIONS value down to the
26 variables passed in the environment when calling the setup.py
27 script that actually builds and installs those extensions.
29 * setup.py is modified so that the existing "disabled_module_list" is
30 filled with those pre-disabled extensions listed in
33 Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>, and
34 then extended by Thomas Petazzoni
35 <thomas.petazzoni@free-electrons.com>.
37 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
39 Makefile.pre.in | 6 +++++-
42 3 files changed, 11 insertions(+), 2 deletions(-)
44 diff --git a/Makefile.pre.in b/Makefile.pre.in
45 index 6a7d974..d70375a 100644
48 @@ -182,6 +182,8 @@ FILEMODE= 644
49 # configure script arguments
50 CONFIG_ARGS= @CONFIG_ARGS@
52 +# disabled extensions
53 +DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@
55 # Subdirectories with code
57 @@ -607,6 +609,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
59 $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
60 _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
61 + DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
62 $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
64 # Build static library
65 @@ -1451,7 +1454,8 @@ libainstall: all python-config
66 # Install the dynamically loadable modules
67 # This goes into $(exec_prefix)
68 sharedinstall: sharedmods
69 - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
70 + $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
71 + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
73 --install-scripts=$(BINDIR) \
74 --install-platlib=$(DESTSHARED) \
75 diff --git a/configure.ac b/configure.ac
76 index f57f2eb..c43ff9f 100644
79 @@ -2670,6 +2670,8 @@ LIBS="$withval $LIBS"
83 +AC_SUBST(DISABLED_EXTENSIONS)
85 # Check for use of the system expat library
86 AC_MSG_CHECKING(for --with-system-expat)
87 AC_ARG_WITH(system_expat,
88 diff --git a/setup.py b/setup.py
89 index b67d913..149911c 100644
92 @@ -44,7 +44,10 @@ host_platform = get_platform()
93 COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
95 # This global variable is used to hold the list of modules to be disabled.
96 -disabled_module_list = []
98 + disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
100 + disabled_module_list = list()
102 def add_dir_to_list(dirlist, dir):
103 """Add the directory 'dir' to the list 'dirlist' (after any relative