0018-Add-an-option-to-disable-lib2to3.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From d0cf9ebed6d34d820cf594578cf513797fb52772 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Tue, 7 Mar 2017 22:27:49 +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 | 11 ++++++++---
  11. configure.ac | 6 ++++++
  12. setup.py | 5 +++--
  13. 3 files changed, 17 insertions(+), 5 deletions(-)
  14. diff --git a/Makefile.pre.in b/Makefile.pre.in
  15. index 84d5fc6..b2a0490 100644
  16. --- a/Makefile.pre.in
  17. +++ b/Makefile.pre.in
  18. @@ -1045,7 +1045,6 @@ LIBSUBDIRS= lib-tk site-packages \
  19. json \
  20. sqlite3 \
  21. logging bsddb csv importlib wsgiref \
  22. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  23. ctypes ctypes/macholib \
  24. idlelib idlelib/Icons \
  25. distutils distutils/command $(XMLLIBSUBDIRS) \
  26. @@ -1064,8 +1063,6 @@ TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
  27. json/tests \
  28. sqlite3/test \
  29. bsddb/test \
  30. - lib2to3/tests \
  31. - lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
  32. ctypes/test \
  33. idlelib/idle_test \
  34. distutils/tests \
  35. @@ -1079,6 +1076,14 @@ ifeq (@PYDOC@,yes)
  36. LIBSUBDIRS += pydoc_data
  37. endif
  38. +ifeq (@LIB2TO3@,yes)
  39. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  40. +TESTSUBDIRS += lib2to3/tests \
  41. + lib2to3/tests/data \
  42. + lib2to3/tests/data/fixers \
  43. + lib2to3/tests/data/fixers/myfixes
  44. +endif
  45. +
  46. libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
  47. @for i in $(SCRIPTDIR) $(LIBDEST); \
  48. do \
  49. diff --git a/configure.ac b/configure.ac
  50. index 8bab160..270f337 100644
  51. --- a/configure.ac
  52. +++ b/configure.ac
  53. @@ -2817,6 +2817,12 @@ AC_ARG_ENABLE(test-modules,
  54. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  55. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  56. +AC_SUBST(LIB2TO3)
  57. +
  58. +AC_ARG_ENABLE(lib2to3,
  59. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  60. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  61. +
  62. # Check for enable-ipv6
  63. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  64. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  65. diff --git a/setup.py b/setup.py
  66. index 69771e2..f51ef8c 100644
  67. --- a/setup.py
  68. +++ b/setup.py
  69. @@ -2234,10 +2234,11 @@ def main():
  70. import warnings
  71. warnings.filterwarnings("ignore",category=DeprecationWarning)
  72. - scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
  73. - 'Lib/smtpd.py']
  74. + scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
  75. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  76. scripts += [ 'Tools/scripts/pydoc' ]
  77. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  78. + scripts += [ 'Tools/scripts/2to3' ]
  79. setup(# PyPI Metadata (PEP 301)
  80. name = "Python",
  81. --
  82. 2.7.4