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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From 77fcd90a1236d59d40aa32d3bc4bef4303eb4066 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. ---
  14. Makefile.pre.in | 7 ++++++-
  15. configure.ac | 6 ++++++
  16. setup.py | 9 +++++++--
  17. 3 files changed, 19 insertions(+), 3 deletions(-)
  18. diff --git a/Makefile.pre.in b/Makefile.pre.in
  19. index 5a40b7c5484..e87bc1fcd32 100644
  20. --- a/Makefile.pre.in
  21. +++ b/Makefile.pre.in
  22. @@ -1877,7 +1877,9 @@ bininstall: commoninstall altbininstall
  23. -rm -f $(DESTDIR)$(BINDIR)/idle3
  24. (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
  25. -rm -f $(DESTDIR)$(BINDIR)/pydoc3
  26. +ifeq (@PYDOC@,yes)
  27. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  28. +endif
  29. -rm -f $(DESTDIR)$(BINDIR)/2to3
  30. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  31. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  32. @@ -1928,7 +1930,6 @@ LIBSUBDIRS= asyncio \
  33. lib2to3 lib2to3/fixes lib2to3/pgen2 \
  34. logging \
  35. multiprocessing multiprocessing/dummy \
  36. - pydoc_data \
  37. re \
  38. site-packages \
  39. sqlite3 \
  40. @@ -2069,6 +2070,10 @@ TESTSUBDIRS= ctypes/test \
  41. unittest/test \
  42. unittest/test/testmock
  43. +ifeq (@PYDOC@,yes)
  44. +LIBSUBDIRS += pydoc_data
  45. +endif
  46. +
  47. TEST_MODULES=@TEST_MODULES@
  48. libinstall: all $(srcdir)/Modules/xxmodule.c
  49. @for i in $(SCRIPTDIR) $(LIBDEST); \
  50. diff --git a/configure.ac b/configure.ac
  51. index b4d7d2cca6a..d56d8f9d1c5 100644
  52. --- a/configure.ac
  53. +++ b/configure.ac
  54. @@ -4222,6 +4222,12 @@ AS_VAR_IF([posix_threads], [stub], [
  55. AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
  56. ])
  57. +AC_SUBST(PYDOC)
  58. +
  59. +AC_ARG_ENABLE(pydoc,
  60. + AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
  61. + [ PYDOC="${enableval}" ], [ PYDOC=yes ])
  62. +
  63. # Check for enable-ipv6
  64. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  65. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  66. diff --git a/setup.py b/setup.py
  67. index 53b066cb18b..d8647724650 100644
  68. --- a/setup.py
  69. +++ b/setup.py
  70. @@ -1597,6 +1597,12 @@ class DummyProcess:
  71. # turn off warnings when deprecated modules are imported
  72. import warnings
  73. warnings.filterwarnings("ignore",category=DeprecationWarning)
  74. +
  75. + scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  76. + 'Lib/smtpd.py']
  77. + if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  78. + scripts += [ 'Tools/scripts/pydoc3' ]
  79. +
  80. setup(# PyPI Metadata (PEP 301)
  81. name = "Python",
  82. version = sys.version.split()[0],
  83. @@ -1621,8 +1627,7 @@ class DummyProcess:
  84. # If you change the scripts installed here, you also need to
  85. # check the PyBuildScripts command above, and change the links
  86. # created by the bininstall target in Makefile.pre.in
  87. - scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
  88. - "Tools/scripts/2to3"]
  89. + scripts = scripts
  90. )
  91. # --install-platlib
  92. --
  93. 2.44.0