2
1

0015-Add-an-option-to-disable-lib2to3.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 868823f15bab031caf05dc5e8ce2eac076bfc82b Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 22 Feb 2017 17:15:31 -0800
  4. Subject: [PATCH] Add an option to disable lib2to3
  5. lib2to3 is a library to convert Python 2.x code to Python 3.x. As
  6. such, it is probably not very useful on embedded system targets.
  7. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  8. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  9. [ Andrey Smirnov: ported to Python 3.6 ]
  10. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
  11. ---
  12. Makefile.pre.in | 16 ++++++++++++----
  13. configure.ac | 6 ++++++
  14. setup.py | 5 +++--
  15. 3 files changed, 21 insertions(+), 6 deletions(-)
  16. diff --git a/Makefile.pre.in b/Makefile.pre.in
  17. index 6fa0549a56..3e1f130532 100644
  18. --- a/Makefile.pre.in
  19. +++ b/Makefile.pre.in
  20. @@ -1293,7 +1293,9 @@ ifeq (@PYDOC@,yes)
  21. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  22. endif
  23. -rm -f $(DESTDIR)$(BINDIR)/2to3
  24. +ifeq (@LIB2TO3@,yes)
  25. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  26. +endif
  27. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  28. rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
  29. (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
  30. @@ -1328,7 +1330,6 @@ LIBSUBDIRS= tkinter site-packages \
  31. html json http dbm xmlrpc \
  32. sqlite3 \
  33. logging csv wsgiref urllib \
  34. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  35. ctypes ctypes/macholib \
  36. idlelib idlelib/Icons \
  37. distutils distutils/command $(XMLLIBSUBDIRS) \
  38. @@ -1402,9 +1403,6 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
  39. test/test_email test/test_email/data \
  40. test/test_json \
  41. sqlite3/test \
  42. - lib2to3/tests \
  43. - lib2to3/tests/data lib2to3/tests/data/fixers \
  44. - lib2to3/tests/data/fixers/myfixes \
  45. ctypes/test \
  46. idlelib/idle_test \
  47. distutils/tests \
  48. @@ -1412,6 +1410,14 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
  49. test/test_tools test/test_warnings test/test_warnings/data \
  50. unittest/test unittest/test/testmock
  51. +ifeq (@LIB2TO3@,yes)
  52. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  53. +TESTSUBDIRS += lib2to3/tests \
  54. + lib2to3/tests/data \
  55. + lib2to3/tests/data/fixers \
  56. + lib2to3/tests/data/fixers/myfixes
  57. +endif
  58. +
  59. ifeq (@TEST_MODULES@,yes)
  60. LIBSUBDIRS += $(TESTSUBDIRS)
  61. endif
  62. @@ -1511,10 +1517,12 @@ ifeq (@PYC_BUILD@,yes)
  63. -j0 -d $(LIBDEST)/site-packages -f \
  64. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  65. endif
  66. +ifeq (@LIB2TO3@,yes)
  67. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  68. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  69. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  70. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  71. +endif
  72. # bpo-21536: Misc/python-config.sh is generated in the build directory
  73. # from $(srcdir)Misc/python-config.sh.in.
  74. diff --git a/configure.ac b/configure.ac
  75. index f53cc86d89..caa8eaf88a 100644
  76. --- a/configure.ac
  77. +++ b/configure.ac
  78. @@ -3225,6 +3225,12 @@ AC_ARG_ENABLE(test-modules,
  79. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  80. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  81. +AC_SUBST(LIB2TO3)
  82. +
  83. +AC_ARG_ENABLE(lib2to3,
  84. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  85. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  86. +
  87. # Check for enable-ipv6
  88. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  89. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  90. diff --git a/setup.py b/setup.py
  91. index 748c269960..1669797cad 100644
  92. --- a/setup.py
  93. +++ b/setup.py
  94. @@ -2402,10 +2402,11 @@ def main():
  95. import warnings
  96. warnings.filterwarnings("ignore",category=DeprecationWarning)
  97. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  98. - 'Lib/smtpd.py']
  99. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  100. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  101. scripts += [ 'Tools/scripts/pydoc3' ]
  102. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  103. + scripts += [ 'Tools/scripts/2to3' ]
  104. setup(# PyPI Metadata (PEP 301)
  105. name = "Python",
  106. --
  107. 2.20.1