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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From df7c95b4ceecf390b961d843a556c470ac9080b2 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 | 5 ++++-
  36. 3 files changed, 11 insertions(+), 2 deletions(-)
  37. diff --git a/Makefile.pre.in b/Makefile.pre.in
  38. index 0c809f3d8a..7c3dde8dd4 100644
  39. --- a/Makefile.pre.in
  40. +++ b/Makefile.pre.in
  41. @@ -216,6 +216,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. @@ -632,6 +634,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. @@ -1696,7 +1699,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 c2445edc88..73d66167de 100644
  68. --- a/configure.ac
  69. +++ b/configure.ac
  70. @@ -3081,6 +3081,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 770866bca7..b6c829b3a5 100644
  79. --- a/setup.py
  80. +++ b/setup.py
  81. @@ -44,7 +44,10 @@ from distutils.spawn import find_executable
  82. TEST_EXTENSIONS = True
  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. def get_platform():
  90. --
  91. 2.25.1