102-optional-2to3.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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: b/Makefile.pre.in
  12. ===================================================================
  13. --- a/Makefile.pre.in
  14. +++ b/Makefile.pre.in
  15. @@ -1107,7 +1107,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. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  25. @@ -1147,7 +1149,6 @@
  26. html json http dbm xmlrpc \
  27. sqlite3 \
  28. logging csv wsgiref urllib \
  29. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  30. ctypes ctypes/macholib \
  31. idlelib idlelib/Icons \
  32. distutils distutils/command $(XMLLIBSUBDIRS) \
  33. @@ -1189,9 +1190,6 @@
  34. test/test_importlib/namespace_pkgs/module_and_namespace_package \
  35. test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
  36. sqlite3/test \
  37. - lib2to3/tests \
  38. - lib2to3/tests/data lib2to3/tests/data/fixers \
  39. - lib2to3/tests/data/fixers/myfixes \
  40. ctypes/test \
  41. idlelib/idle_test \
  42. distutils/tests \
  43. @@ -1204,6 +1202,14 @@
  44. LIBSUBDIRS += pydoc_data
  45. endif
  46. +ifeq (@LIB2TO3@,yes)
  47. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  48. +TESTSUBDIRS += lib2to3/tests \
  49. + lib2to3/tests/data \
  50. + lib2to3/tests/data/fixers \
  51. + lib2to3/tests/data/fixers/myfixes
  52. +endif
  53. +
  54. ifeq (@TEST_MODULES@,yes)
  55. LIBSUBDIRS += $(TESTSUBDIRS)
  56. endif
  57. @@ -1299,10 +1305,12 @@
  58. -d $(LIBDEST)/site-packages -f $(STDLIB_CACHE_FLAGS) \
  59. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  60. endif
  61. +ifeq (@LIB2TO3@,yes)
  62. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  63. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  64. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  65. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  66. +endif
  67. # Create the PLATDIR source directory, if one wasn't distributed..
  68. $(srcdir)/Lib/$(PLATDIR):
  69. Index: b/setup.py
  70. ===================================================================
  71. --- a/setup.py
  72. +++ b/setup.py
  73. @@ -2201,10 +2201,11 @@
  74. import warnings
  75. warnings.filterwarnings("ignore",category=DeprecationWarning)
  76. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  77. - 'Lib/smtpd.py']
  78. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  79. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  80. scripts += [ 'Tools/scripts/pydoc3' ]
  81. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  82. + scripts += [ 'Tools/scripts/2to3' ]
  83. setup(# PyPI Metadata (PEP 301)
  84. name = "Python",
  85. Index: b/configure.ac
  86. ===================================================================
  87. --- a/configure.ac
  88. +++ b/configure.ac
  89. @@ -2687,6 +2687,12 @@
  90. AS_HELP_STRING([--disable-test-modules], [disable test modules]),
  91. [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
  92. +AC_SUBST(LIB2TO3)
  93. +
  94. +AC_ARG_ENABLE(lib2to3,
  95. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  96. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  97. +
  98. # Check for enable-ipv6
  99. AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  100. AC_MSG_CHECKING([if --enable-ipv6 is specified])