1*4882a593SmuzhiyunFrom df7c95b4ceecf390b961d843a556c470ac9080b2 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 3*4882a593SmuzhiyunDate: Wed, 22 Feb 2017 16:33:22 -0800 4*4882a593SmuzhiyunSubject: [PATCH] Add infrastructure to disable the build of certain extensions 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunSome of the extensions part of the Python core have dependencies on 7*4882a593Smuzhiyunexternal libraries (sqlite, tk, etc.) or are relatively big and not 8*4882a593Smuzhiyunnecessarly always useful (CJK codecs for example). By extensions, we 9*4882a593Smuzhiyunmean part of Python modules that are written in C and therefore 10*4882a593Smuzhiyuncompiled to binary code. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunTherefore, we introduce a small infrastructure that allows to disable 13*4882a593Smuzhiyunsome of those extensions. This can be done inside the configure.ac by 14*4882a593Smuzhiyunadding values to the DISABLED_EXTENSIONS variable (which is a 15*4882a593Smuzhiyunword-separated list of extensions). 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunThe implementation works as follow : 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun * configure.ac defines a DISABLED_EXTENSIONS variable, which is 20*4882a593Smuzhiyun substituted (so that when Makefile.pre is generated from 21*4882a593Smuzhiyun Makefile.pre.in, the value of the variable is substituted). For 22*4882a593Smuzhiyun now, this DISABLED_EXTENSIONS variable is empty, later patches will 23*4882a593Smuzhiyun use it. 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun * Makefile.pre.in passes the DISABLED_EXTENSIONS value down to the 26*4882a593Smuzhiyun variables passed in the environment when calling the setup.py 27*4882a593Smuzhiyun script that actually builds and installs those extensions. 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun * setup.py is modified so that the existing "disabled_module_list" is 30*4882a593Smuzhiyun filled with those pre-disabled extensions listed in 31*4882a593Smuzhiyun DISABLED_EXTENSIONS. 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunPatch ported to python2.7 by Maxime Ripard <ripard@archos.com>, and 34*4882a593Smuzhiyunthen extended by Thomas Petazzoni 35*4882a593Smuzhiyun<thomas.petazzoni@free-electrons.com>. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunSigned-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 38*4882a593Smuzhiyun[ Andrey Smirnov: ported to Python 3.6 ] 39*4882a593SmuzhiyunSigned-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> 40*4882a593Smuzhiyun--- 41*4882a593Smuzhiyun Makefile.pre.in | 6 +++++- 42*4882a593Smuzhiyun configure.ac | 2 ++ 43*4882a593Smuzhiyun setup.py | 5 ++++- 44*4882a593Smuzhiyun 3 files changed, 11 insertions(+), 2 deletions(-) 45*4882a593Smuzhiyun 46*4882a593Smuzhiyundiff --git a/Makefile.pre.in b/Makefile.pre.in 47*4882a593Smuzhiyunindex 0c809f3d8a..7c3dde8dd4 100644 48*4882a593Smuzhiyun--- a/Makefile.pre.in 49*4882a593Smuzhiyun+++ b/Makefile.pre.in 50*4882a593Smuzhiyun@@ -218,6 +218,8 @@ FILEMODE= 644 51*4882a593Smuzhiyun # configure script arguments 52*4882a593Smuzhiyun CONFIG_ARGS= @CONFIG_ARGS@ 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun+# disabled extensions 55*4882a593Smuzhiyun+DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@ 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun # Subdirectories with code 58*4882a593Smuzhiyun SRCDIRS= @SRCDIRS@ 59*4882a593Smuzhiyun@@ -628,6 +630,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o 60*4882a593Smuzhiyun esac; \ 61*4882a593Smuzhiyun echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ 62*4882a593Smuzhiyun _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ 63*4882a593Smuzhiyun+ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \ 64*4882a593Smuzhiyun $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ 65*4882a593Smuzhiyun $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ 66*4882a593Smuzhiyun _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ 67*4882a593Smuzhiyun@@ -1748,7 +1751,8 @@ libainstall: @DEF_MAKE_RULE@ python-config 68*4882a593Smuzhiyun # Install the dynamically loadable modules 69*4882a593Smuzhiyun # This goes into $(exec_prefix) 70*4882a593Smuzhiyun sharedinstall: sharedmods 71*4882a593Smuzhiyun- $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ 72*4882a593Smuzhiyun+ $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \ 73*4882a593Smuzhiyun+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ 74*4882a593Smuzhiyun --prefix=$(prefix) \ 75*4882a593Smuzhiyun --install-scripts=$(BINDIR) \ 76*4882a593Smuzhiyun --install-platlib=$(DESTSHARED) \ 77*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac 78*4882a593Smuzhiyunindex c2445edc88..73d66167de 100644 79*4882a593Smuzhiyun--- a/configure.ac 80*4882a593Smuzhiyun+++ b/configure.ac 81*4882a593Smuzhiyun@@ -3091,6 +3091,8 @@ LIBS="$withval $LIBS" 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun PKG_PROG_PKG_CONFIG 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun+AC_SUBST(DISABLED_EXTENSIONS) 86*4882a593Smuzhiyun+ 87*4882a593Smuzhiyun # Check for use of the system expat library 88*4882a593Smuzhiyun AC_MSG_CHECKING(for --with-system-expat) 89*4882a593Smuzhiyun AC_ARG_WITH(system_expat, 90*4882a593Smuzhiyundiff --git a/setup.py b/setup.py 91*4882a593Smuzhiyunindex 770866bca7..b6c829b3a5 100644 92*4882a593Smuzhiyun--- a/setup.py 93*4882a593Smuzhiyun+++ b/setup.py 94*4882a593Smuzhiyun@@ -58,7 +58,10 @@ with warnings.catch_warnings(): 95*4882a593Smuzhiyun TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes') 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun # This global variable is used to hold the list of modules to be disabled. 98*4882a593Smuzhiyun-DISABLED_MODULE_LIST = [] 99*4882a593Smuzhiyun+try: 100*4882a593Smuzhiyun+ DISABLED_MODULE_LIST = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ") 101*4882a593Smuzhiyun+except KeyError: 102*4882a593Smuzhiyun+ DISABLED_MODULE_LIST = list() 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun # --list-module-names option used by Tools/scripts/generate_module_names.py 105*4882a593Smuzhiyun LIST_MODULE_NAMES = False 106*4882a593Smuzhiyun-- 107*4882a593Smuzhiyun2.25.1 108*4882a593Smuzhiyun 109