0004-Add-an-option-to-disable-lib2to3.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. From 2a4b87bb00805156d40782a3197fbbf20937da6f Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 22 Feb 2017 17:15:31 -0800
  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. [ Andrey Smirnov: ported to Python 3.6 ]
  10. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
  11. [ Adam Duskett: ported to Python 3.10.0 ]
  12. Signed-off-by: Adam Duskett <aduskett@gmail.com>
  13. [ Bernd Kuhls: ported to Python 3.11.4]
  14. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  15. [ Adam Duskett: ported to Python 3.12.1 ]
  16. Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
  17. ---
  18. Makefile.pre.in | 19 ++++++++++++++-----
  19. configure.ac | 6 ++++++
  20. 2 files changed, 20 insertions(+), 5 deletions(-)
  21. diff --git a/Makefile.pre.in b/Makefile.pre.in
  22. index 401d130b804..b44ad736144 100644
  23. --- a/Makefile.pre.in
  24. +++ b/Makefile.pre.in
  25. @@ -2054,7 +2054,9 @@ ifeq (@PYDOC@,yes)
  26. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  27. endif
  28. -rm -f $(DESTDIR)$(BINDIR)/2to3
  29. +ifeq (@LIB2TO3@,yes)
  30. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  31. +endif
  32. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  33. rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
  34. (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
  35. @@ -2101,7 +2103,6 @@ LIBSUBDIRS= asyncio \
  36. idlelib idlelib/Icons \
  37. importlib importlib/resources importlib/metadata \
  38. json \
  39. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  40. logging \
  41. multiprocessing multiprocessing/dummy \
  42. re \
  43. @@ -2208,10 +2209,6 @@ TESTSUBDIRS= idlelib/idle_test \
  44. test/test_importlib/resources/zipdata02 \
  45. test/test_importlib/source \
  46. test/test_json \
  47. - test/test_lib2to3 \
  48. - test/test_lib2to3/data \
  49. - test/test_lib2to3/data/fixers \
  50. - test/test_lib2to3/data/fixers/myfixes \
  51. test/test_module \
  52. test/test_peg_generator \
  53. test/test_pydoc \
  54. @@ -2268,6 +2265,14 @@ ifeq (@PYDOC@,yes)
  55. LIBSUBDIRS += pydoc_data
  56. endif
  57. +ifeq (@LIB2TO3@,yes)
  58. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  59. +TESTSUBDIRS += test/test_lib2to3 \
  60. + test/test_lib2to3/data \
  61. + test/test_lib2to3/data/fixers \
  62. + test/test_lib2to3/data/fixers/myfixes
  63. +endif
  64. +
  65. TEST_MODULES=@TEST_MODULES@
  66. .PHONY: libinstall
  67. @@ -2351,10 +2356,12 @@ ifeq (@PYC_BUILD@,yes)
  68. -o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
  69. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  70. endif
  71. +ifeq (@LIB2TO3@,yes)
  72. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  73. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  74. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  75. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  76. +endif
  77. # bpo-21536: Misc/python-config.sh is generated in the build directory
  78. # from $(srcdir)Misc/python-config.sh.in.
  79. @@ -2480,7 +2487,9 @@ libainstall: all scripts
  80. $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
  81. $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
  82. $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
  83. +ifeq (@LIB2TO3@,yes)
  84. $(INSTALL_SCRIPT) $(SCRIPT_2TO3) $(DESTDIR)$(BINDIR)/2to3-$(VERSION)
  85. +endif
  86. $(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION)
  87. ifeq (@PYDOC@,yes)
  88. $(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION)
  89. diff --git a/configure.ac b/configure.ac
  90. index ca226dcc5b9..9b77582560d 100644
  91. --- a/configure.ac
  92. +++ b/configure.ac
  93. @@ -7572,6 +7572,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu
  94. # substitute multiline block, must come after last PY_STDLIB_MOD()
  95. AC_SUBST([MODULE_BLOCK])
  96. +AC_SUBST(LIB2TO3)
  97. +
  98. +AC_ARG_ENABLE(lib2to3,
  99. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  100. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  101. +
  102. # generate output files
  103. AC_CONFIG_FILES(m4_normalize([
  104. Makefile.pre
  105. --
  106. 2.39.5