1From a65e5d3caf8e076d531191164c23c6240461f675 Mon Sep 17 00:00:00 2001 2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 3Date: Wed, 22 Feb 2017 17:07:56 -0800 4Subject: [PATCH] Add an option to disable pydoc 5 6It removes 0.5 MB of data from the target plus the pydoc script 7itself. 8 9Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 10Signed-off-by: Samuel Martin <s.martin49@gmail.com> 11[ Andrey Smirnov: ported to Python 3.6 ] 12Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> 13[ Adam Duskett: ported to Python 3.10.0 ] 14Signed-off-by: Adam Duskett <aduskett@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 21diff --git a/Makefile.pre.in b/Makefile.pre.in 22index c0d5511..32b3df7 100644 23--- a/Makefile.pre.in 24+++ b/Makefile.pre.in 25@@ -1391,7 +1391,9 @@ bininstall: altbininstall 26 -rm -f $(DESTDIR)$(BINDIR)/idle3 27 (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3) 28 -rm -f $(DESTDIR)$(BINDIR)/pydoc3 29+ifeq (@PYDOC@,yes) 30 (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3) 31+endif 32 -rm -f $(DESTDIR)$(BINDIR)/2to3 33 (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3) 34 if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \ 35@@ -1442,7 +1444,6 @@ LIBSUBDIRS= asyncio \ 36 lib2to3 lib2to3/fixes lib2to3/pgen2 \ 37 logging \ 38 multiprocessing multiprocessing/dummy \ 39- pydoc_data \ 40 site-packages \ 41 sqlite3 \ 42 tkinter \ 43@@ -1530,6 +1531,10 @@ TESTSUBDIRS= ctypes/test \ 44 tkinter/test/test_ttk \ 45 unittest/test unittest/test/testmock 46 47+ifeq (@PYDOC@,yes) 48+LIBSUBDIRS += pydoc_data 49+endif 50+ 51 TEST_MODULES=@TEST_MODULES@ 52 libinstall: build_all $(srcdir)/Modules/xxmodule.c 53 @for i in $(SCRIPTDIR) $(LIBDEST); \ 54diff --git a/configure.ac b/configure.ac 55index 083a12d..9079531 100644 56--- a/configure.ac 57+++ b/configure.ac 58@@ -3373,6 +3373,12 @@ if test "$posix_threads" = "yes"; then 59 AC_CHECK_FUNCS(pthread_getcpuclockid) 60 fi 61 62+AC_SUBST(PYDOC) 63+ 64+AC_ARG_ENABLE(pydoc, 65+ AS_HELP_STRING([--disable-pydoc], [disable pydoc]), 66+ [ PYDOC="${enableval}" ], [ PYDOC=yes ]) 67+ 68 69 # Check for enable-ipv6 70 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) 71diff --git a/setup.py b/setup.py 72index d00d389..d23f148 100644 73--- a/setup.py 74+++ b/setup.py 75@@ -2721,6 +2721,12 @@ def main(): 76 # turn off warnings when deprecated modules are imported 77 import warnings 78 warnings.filterwarnings("ignore",category=DeprecationWarning) 79+ 80+ scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3', 81+ 'Lib/smtpd.py'] 82+ if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"): 83+ scripts += [ 'Tools/scripts/pydoc3' ] 84+ 85 setup(# PyPI Metadata (PEP 301) 86 name = "Python", 87 version = sys.version.split()[0], 88@@ -2746,8 +2752,7 @@ def main(): 89 # If you change the scripts installed here, you also need to 90 # check the PyBuildScripts command above, and change the links 91 # created by the bininstall target in Makefile.pre.in 92- scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 93- "Tools/scripts/2to3"] 94+ scripts = scripts 95 ) 96 97 # --install-platlib 98-- 992.30.2 100 101