blob: 1bd1ae511fa2b98dd9a3848a51d30b921c5c4782 [file] [log] [blame]
From 868823f15bab031caf05dc5e8ce2eac076bfc82b 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>
---
Makefile.pre.in | 16 ++++++++++++----
configure.ac | 6 ++++++
setup.py | 5 +++--
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 6fa0549a56..3e1f130532 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1293,7 +1293,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)) \
@@ -1328,7 +1330,6 @@ LIBSUBDIRS= tkinter site-packages \
html json http dbm xmlrpc \
sqlite3 \
logging csv wsgiref urllib \
- lib2to3 lib2to3/fixes lib2to3/pgen2 \
ctypes ctypes/macholib \
idlelib idlelib/Icons \
distutils distutils/command $(XMLLIBSUBDIRS) \
@@ -1402,9 +1403,6 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
test/test_email test/test_email/data \
test/test_json \
sqlite3/test \
- lib2to3/tests \
- lib2to3/tests/data lib2to3/tests/data/fixers \
- lib2to3/tests/data/fixers/myfixes \
ctypes/test \
idlelib/idle_test \
distutils/tests \
@@ -1412,6 +1410,14 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
test/test_tools test/test_warnings test/test_warnings/data \
unittest/test unittest/test/testmock
+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
+
ifeq (@TEST_MODULES@,yes)
LIBSUBDIRS += $(TESTSUBDIRS)
endif
@@ -1511,10 +1517,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 f53cc86d89..caa8eaf88a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3246,6 +3246,12 @@ AC_ARG_ENABLE(test-modules,
AS_HELP_STRING([--disable-test-modules], [disable test modules]),
[ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
+AC_SUBST(LIB2TO3)
+
+AC_ARG_ENABLE(lib2to3,
+ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
+ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
+
# Check for enable-ipv6
AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
AC_MSG_CHECKING([if --enable-ipv6 is specified])
diff --git a/setup.py b/setup.py
index 748c269960..1669797cad 100644
--- a/setup.py
+++ b/setup.py
@@ -2402,10 +2402,11 @@ def main():
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",
--
2.20.1