0008-Add-an-option-to-disable-pydoc.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From e6284624679a525440dc4bfddc1347f8add22fd8 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 22 Feb 2017 17:07:56 -0800
  4. Subject: [PATCH] Add an option to disable pydoc
  5. It removes 0.5 MB of data from the target plus the pydoc script
  6. itself.
  7. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  8. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  9. [ Andrey Smirnov: ported to Python 3.6 ]
  10. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
  11. [ Adam Duskett: ported to Python 3.10.0 ]
  12. Signed-off-by: Adam Duskett <aduskett@gmail.com>
  13. [ Vincent Fazio: fix scripts array to reflect upstream ]
  14. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
  15. ---
  16. Makefile.pre.in | 7 ++++++-
  17. configure.ac | 6 ++++++
  18. setup.py | 9 +++++++--
  19. 3 files changed, 19 insertions(+), 3 deletions(-)
  20. diff --git a/Makefile.pre.in b/Makefile.pre.in
  21. index 5a40b7c548..e87bc1fcd3 100644
  22. --- a/Makefile.pre.in
  23. +++ b/Makefile.pre.in
  24. @@ -1877,7 +1877,9 @@ bininstall: commoninstall altbininstall
  25. -rm -f $(DESTDIR)$(BINDIR)/idle3
  26. (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
  27. -rm -f $(DESTDIR)$(BINDIR)/pydoc3
  28. +ifeq (@PYDOC@,yes)
  29. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  30. +endif
  31. -rm -f $(DESTDIR)$(BINDIR)/2to3
  32. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  33. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  34. @@ -1928,7 +1930,6 @@ LIBSUBDIRS= asyncio \
  35. lib2to3 lib2to3/fixes lib2to3/pgen2 \
  36. logging \
  37. multiprocessing multiprocessing/dummy \
  38. - pydoc_data \
  39. re \
  40. site-packages \
  41. sqlite3 \
  42. @@ -2069,6 +2070,10 @@ TESTSUBDIRS= ctypes/test \
  43. unittest/test \
  44. unittest/test/testmock
  45. +ifeq (@PYDOC@,yes)
  46. +LIBSUBDIRS += pydoc_data
  47. +endif
  48. +
  49. TEST_MODULES=@TEST_MODULES@
  50. libinstall: all $(srcdir)/Modules/xxmodule.c
  51. @for i in $(SCRIPTDIR) $(LIBDEST); \
  52. diff --git a/configure.ac b/configure.ac
  53. index b4d7d2cca6..d56d8f9d1c 100644
  54. --- a/configure.ac
  55. +++ b/configure.ac
  56. @@ -4222,6 +4222,12 @@ AS_VAR_IF([posix_threads], [stub], [
  57. AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
  58. ])
  59. +AC_SUBST(PYDOC)
  60. +
  61. +AC_ARG_ENABLE(pydoc,
  62. + AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
  63. + [ PYDOC="${enableval}" ], [ PYDOC=yes ])
  64. +
  65. # Check for enable-ipv6
  66. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  67. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  68. diff --git a/setup.py b/setup.py
  69. index 53b066cb18..25e6f4fc26 100644
  70. --- a/setup.py
  71. +++ b/setup.py
  72. @@ -1597,6 +1597,12 @@ class DummyProcess:
  73. # turn off warnings when deprecated modules are imported
  74. import warnings
  75. warnings.filterwarnings("ignore",category=DeprecationWarning)
  76. +
  77. + scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3']
  78. +
  79. + if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  80. + scripts += [ 'Tools/scripts/pydoc3' ]
  81. +
  82. setup(# PyPI Metadata (PEP 301)
  83. name = "Python",
  84. version = sys.version.split()[0],
  85. @@ -1621,8 +1627,7 @@ class DummyProcess:
  86. # If you change the scripts installed here, you also need to
  87. # check the PyBuildScripts command above, and change the links
  88. # created by the bininstall target in Makefile.pre.in
  89. - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
  90. - "Tools/scripts/2to3"]
  91. + scripts = scripts
  92. )
  93. # --install-platlib
  94. --
  95. 2.34.1