2
1

007-disable-extensions.patch 3.5 KB

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