0009-Add-an-option-to-disable-lib2to3.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. From 3fbd10c59a777c4ef7ee1bd3fb70808e25e11703 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. [ Vincent Fazio: fix scripts array to reflect upstream ]
  16. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
  17. ---
  18. Makefile.pre.in | 17 ++++++++++++-----
  19. configure.ac | 6 ++++++
  20. setup.py | 4 +++-
  21. 3 files changed, 21 insertions(+), 6 deletions(-)
  22. diff --git a/Makefile.pre.in b/Makefile.pre.in
  23. index e87bc1fcd3..1a0ab0de42 100644
  24. --- a/Makefile.pre.in
  25. +++ b/Makefile.pre.in
  26. @@ -1881,7 +1881,9 @@ ifeq (@PYDOC@,yes)
  27. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  28. endif
  29. -rm -f $(DESTDIR)$(BINDIR)/2to3
  30. +ifeq (@LIB2TO3@,yes)
  31. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  32. +endif
  33. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  34. rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
  35. (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
  36. @@ -1927,7 +1929,6 @@ LIBSUBDIRS= asyncio \
  37. idlelib idlelib/Icons \
  38. importlib importlib/resources importlib/metadata \
  39. json \
  40. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  41. logging \
  42. multiprocessing multiprocessing/dummy \
  43. re \
  44. @@ -1947,10 +1948,6 @@ LIBSUBDIRS= asyncio \
  45. TESTSUBDIRS= ctypes/test \
  46. distutils/tests \
  47. idlelib/idle_test \
  48. - lib2to3/tests \
  49. - lib2to3/tests/data \
  50. - lib2to3/tests/data/fixers \
  51. - lib2to3/tests/data/fixers/myfixes \
  52. test \
  53. test/audiodata \
  54. test/certdata \
  55. @@ -2074,6 +2071,14 @@ ifeq (@PYDOC@,yes)
  56. LIBSUBDIRS += pydoc_data
  57. endif
  58. +ifeq (@LIB2TO3@,yes)
  59. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  60. +TESTSUBDIRS += lib2to3/tests \
  61. + lib2to3/tests/data \
  62. + lib2to3/tests/data/fixers \
  63. + lib2to3/tests/data/fixers/myfixes
  64. +endif
  65. +
  66. TEST_MODULES=@TEST_MODULES@
  67. libinstall: all $(srcdir)/Modules/xxmodule.c
  68. @for i in $(SCRIPTDIR) $(LIBDEST); \
  69. @@ -2176,10 +2181,12 @@ ifeq (@PYC_BUILD@,yes)
  70. -j0 -d $(LIBDEST)/site-packages -f \
  71. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  72. endif
  73. +ifeq (@LIB2TO3@,yes)
  74. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  75. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
  76. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  77. $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
  78. +endif
  79. # bpo-21536: Misc/python-config.sh is generated in the build directory
  80. # from $(srcdir)Misc/python-config.sh.in.
  81. diff --git a/configure.ac b/configure.ac
  82. index d56d8f9d1c..bf91fb2f82 100644
  83. --- a/configure.ac
  84. +++ b/configure.ac
  85. @@ -7147,6 +7147,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu
  86. # substitute multiline block, must come after last PY_STDLIB_MOD()
  87. AC_SUBST([MODULE_BLOCK])
  88. +AC_SUBST(LIB2TO3)
  89. +
  90. +AC_ARG_ENABLE(lib2to3,
  91. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  92. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  93. +
  94. # generate output files
  95. AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
  96. AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib])
  97. diff --git a/setup.py b/setup.py
  98. index 25e6f4fc26..78d880f9db 100644
  99. --- a/setup.py
  100. +++ b/setup.py
  101. @@ -1598,10 +1598,12 @@ class DummyProcess:
  102. import warnings
  103. warnings.filterwarnings("ignore",category=DeprecationWarning)
  104. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3']
  105. + scripts = ['Tools/scripts/idle3']
  106. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  107. scripts += [ 'Tools/scripts/pydoc3' ]
  108. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  109. + scripts += [ 'Tools/scripts/2to3' ]
  110. setup(# PyPI Metadata (PEP 301)
  111. name = "Python",
  112. --
  113. 2.34.1