123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- From 18e19402fab3939223a58481734e685d25c3102b 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>
- ---
- Makefile.pre.in | 17 ++++++++++++-----
- configure.ac | 6 ++++++
- setup.py | 6 +++---
- 3 files changed, 21 insertions(+), 8 deletions(-)
- diff --git a/Makefile.pre.in b/Makefile.pre.in
- index e87bc1fcd32..1a0ab0de426 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 d56d8f9d1c5..bf91fb2f824 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 d8647724650..e02591dae10 100644
- --- a/setup.py
- +++ b/setup.py
- @@ -1598,11 +1598,11 @@ class DummyProcess:
- import warnings
- warnings.filterwarnings("ignore",category=DeprecationWarning)
-
- - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
- - 'Lib/smtpd.py']
- + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
- 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",
- version = sys.version.split()[0],
- --
- 2.44.0
|