0005-Add-infrastructure-to-disable-the-build-of-certain-e.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 3a9f4aa255909ed152883eee787313efd20dbc58 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
  5. Some of the extensions part of the Python core have dependencies on
  6. external libraries (sqlite, tk, etc.) or are relatively big and not
  7. necessarly always useful (CJK codecs for example). By extensions, we
  8. mean part of Python modules that are written in C and therefore
  9. compiled to binary code.
  10. Therefore, we introduce a small infrastructure that allows to disable
  11. some of those extensions. This can be done inside the configure.ac by
  12. adding values to the DISABLED_EXTENSIONS variable (which is a
  13. word-separated list of extensions).
  14. The implementation works as follow :
  15. * configure.ac defines a DISABLED_EXTENSIONS variable, which is
  16. substituted (so that when Makefile.pre is generated from
  17. Makefile.pre.in, the value of the variable is substituted). For
  18. now, this DISABLED_EXTENSIONS variable is empty, later patches will
  19. use it.
  20. * Makefile.pre.in passes the DISABLED_EXTENSIONS value down to the
  21. variables passed in the environment when calling the setup.py
  22. script that actually builds and installs those extensions.
  23. * setup.py is modified so that the existing "disabled_module_list" is
  24. filled with those pre-disabled extensions listed in
  25. DISABLED_EXTENSIONS.
  26. Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>, and
  27. then extended by Thomas Petazzoni
  28. <thomas.petazzoni@free-electrons.com>.
  29. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  30. ---
  31. Makefile.pre.in | 6 +++++-
  32. configure.ac | 2 ++
  33. setup.py | 5 ++++-
  34. 3 files changed, 11 insertions(+), 2 deletions(-)
  35. diff --git a/Makefile.pre.in b/Makefile.pre.in
  36. index 272f312..9420860 100644
  37. --- a/Makefile.pre.in
  38. +++ b/Makefile.pre.in
  39. @@ -182,6 +182,8 @@ FILEMODE= 644
  40. # configure script arguments
  41. CONFIG_ARGS= @CONFIG_ARGS@
  42. +# disabled extensions
  43. +DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@
  44. # Subdirectories with code
  45. SRCDIRS= @SRCDIRS@
  46. @@ -600,6 +602,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
  47. esac; \
  48. $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
  49. _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
  50. + DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
  51. $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
  52. # Build static library
  53. @@ -1425,7 +1428,8 @@ libainstall: all python-config
  54. # Install the dynamically loadable modules
  55. # This goes into $(exec_prefix)
  56. sharedinstall: sharedmods
  57. - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  58. + $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
  59. + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  60. --prefix=$(prefix) \
  61. --install-scripts=$(BINDIR) \
  62. --install-platlib=$(DESTSHARED) \
  63. diff --git a/configure.ac b/configure.ac
  64. index c492594..bfb599e 100644
  65. --- a/configure.ac
  66. +++ b/configure.ac
  67. @@ -2588,6 +2588,8 @@ LIBS="$withval $LIBS"
  68. PKG_PROG_PKG_CONFIG
  69. +AC_SUBST(DISABLED_EXTENSIONS)
  70. +
  71. # Check for use of the system expat library
  72. AC_MSG_CHECKING(for --with-system-expat)
  73. AC_ARG_WITH(system_expat,
  74. diff --git a/setup.py b/setup.py
  75. index dbd2a3c..1ebfa50 100644
  76. --- a/setup.py
  77. +++ b/setup.py
  78. @@ -44,7 +44,10 @@ host_platform = get_platform()
  79. COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
  80. # This global variable is used to hold the list of modules to be disabled.
  81. -disabled_module_list = []
  82. +try:
  83. + disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
  84. +except KeyError:
  85. + disabled_module_list = list()
  86. def add_dir_to_list(dirlist, dir):
  87. """Add the directory 'dir' to the list 'dirlist' (after any relative
  88. --
  89. 2.6.4