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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 2c2afc80831c518e5daf3df6c9e4c4ac0a7be001 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 b38bd79121..4ce917ab8d 100644
  39. --- a/Makefile.pre.in
  40. +++ b/Makefile.pre.in
  41. @@ -206,6 +206,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. @@ -619,6 +621,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
  49. esac; \
  50. echo "$(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. $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
  55. _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
  56. @@ -1528,7 +1531,8 @@ libainstall: @DEF_MAKE_RULE@ python-config
  57. # Install the dynamically loadable modules
  58. # This goes into $(exec_prefix)
  59. sharedinstall: sharedmods
  60. - $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  61. + $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
  62. + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
  63. --prefix=$(prefix) \
  64. --install-scripts=$(BINDIR) \
  65. --install-platlib=$(DESTSHARED) \
  66. diff --git a/configure.ac b/configure.ac
  67. index 5f87c4db5a..d5ee2aedfb 100644
  68. --- a/configure.ac
  69. +++ b/configure.ac
  70. @@ -2966,6 +2966,8 @@ LIBS="$withval $LIBS"
  71. PKG_PROG_PKG_CONFIG
  72. +AC_SUBST(DISABLED_EXTENSIONS)
  73. +
  74. # Check for use of the system expat library
  75. AC_MSG_CHECKING(for --with-system-expat)
  76. AC_ARG_WITH(system_expat,
  77. diff --git a/setup.py b/setup.py
  78. index fe477974bd..86643ae8bf 100644
  79. --- a/setup.py
  80. +++ b/setup.py
  81. @@ -48,7 +48,11 @@ host_platform = get_platform()
  82. COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
  83. # This global variable is used to hold the list of modules to be disabled.
  84. -disabled_module_list = []
  85. +try:
  86. + disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
  87. +except KeyError:
  88. + disabled_module_list = list()
  89. +
  90. def add_dir_to_list(dirlist, dir):
  91. """Add the directory 'dir' to the list 'dirlist' (after any relative
  92. --
  93. 2.13.5