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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From 18e19402fab3939223a58481734e685d25c3102b 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. ---
  16. Makefile.pre.in | 17 ++++++++++++-----
  17. configure.ac | 6 ++++++
  18. setup.py | 6 +++---
  19. 3 files changed, 21 insertions(+), 8 deletions(-)
  20. diff --git a/Makefile.pre.in b/Makefile.pre.in
  21. index e87bc1fcd32..1a0ab0de426 100644
  22. --- a/Makefile.pre.in
  23. +++ b/Makefile.pre.in
  24. @@ -1881,7 +1881,9 @@ ifeq (@PYDOC@,yes)
  25. (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
  26. endif
  27. -rm -f $(DESTDIR)$(BINDIR)/2to3
  28. +ifeq (@LIB2TO3@,yes)
  29. (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
  30. +endif
  31. if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
  32. rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
  33. (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
  34. @@ -1927,7 +1929,6 @@ LIBSUBDIRS= asyncio \
  35. idlelib idlelib/Icons \
  36. importlib importlib/resources importlib/metadata \
  37. json \
  38. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  39. logging \
  40. multiprocessing multiprocessing/dummy \
  41. re \
  42. @@ -1947,10 +1948,6 @@ LIBSUBDIRS= asyncio \
  43. TESTSUBDIRS= ctypes/test \
  44. distutils/tests \
  45. idlelib/idle_test \
  46. - lib2to3/tests \
  47. - lib2to3/tests/data \
  48. - lib2to3/tests/data/fixers \
  49. - lib2to3/tests/data/fixers/myfixes \
  50. test \
  51. test/audiodata \
  52. test/certdata \
  53. @@ -2074,6 +2071,14 @@ ifeq (@PYDOC@,yes)
  54. LIBSUBDIRS += pydoc_data
  55. endif
  56. +ifeq (@LIB2TO3@,yes)
  57. +LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
  58. +TESTSUBDIRS += lib2to3/tests \
  59. + lib2to3/tests/data \
  60. + lib2to3/tests/data/fixers \
  61. + lib2to3/tests/data/fixers/myfixes
  62. +endif
  63. +
  64. TEST_MODULES=@TEST_MODULES@
  65. libinstall: all $(srcdir)/Modules/xxmodule.c
  66. @for i in $(SCRIPTDIR) $(LIBDEST); \
  67. @@ -2176,10 +2181,12 @@ ifeq (@PYC_BUILD@,yes)
  68. -j0 -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. diff --git a/configure.ac b/configure.ac
  80. index d56d8f9d1c5..bf91fb2f824 100644
  81. --- a/configure.ac
  82. +++ b/configure.ac
  83. @@ -7147,6 +7147,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu
  84. # substitute multiline block, must come after last PY_STDLIB_MOD()
  85. AC_SUBST([MODULE_BLOCK])
  86. +AC_SUBST(LIB2TO3)
  87. +
  88. +AC_ARG_ENABLE(lib2to3,
  89. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  90. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  91. +
  92. # generate output files
  93. AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
  94. AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib])
  95. diff --git a/setup.py b/setup.py
  96. index d8647724650..e02591dae10 100644
  97. --- a/setup.py
  98. +++ b/setup.py
  99. @@ -1598,11 +1598,11 @@ class DummyProcess:
  100. import warnings
  101. warnings.filterwarnings("ignore",category=DeprecationWarning)
  102. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  103. - 'Lib/smtpd.py']
  104. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  105. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  106. scripts += [ 'Tools/scripts/pydoc3' ]
  107. -
  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. version = sys.version.split()[0],
  113. --
  114. 2.44.0