python3-102-optional-2to3.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 | 18 ++++++++++++++----
  8. configure.ac | 6 ++++++
  9. setup.py | 5 +++--
  10. 3 files changed, 23 insertions(+), 6 deletions(-)
  11. Index: cpython/Makefile.pre.in
  12. ===================================================================
  13. --- cpython.orig/Makefile.pre.in
  14. +++ cpython/Makefile.pre.in
  15. @@ -956,7 +956,9 @@
  16. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  17. endif
  18. -rm -f $(DESTDIR)$(BINDIR)/2to3
  19. +ifeq (@LIB2TO3@,yes)
  20. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  21. +endif
  22. -rm -f $(DESTDIR)$(BINDIR)/pyvenv
  23. (cd $(DESTDIR)$(BINDIR); $(LN) -s pyvenv-$(VERSION) pyvenv)
  24. @@ -985,7 +987,6 @@
  25. html json http dbm xmlrpc \
  26. sqlite3 \
  27. logging csv wsgiref urllib \
  28. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  29. ctypes ctypes/macholib idlelib idlelib/Icons \
  30. distutils distutils/command $(XMLLIBSUBDIRS) \
  31. importlib \
  32. @@ -1025,9 +1026,6 @@
  33. test/test_email test/test_email/data \
  34. test/json_tests \
  35. sqlite3/test \
  36. - lib2to3/tests \
  37. - lib2to3/tests/data lib2to3/tests/data/fixers \
  38. - lib2to3/tests/data/fixers/myfixes \
  39. ctypes/test \
  40. distutils/tests \
  41. test/test_importlib test/test_importlib/builtin \
  42. @@ -1040,6 +1038,16 @@
  43. LIBSUBDIRS += pydoc_data
  44. endif
  45. +ifeq (@LIB2TO3@,yes)
  46. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  47. +ifeq (@TEST_MODULES@,yes)
  48. +LIBSUBDIRS += lib2to3/tests \
  49. + lib2to3/tests/data \
  50. + lib2to3/tests/data/fixers \
  51. + lib2to3/tests/data/fixers/myfixes
  52. +endif
  53. +endif
  54. +
  55. libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
  56. @for i in $(SCRIPTDIR) $(LIBDEST); \
  57. do \
  58. @@ -1109,10 +1117,12 @@
  59. $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
  60. -d $(LIBDEST)/site-packages -f \
  61. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  62. +ifeq (@LIB2TO3@,yes)
  63. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  64. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  65. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  66. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  67. +endif
  68. # Create the PLATDIR source directory, if one wasn't distributed..
  69. $(srcdir)/Lib/$(PLATDIR):
  70. Index: cpython/setup.py
  71. ===================================================================
  72. --- cpython.orig/setup.py
  73. +++ cpython/setup.py
  74. @@ -2124,10 +2124,11 @@
  75. import warnings
  76. warnings.filterwarnings("ignore",category=DeprecationWarning)
  77. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  78. - 'Lib/smtpd.py']
  79. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  80. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  81. scripts += [ 'Tools/scripts/pydoc3' ]
  82. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  83. + scripts += [ 'Tools/scripts/2to3' ]
  84. setup(# PyPI Metadata (PEP 301)
  85. name = "Python",
  86. Index: cpython/configure.ac
  87. ===================================================================
  88. --- cpython.orig/configure.ac
  89. +++ cpython/configure.ac
  90. @@ -2460,6 +2460,12 @@
  91. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  92. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  93. +AC_SUBST(LIB2TO3)
  94. +
  95. +AC_ARG_ENABLE(lib2to3,
  96. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  97. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  98. +
  99. # Check for enable-ipv6
  100. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  101. AC_MSG_CHECKING([if --enable-ipv6 is specified])