| From 3fbd10c59a777c4ef7ee1bd3fb70808e25e11703 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> |
| [ Vincent Fazio: fix scripts array to reflect upstream ] |
| Signed-off-by: Vincent Fazio <vfazio@gmail.com> |
| --- |
| Makefile.pre.in | 17 ++++++++++++----- |
| configure.ac | 6 ++++++ |
| setup.py | 4 +++- |
| 3 files changed, 21 insertions(+), 6 deletions(-) |
| |
| diff --git a/Makefile.pre.in b/Makefile.pre.in |
| index e87bc1fcd3..1a0ab0de42 100644 |
| --- a/Makefile.pre.in |
| +++ b/Makefile.pre.in |
| @@ -1881,7 +1881,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)) \ |
| @@ -1927,7 +1929,6 @@ LIBSUBDIRS= asyncio \ |
| idlelib idlelib/Icons \ |
| importlib importlib/resources importlib/metadata \ |
| json \ |
| - lib2to3 lib2to3/fixes lib2to3/pgen2 \ |
| logging \ |
| multiprocessing multiprocessing/dummy \ |
| re \ |
| @@ -1947,10 +1948,6 @@ LIBSUBDIRS= asyncio \ |
| TESTSUBDIRS= ctypes/test \ |
| distutils/tests \ |
| idlelib/idle_test \ |
| - lib2to3/tests \ |
| - lib2to3/tests/data \ |
| - lib2to3/tests/data/fixers \ |
| - lib2to3/tests/data/fixers/myfixes \ |
| test \ |
| test/audiodata \ |
| test/certdata \ |
| @@ -2074,6 +2071,14 @@ ifeq (@PYDOC@,yes) |
| LIBSUBDIRS += pydoc_data |
| endif |
| |
| +ifeq (@LIB2TO3@,yes) |
| +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2 |
| +TESTSUBDIRS += lib2to3/tests \ |
| + lib2to3/tests/data \ |
| + lib2to3/tests/data/fixers \ |
| + lib2to3/tests/data/fixers/myfixes |
| +endif |
| + |
| TEST_MODULES=@TEST_MODULES@ |
| libinstall: all $(srcdir)/Modules/xxmodule.c |
| @for i in $(SCRIPTDIR) $(LIBDEST); \ |
| @@ -2176,10 +2181,12 @@ ifeq (@PYC_BUILD@,yes) |
| -j0 -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. |
| diff --git a/configure.ac b/configure.ac |
| index d56d8f9d1c..bf91fb2f82 100644 |
| --- a/configure.ac |
| +++ b/configure.ac |
| @@ -7147,6 +7147,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(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh) |
| AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib]) |
| diff --git a/setup.py b/setup.py |
| index 25e6f4fc26..78d880f9db 100644 |
| --- a/setup.py |
| +++ b/setup.py |
| @@ -1598,10 +1598,12 @@ class DummyProcess: |
| import warnings |
| warnings.filterwarnings("ignore",category=DeprecationWarning) |
| |
| - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3'] |
| + scripts = ['Tools/scripts/idle3'] |
| |
| if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"): |
| scripts += [ 'Tools/scripts/pydoc3' ] |
| + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"): |
| + scripts += [ 'Tools/scripts/2to3' ] |
| |
| setup(# PyPI Metadata (PEP 301) |
| name = "Python", |
| -- |
| 2.34.1 |
| |