0003-Add-infrastructure-to-disable-the-build-of-certain-e.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 300143451b42717eb05fc8b876f25ff4b202d8c4 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 22 Feb 2017 16:33:22 -0800
  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. [ Andrey Smirnov: ported to Python 3.6 ]
  31. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
  32. ---
  33. Makefile.pre.in | 6 +++++-
  34. configure.ac | 2 ++
  35. setup.py | 6 +++++-
  36. 3 files changed, 12 insertions(+), 2 deletions(-)
  37. diff --git a/Makefile.pre.in b/Makefile.pre.in
  38. index b78a765..0e06ddb 100644
  39. --- a/Makefile.pre.in
  40. +++ b/Makefile.pre.in
  41. @@ -188,6 +188,8 @@ FILEMODE= 644
  42. # configure script arguments
  43. CONFIG_ARGS= @CONFIG_ARGS@
  44. +# disabled extensions
  45. +DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@
  46. # Subdirectories with code
  47. SRCDIRS= @SRCDIRS@
  48. @@ -606,6 +608,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
  49. esac; \
  50. $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
  51. _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
  52. + DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
  53. $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
  54. @@ -1433,7 +1436,8 @@ libainstall: all python-config
  55. # Install the dynamically loadable modules
  56. # This goes into $(exec_prefix)
  57. sharedinstall: sharedmods
  58. - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  59. + $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
  60. + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  61. --prefix=$(prefix) \
  62. --install-scripts=$(BINDIR) \
  63. --install-platlib=$(DESTSHARED) \
  64. diff --git a/configure.ac b/configure.ac
  65. index 250b23b..fc4e71a 100644
  66. --- a/configure.ac
  67. +++ b/configure.ac
  68. @@ -2779,6 +2779,8 @@ LIBS="$withval $LIBS"
  69. PKG_PROG_PKG_CONFIG
  70. +AC_SUBST(DISABLED_EXTENSIONS)
  71. +
  72. # Check for use of the system expat library
  73. AC_MSG_CHECKING(for --with-system-expat)
  74. AC_ARG_WITH(system_expat,
  75. diff --git a/setup.py b/setup.py
  76. index f04bf22..c5bce21 100644
  77. --- a/setup.py
  78. +++ b/setup.py
  79. @@ -43,7 +43,11 @@ host_platform = get_platform()
  80. COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
  81. # This global variable is used to hold the list of modules to be disabled.
  82. -disabled_module_list = []
  83. +try:
  84. + disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
  85. +except KeyError:
  86. + disabled_module_list = list()
  87. +
  88. def add_dir_to_list(dirlist, dir):
  89. """Add the directory 'dir' to the list 'dirlist' (after any relative
  90. --
  91. 2.9.3