| From 572f3164d1dce13db30e897ab0be7c706fa7b731 Mon Sep 17 00:00:00 2001 |
| From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| Date: Wed, 22 Feb 2017 17:15:31 -0800 |
| Subject: [PATCH] Add an option to disable lib2to3 |
| |
| lib2to3 is a library to convert Python 2.x code to Python 3.x. As |
| such, it is probably not very useful on embedded system targets. |
| |
| Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| Signed-off-by: Samuel Martin <s.martin49@gmail.com> |
| [ Andrey Smirnov: ported to Python 3.6 ] |
| Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> |
| [ Adam Duskett: ported to Python 3.10.0 ] |
| Signed-off-by: Adam Duskett <aduskett@gmail.com> |
| [ Bernd Kuhls: ported to Python 3.11.4] |
| Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de> |
| [ Adam Duskett: ported to Python 3.12.1 ] |
| Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> |
| --- |
| Makefile.pre.in | 19 ++++++++++++++----- |
| configure.ac | 6 ++++++ |
| 2 files changed, 20 insertions(+), 5 deletions(-) |
| |
| diff --git a/Makefile.pre.in b/Makefile.pre.in |
| index 2243a658a9..3f314d1354 100644 |
| --- a/Makefile.pre.in |
| +++ b/Makefile.pre.in |
| @@ -2054,7 +2054,9 @@ ifeq (@PYDOC@,yes) |
| (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3) |
| endif |
| -rm -f $(DESTDIR)$(BINDIR)/2to3 |
| +ifeq (@LIB2TO3@,yes) |
| (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3) |
| +endif |
| if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \ |
| rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \ |
| (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \ |
| @@ -2101,7 +2103,6 @@ LIBSUBDIRS= asyncio \ |
| idlelib idlelib/Icons \ |
| importlib importlib/resources importlib/metadata \ |
| json \ |
| - lib2to3 lib2to3/fixes lib2to3/pgen2 \ |
| logging \ |
| multiprocessing multiprocessing/dummy \ |
| re \ |
| @@ -2207,10 +2208,6 @@ TESTSUBDIRS= idlelib/idle_test \ |
| test/test_importlib/resources/zipdata02 \ |
| test/test_importlib/source \ |
| test/test_json \ |
| - test/test_lib2to3 \ |
| - test/test_lib2to3/data \ |
| - test/test_lib2to3/data/fixers \ |
| - test/test_lib2to3/data/fixers/myfixes \ |
| test/test_module \ |
| test/test_peg_generator \ |
| test/test_pydoc \ |
| @@ -2262,6 +2259,14 @@ ifeq (@PYDOC@,yes) |
| LIBSUBDIRS += pydoc_data |
| endif |
| |
| +ifeq (@LIB2TO3@,yes) |
| +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2 |
| +TESTSUBDIRS += test/test_lib2to3 \ |
| + test/test_lib2to3/data \ |
| + test/test_lib2to3/data/fixers \ |
| + test/test_lib2to3/data/fixers/myfixes |
| +endif |
| + |
| TEST_MODULES=@TEST_MODULES@ |
| |
| .PHONY: libinstall |
| @@ -2345,10 +2350,12 @@ ifeq (@PYC_BUILD@,yes) |
| -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \ |
| -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages |
| endif |
| +ifeq (@LIB2TO3@,yes) |
| -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ |
| $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt |
| -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ |
| $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt |
| +endif |
| |
| # bpo-21536: Misc/python-config.sh is generated in the build directory |
| # from $(srcdir)Misc/python-config.sh.in. |
| @@ -2474,7 +2481,9 @@ libainstall: all scripts |
| $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh |
| $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py |
| $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config |
| +ifeq (@LIB2TO3@,yes) |
| $(INSTALL_SCRIPT) $(SCRIPT_2TO3) $(DESTDIR)$(BINDIR)/2to3-$(VERSION) |
| +endif |
| $(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION) |
| ifeq (@PYDOC@,yes) |
| $(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION) |
| diff --git a/configure.ac b/configure.ac |
| index 1a2dd28d1e..f0354c580d 100644 |
| --- a/configure.ac |
| +++ b/configure.ac |
| @@ -7561,6 +7561,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu |
| # substitute multiline block, must come after last PY_STDLIB_MOD() |
| AC_SUBST([MODULE_BLOCK]) |
| |
| +AC_SUBST(LIB2TO3) |
| + |
| +AC_ARG_ENABLE(lib2to3, |
| + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]), |
| + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ]) |
| + |
| # generate output files |
| AC_CONFIG_FILES(m4_normalize([ |
| Makefile.pre |
| -- |
| 2.34.1 |
| |