1From f034b1b0f33a7bd4dde23f0bc1fa8e00e3518c9d Mon Sep 17 00:00:00 2001 2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 3Date: Wed, 22 Feb 2017 17:15:31 -0800 4Subject: [PATCH] Add an option to disable lib2to3 5 6lib2to3 is a library to convert Python 2.x code to Python 3.x. As 7such, it is probably not very useful on embedded system targets. 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 | 17 ++++++++++++----- 17 configure.ac | 5 +++++ 18 setup.py | 6 +++--- 19 3 files changed, 20 insertions(+), 8 deletions(-) 20 21diff --git a/Makefile.pre.in b/Makefile.pre.in 22index 28cf88e..63fa9fb 100644 23--- a/Makefile.pre.in 24+++ b/Makefile.pre.in 25@@ -1395,7 +1395,9 @@ ifeq (@PYDOC@,yes) 26 (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3) 27 endif 28 -rm -f $(DESTDIR)$(BINDIR)/2to3 29+ifeq (@LIB2TO3@,yes) 30 (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3) 31+endif 32 if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \ 33 rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \ 34 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \ 35@@ -1441,7 +1443,6 @@ LIBSUBDIRS= asyncio \ 36 idlelib idlelib/Icons \ 37 importlib importlib/metadata \ 38 json \ 39- lib2to3 lib2to3/fixes lib2to3/pgen2 \ 40 logging \ 41 multiprocessing multiprocessing/dummy \ 42 site-packages \ 43@@ -1458,10 +1459,6 @@ LIBSUBDIRS= asyncio \ 44 TESTSUBDIRS= ctypes/test \ 45 distutils/tests \ 46 idlelib/idle_test \ 47- lib2to3/tests \ 48- lib2to3/tests/data \ 49- lib2to3/tests/data/fixers \ 50- lib2to3/tests/data/fixers/myfixes \ 51 sqlite3/test \ 52 test test/audiodata \ 53 test/capath test/cjkencodings \ 54@@ -1535,6 +1532,14 @@ ifeq (@PYDOC@,yes) 55 LIBSUBDIRS += pydoc_data 56 endif 57 58+ifeq (@LIB2TO3@,yes) 59+LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2 60+TESTSUBDIRS += lib2to3/tests \ 61+ lib2to3/tests/data \ 62+ lib2to3/tests/data/fixers \ 63+ lib2to3/tests/data/fixers/myfixes 64+endif 65+ 66 TEST_MODULES=@TEST_MODULES@ 67 libinstall: build_all $(srcdir)/Modules/xxmodule.c 68 @for i in $(SCRIPTDIR) $(LIBDEST); \ 69@@ -1637,10 +1642,12 @@ ifeq (@PYC_BUILD@,yes) 70 -j0 -d $(LIBDEST)/site-packages -f \ 71 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages 72 endif 73+ifeq (@LIB2TO3@,yes) 74 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 75 $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt 76 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ 77 $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt 78+endif 79 80 # bpo-21536: Misc/python-config.sh is generated in the build directory 81 # from $(srcdir)Misc/python-config.sh.in. 82diff --git a/configure.ac b/configure.ac 83index 9079531..34c2ba9 100644 84--- a/configure.ac 85+++ b/configure.ac 86@@ -6014,6 +6014,11 @@ else 87 fi 88 AC_SUBST(TEST_MODULES) 89 90+AC_SUBST(LIB2TO3) 91+ 92+AC_ARG_ENABLE(lib2to3, 93+ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]), 94+ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ]) 95 96 # generate output files 97 AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh) 98diff --git a/setup.py b/setup.py 99index d23f148..663fd44 100644 100--- a/setup.py 101+++ b/setup.py 102@@ -2722,11 +2722,11 @@ def main(): 103 import warnings 104 warnings.filterwarnings("ignore",category=DeprecationWarning) 105 106- scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3', 107- 'Lib/smtpd.py'] 108+ scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py'] 109 if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"): 110 scripts += [ 'Tools/scripts/pydoc3' ] 111- 112+ if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"): 113+ scripts += [ 'Tools/scripts/2to3' ] 114 setup(# PyPI Metadata (PEP 301) 115 name = "Python", 116 version = sys.version.split()[0], 117-- 1182.30.2 119 120