0019-Add-an-option-to-disable-lib2to3.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. From 4d6bc8497ab740ae23a7091ff91dba06a63ba877 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 23 Dec 2015 11:48:44 +0100
  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. ---
  10. Makefile.pre.in | 16 ++++++++++++----
  11. configure.ac | 6 ++++++
  12. setup.py | 5 +++--
  13. 3 files changed, 21 insertions(+), 6 deletions(-)
  14. diff --git a/Makefile.pre.in b/Makefile.pre.in
  15. index 5e2333e..6656f48 100644
  16. --- a/Makefile.pre.in
  17. +++ b/Makefile.pre.in
  18. @@ -1104,7 +1104,9 @@ ifeq (@PYDOC@,yes)
  19. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  20. endif
  21. -rm -f $(DESTDIR)$(BINDIR)/2to3
  22. +ifeq (@LIB2TO3@,yes)
  23. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  24. +endif
  25. -rm -f $(DESTDIR)$(BINDIR)/pyvenv
  26. (cd $(DESTDIR)$(BINDIR); $(LN) -s pyvenv-$(VERSION) pyvenv)
  27. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  28. @@ -1144,7 +1146,6 @@ LIBSUBDIRS= tkinter \
  29. html json http dbm xmlrpc \
  30. sqlite3 \
  31. logging csv wsgiref urllib \
  32. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  33. ctypes ctypes/macholib \
  34. idlelib idlelib/Icons \
  35. distutils distutils/command $(XMLLIBSUBDIRS) \
  36. @@ -1186,9 +1187,6 @@ TESTSUBDIRS = tkinter/test tkinter/test/test_tkinter tkinter/test/test_ttk \
  37. test/test_importlib/namespace_pkgs/module_and_namespace_package \
  38. test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
  39. sqlite3/test \
  40. - lib2to3/tests \
  41. - lib2to3/tests/data lib2to3/tests/data/fixers \
  42. - lib2to3/tests/data/fixers/myfixes \
  43. ctypes/test \
  44. idlelib/idle_test \
  45. distutils/tests \
  46. @@ -1201,6 +1199,14 @@ ifeq (@PYDOC@,yes)
  47. LIBSUBDIRS += pydoc_data
  48. endif
  49. +ifeq (@LIB2TO3@,yes)
  50. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  51. +TESTSUBDIRS += lib2to3/tests \
  52. + lib2to3/tests/data \
  53. + lib2to3/tests/data/fixers \
  54. + lib2to3/tests/data/fixers/myfixes
  55. +endif
  56. +
  57. ifeq (@TEST_MODULES@,yes)
  58. LIBSUBDIRS += $(TESTSUBDIRS)
  59. endif
  60. @@ -1296,10 +1302,12 @@ ifeq (@PYO_BUILD@,yes)
  61. -d $(LIBDEST)/site-packages -f \
  62. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  63. endif
  64. +ifeq (@LIB2TO3@,yes)
  65. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  66. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  67. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  68. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  69. +endif
  70. # Create the PLATDIR source directory, if one wasn't distributed..
  71. $(srcdir)/Lib/$(PLATDIR):
  72. diff --git a/configure.ac b/configure.ac
  73. index 2e75345..0ed6b17 100644
  74. --- a/configure.ac
  75. +++ b/configure.ac
  76. @@ -2670,6 +2670,12 @@ AC_ARG_ENABLE(test-modules,
  77. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  78. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  79. +AC_SUBST(LIB2TO3)
  80. +
  81. +AC_ARG_ENABLE(lib2to3,
  82. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  83. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  84. +
  85. # Check for enable-ipv6
  86. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  87. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  88. diff --git a/setup.py b/setup.py
  89. index 69198db..a2bf05a 100644
  90. --- a/setup.py
  91. +++ b/setup.py
  92. @@ -2201,10 +2201,11 @@ def main():
  93. import warnings
  94. warnings.filterwarnings("ignore",category=DeprecationWarning)
  95. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  96. - 'Lib/smtpd.py']
  97. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  98. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  99. scripts += [ 'Tools/scripts/pydoc3' ]
  100. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  101. + scripts += [ 'Tools/scripts/2to3' ]
  102. setup(# PyPI Metadata (PEP 301)
  103. name = "Python",
  104. --
  105. 2.6.4