2023-08-24 09:53:35 +00:00
|
|
|
From 0e4f0a525ea0a68f6d4c5349c301da2e9b0c8ac9 Mon Sep 17 00:00:00 2001
|
2022-12-06 22:00:30 +00:00
|
|
|
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>
|
|
|
|
---
|
|
|
|
Makefile.pre.in | 17 ++++++++++++-----
|
2023-08-24 09:53:35 +00:00
|
|
|
configure.ac | 6 ++++++
|
2022-12-06 22:00:30 +00:00
|
|
|
setup.py | 6 +++---
|
2023-08-24 09:53:35 +00:00
|
|
|
3 files changed, 21 insertions(+), 8 deletions(-)
|
2022-12-06 22:00:30 +00:00
|
|
|
|
|
|
|
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
2023-08-24 09:53:35 +00:00
|
|
|
index 403380e181..f5d0573067 100644
|
2022-12-06 22:00:30 +00:00
|
|
|
--- a/Makefile.pre.in
|
|
|
|
+++ b/Makefile.pre.in
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -1868,7 +1868,9 @@ ifeq (@PYDOC@,yes)
|
2022-12-06 22:00:30 +00:00
|
|
|
(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)) \
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -1914,7 +1916,6 @@ LIBSUBDIRS= asyncio \
|
2022-12-06 22:00:30 +00:00
|
|
|
idlelib idlelib/Icons \
|
|
|
|
importlib importlib/resources importlib/metadata \
|
|
|
|
json \
|
|
|
|
- lib2to3 lib2to3/fixes lib2to3/pgen2 \
|
|
|
|
logging \
|
|
|
|
multiprocessing multiprocessing/dummy \
|
|
|
|
re \
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -1934,10 +1935,6 @@ LIBSUBDIRS= asyncio \
|
2022-12-06 22:00:30 +00:00
|
|
|
TESTSUBDIRS= ctypes/test \
|
|
|
|
distutils/tests \
|
|
|
|
idlelib/idle_test \
|
|
|
|
- lib2to3/tests \
|
|
|
|
- lib2to3/tests/data \
|
|
|
|
- lib2to3/tests/data/fixers \
|
|
|
|
- lib2to3/tests/data/fixers/myfixes \
|
2023-08-24 09:53:35 +00:00
|
|
|
test \
|
|
|
|
test/audiodata \
|
|
|
|
test/capath \
|
|
|
|
@@ -2013,6 +2010,14 @@ ifeq (@PYDOC@,yes)
|
2022-12-06 22:00:30 +00:00
|
|
|
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@
|
2023-08-24 09:53:35 +00:00
|
|
|
libinstall: all $(srcdir)/Modules/xxmodule.c
|
2022-12-06 22:00:30 +00:00
|
|
|
@for i in $(SCRIPTDIR) $(LIBDEST); \
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -2115,10 +2120,12 @@ ifeq (@PYC_BUILD@,yes)
|
2022-12-06 22:00:30 +00:00
|
|
|
-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
|
2023-08-24 09:53:35 +00:00
|
|
|
index f68ea72321..d8e10cf2b2 100644
|
2022-12-06 22:00:30 +00:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -7078,6 +7078,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])
|
2022-12-06 22:00:30 +00:00
|
|
|
|
|
|
|
+AC_SUBST(LIB2TO3)
|
|
|
|
+
|
|
|
|
+AC_ARG_ENABLE(lib2to3,
|
|
|
|
+ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
|
|
|
|
+ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
|
2023-08-24 09:53:35 +00:00
|
|
|
+
|
2022-12-06 22:00:30 +00:00
|
|
|
# generate output files
|
|
|
|
AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
|
2023-08-24 09:53:35 +00:00
|
|
|
AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib])
|
2022-12-06 22:00:30 +00:00
|
|
|
diff --git a/setup.py b/setup.py
|
2023-08-24 09:53:35 +00:00
|
|
|
index 3e55f5b2e0..c490b0b08f 100644
|
2022-12-06 22:00:30 +00:00
|
|
|
--- a/setup.py
|
|
|
|
+++ b/setup.py
|
2023-08-24 09:53:35 +00:00
|
|
|
@@ -1594,11 +1594,11 @@ class DummyProcess:
|
2022-12-06 22:00:30 +00:00
|
|
|
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],
|
|
|
|
--
|
2023-08-24 09:53:35 +00:00
|
|
|
2.34.1
|
2022-12-06 22:00:30 +00:00
|
|
|
|