python-2.7-102-optional-2to3.patch 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Add an option to disable lib2to3
  2. lib2to3 is a library to convert Python 2.x code to Python 3.x. As
  3. such, it is probably not very useful on embedded system targets.
  4. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  5. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  6. ---
  7. Makefile.pre.in | 24 +++++++++++++++++-------
  8. configure.in | 6 ++++++
  9. setup.py | 5 +++--
  10. 3 files changed, 26 insertions(+), 9 deletions(-)
  11. Index: Python-2.7.2/Makefile.pre.in
  12. ===================================================================
  13. --- Python-2.7.2.orig/Makefile.pre.in
  14. +++ Python-2.7.2/Makefile.pre.in
  15. @@ -862,7 +862,6 @@
  16. json \
  17. sqlite3 \
  18. logging bsddb csv importlib wsgiref \
  19. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  20. ctypes ctypes/macholib idlelib idlelib/Icons \
  21. distutils distutils/command $(XMLLIBSUBDIRS) \
  22. multiprocessing multiprocessing/dummy \
  23. @@ -875,8 +874,7 @@
  24. lib-tk/test/test_ttk test test/data \
  25. test/cjkencodings test/decimaltestdata test/xmltestdata test/subprocessdata \
  26. test/tracedmodules email/test email/test/data \
  27. - json/tests sqlite3/test bsddb/test lib2to3/tests \
  28. - lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
  29. + json/tests sqlite3/test bsddb/test \
  30. ctypes/test distutils/tests unittest/test
  31. endif
  32. @@ -884,6 +882,16 @@
  33. LIBSUBDIRS += pydoc_data
  34. endif
  35. +ifeq (@LIB2TO3@,yes)
  36. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  37. +ifeq (@TEST_MODULES@,yes)
  38. +LIBSUBDIRS += lib2to3/tests \
  39. + lib2to3/tests/data \
  40. + lib2to3/tests/data/fixers \
  41. + lib2to3/tests/data/fixers/myfixes
  42. +endif
  43. +endif
  44. +
  45. libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
  46. @for i in $(SCRIPTDIR) $(LIBDEST); \
  47. do \
  48. Index: Python-2.7.2/configure.in
  49. ===================================================================
  50. --- Python-2.7.2.orig/configure.in
  51. +++ Python-2.7.2/configure.in
  52. @@ -2419,6 +2419,12 @@
  53. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  54. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  55. +AC_SUBST(LIB2TO3)
  56. +
  57. +AC_ARG_ENABLE(lib2to3,
  58. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  59. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  60. +
  61. # Check for enable-ipv6
  62. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  63. AC_MSG_CHECKING([if --enable-ipv6 is specified])
  64. Index: Python-2.7.2/setup.py
  65. ===================================================================
  66. --- Python-2.7.2.orig/setup.py
  67. +++ Python-2.7.2/setup.py
  68. @@ -2093,10 +2093,11 @@
  69. import warnings
  70. warnings.filterwarnings("ignore",category=DeprecationWarning)
  71. - scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
  72. - 'Lib/smtpd.py']
  73. + scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
  74. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  75. scripts += [ 'Tools/scripts/pydoc' ]
  76. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  77. + scripts += [ 'Tools/scripts/2to3' ]
  78. setup(# PyPI Metadata (PEP 301)
  79. name = "Python",