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

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