0017-Add-an-option-to-disable-pydoc.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From f98c3f981643411449aba6f93178b2ca14f9a68c Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Tue, 7 Mar 2017 22:27:34 +0100
  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. [Peter: update for 2.7.16]
  10. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  11. ---
  12. Makefile.pre.in | 6 +++++-
  13. configure.ac | 5 +++++
  14. setup.py | 10 +++++++---
  15. 3 files changed, 17 insertions(+), 4 deletions(-)
  16. diff --git a/Makefile.pre.in b/Makefile.pre.in
  17. index 2a5e8adc61..d3ba1aeb4e 100644
  18. --- a/Makefile.pre.in
  19. +++ b/Makefile.pre.in
  20. @@ -1062,7 +1062,7 @@ LIBSUBDIRS= lib-tk site-packages \
  21. multiprocessing multiprocessing/dummy \
  22. unittest \
  23. lib-old \
  24. - curses pydoc_data $(MACHDEPS)
  25. + curses $(MACHDEPS)
  26. TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
  27. lib-tk/test/test_ttk test test/audiodata test/capath test/data \
  28. @@ -1086,6 +1086,10 @@ ifeq (@TEST_MODULES@,yes)
  29. LIBSUBDIRS += $(TESTSUBDIRS)
  30. endif
  31. +ifeq (@PYDOC@,yes)
  32. +LIBSUBDIRS += pydoc_data
  33. +endif
  34. +
  35. libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
  36. @for i in $(SCRIPTDIR) $(LIBDEST); \
  37. do \
  38. diff --git a/configure.ac b/configure.ac
  39. index f257a25620..2ed4119478 100644
  40. --- a/configure.ac
  41. +++ b/configure.ac
  42. @@ -2834,6 +2834,11 @@ if test "$posix_threads" = "yes"; then
  43. AC_CHECK_FUNCS(pthread_atfork)
  44. fi
  45. +AC_SUBST(PYDOC)
  46. +
  47. +AC_ARG_ENABLE(pydoc,
  48. + AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
  49. + [ PYDOC="${enableval}" ], [ PYDOC=yes ])
  50. AC_SUBST(TEST_MODULES)
  51. diff --git a/setup.py b/setup.py
  52. index 2ef5b07189..49f810f72e 100644
  53. --- a/setup.py
  54. +++ b/setup.py
  55. @@ -2277,6 +2277,12 @@ def main():
  56. # turn off warnings when deprecated modules are imported
  57. import warnings
  58. warnings.filterwarnings("ignore",category=DeprecationWarning)
  59. +
  60. + scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
  61. + 'Lib/smtpd.py']
  62. + if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  63. + scripts += [ 'Tools/scripts/pydoc' ]
  64. +
  65. setup(# PyPI Metadata (PEP 301)
  66. name = "Python",
  67. version = sys.version.split()[0],
  68. @@ -2297,9 +2303,7 @@ def main():
  69. ext_modules=[Extension('_struct', ['_struct.c'])],
  70. # Scripts to install
  71. - scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
  72. - 'Tools/scripts/2to3',
  73. - 'Lib/smtpd.py']
  74. + scripts = scripts,
  75. )
  76. # --install-platlib
  77. --
  78. 2.11.0