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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From c2d279b4a19de7a32e8a73e320423f699d408380 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. [aduskett@gmail.com: Update for python 3.6.4]
  12. Signed-off-by: Adam Duskett <aduskett@gmail.com>
  13. ---
  14. Makefile.pre.in | 16 ++++++++++++----
  15. configure.ac | 6 ++++++
  16. setup.py | 5 +++--
  17. 3 files changed, 21 insertions(+), 6 deletions(-)
  18. diff --git a/Makefile.pre.in b/Makefile.pre.in
  19. index badb2af35d..931cc3ed07 100644
  20. --- a/Makefile.pre.in
  21. +++ b/Makefile.pre.in
  22. @@ -1200,7 +1200,9 @@ ifeq (@PYDOC@,yes)
  23. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  24. endif
  25. -rm -f $(DESTDIR)$(BINDIR)/2to3
  26. +ifeq (@LIB2TO3@,yes)
  27. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  28. +endif
  29. -rm -f $(DESTDIR)$(BINDIR)/pyvenv
  30. (cd $(DESTDIR)$(BINDIR); $(LN) -s pyvenv-$(VERSION) pyvenv)
  31. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  32. @@ -1237,7 +1239,6 @@ LIBSUBDIRS= tkinter site-packages \
  33. html json http dbm xmlrpc \
  34. sqlite3 \
  35. logging csv wsgiref urllib \
  36. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  37. ctypes ctypes/macholib \
  38. idlelib idlelib/Icons \
  39. distutils distutils/command $(XMLLIBSUBDIRS) \
  40. @@ -1289,9 +1290,6 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
  41. test/test_email test/test_email/data \
  42. test/test_json \
  43. sqlite3/test \
  44. - lib2to3/tests \
  45. - lib2to3/tests/data lib2to3/tests/data/fixers \
  46. - lib2to3/tests/data/fixers/myfixes \
  47. ctypes/test \
  48. idlelib/idle_test \
  49. distutils/tests \
  50. @@ -1301,6 +1303,14 @@ TESTSUBDIRS= tkinter/test tkinter/test/test_tkinter \
  51. test/test_tools test/test_warnings test/test_warnings/data \
  52. unittest/test unittest/test/testmock
  53. +ifeq (@LIB2TO3@,yes)
  54. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  55. +TESTSUBDIRS += lib2to3/tests \
  56. + lib2to3/tests/data \
  57. + lib2to3/tests/data/fixers \
  58. + lib2to3/tests/data/fixers/myfixes
  59. +endif
  60. +
  61. ifeq (@TEST_MODULES@,yes)
  62. LIBSUBDIRS += $(TESTSUBDIRS)
  63. endif
  64. @@ -1400,10 +1406,12 @@ ifeq (@PYC_BUILD@,yes)
  65. -d $(LIBDEST)/site-packages -f \
  66. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  67. endif
  68. +ifeq (@LIB2TO3@,yes)
  69. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  70. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  71. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  72. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  73. +endif
  74. python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
  75. # Substitution happens here, as the completely-expanded BINDIR
  76. diff --git a/configure.ac b/configure.ac
  77. index 1621fa1611..13b2edf8b7 100644
  78. --- a/configure.ac
  79. +++ b/configure.ac
  80. @@ -3124,6 +3124,12 @@ AC_ARG_ENABLE(test-modules,
  81. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  82. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  83. +AC_SUBST(LIB2TO3)
  84. +
  85. +AC_ARG_ENABLE(lib2to3,
  86. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  87. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  88. +
  89. # Check for enable-ipv6
  90. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  91. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  92. diff --git a/setup.py b/setup.py
  93. index 94dd337fef..76429e1326 100644
  94. --- a/setup.py
  95. +++ b/setup.py
  96. @@ -2324,10 +2324,11 @@ def main():
  97. import warnings
  98. warnings.filterwarnings("ignore",category=DeprecationWarning)
  99. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  100. - 'Lib/smtpd.py']
  101. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  102. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  103. scripts += [ 'Tools/scripts/pydoc3' ]
  104. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  105. + scripts += [ 'Tools/scripts/2to3' ]
  106. setup(# PyPI Metadata (PEP 301)
  107. name = "Python",
  108. --
  109. 2.13.5