0013-Add-an-option-to-disable-lib2to3.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. From f034b1b0f33a7bd4dde23f0bc1fa8e00e3518c9d 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 | 5 +++++
  16. setup.py | 6 +++---
  17. 3 files changed, 20 insertions(+), 8 deletions(-)
  18. diff --git a/Makefile.pre.in b/Makefile.pre.in
  19. index 28cf88e..63fa9fb 100644
  20. --- a/Makefile.pre.in
  21. +++ b/Makefile.pre.in
  22. @@ -1395,7 +1395,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. @@ -1441,7 +1443,6 @@ LIBSUBDIRS= asyncio \
  33. idlelib idlelib/Icons \
  34. importlib importlib/metadata \
  35. json \
  36. - lib2to3 lib2to3/fixes lib2to3/pgen2 \
  37. logging \
  38. multiprocessing multiprocessing/dummy \
  39. site-packages \
  40. @@ -1458,10 +1459,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. sqlite3/test \
  49. test test/audiodata \
  50. test/capath test/cjkencodings \
  51. @@ -1535,6 +1532,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: build_all $(srcdir)/Modules/xxmodule.c
  64. @for i in $(SCRIPTDIR) $(LIBDEST); \
  65. @@ -1637,10 +1642,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 9079531..34c2ba9 100644
  79. --- a/configure.ac
  80. +++ b/configure.ac
  81. @@ -6014,6 +6014,11 @@ else
  82. fi
  83. AC_SUBST(TEST_MODULES)
  84. +AC_SUBST(LIB2TO3)
  85. +
  86. +AC_ARG_ENABLE(lib2to3,
  87. + AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
  88. + [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
  89. # generate output files
  90. AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
  91. diff --git a/setup.py b/setup.py
  92. index d23f148..663fd44 100644
  93. --- a/setup.py
  94. +++ b/setup.py
  95. @@ -2722,11 +2722,11 @@ def main():
  96. import warnings
  97. warnings.filterwarnings("ignore",category=DeprecationWarning)
  98. - scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
  99. - 'Lib/smtpd.py']
  100. + scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
  101. if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
  102. scripts += [ 'Tools/scripts/pydoc3' ]
  103. -
  104. + if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
  105. + scripts += [ 'Tools/scripts/2to3' ]
  106. setup(# PyPI Metadata (PEP 301)
  107. name = "Python",
  108. version = sys.version.split()[0],
  109. --
  110. 2.30.2