Browse Source

package/python3: miscellaneous fixups

There is no longer a need to lie about having mercurial installed as of
upstream 5c4b0d063a, so drop the ac_cv_prog_HAS_HG override.

`PYTHON3_REMOVE_USELESS_FILES`, while not exactly useless, had been
referencing stale files and not performing full cleanup:

  * the "m" ABI suffix was dropped in upstream 6c44fde3e0  (python 3.8)
  * the smtpd was dropped in upstream a797fba888  (python 3.1)
  * the wininst* binaries were dropped in upstream 0e2a0f72cc  (python 3.10)

These legacy references have now been dropped.

The smtpd.py file is a bit quirky because despite having been removed
upstream, Buildroot's patches to disable certain modules have been
carrying it forward. This has been rectified.

While here, rework the file removals to accomodate the ABI suffix change
and to globally remove __pycache__ directories. It's important to note
that Buildroot uses legacy pyc placements for sourceless distributions,
meaning __pycache__ is not used at all [0].

When necessary, optimized pyc files will be generated into the correct
paths in subsequent hooks.

[0]: https://peps.python.org/pep-3147/#case-4-legacy-pyc-files-and-source-less-imports

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Vincent Fazio 1 year ago
parent
commit
54d48c8cad

+ 9 - 7
package/python3/0008-Add-an-option-to-disable-pydoc.patch

@@ -1,4 +1,4 @@
-From 77fcd90a1236d59d40aa32d3bc4bef4303eb4066 Mon Sep 17 00:00:00 2001
+From e6284624679a525440dc4bfddc1347f8add22fd8 Mon Sep 17 00:00:00 2001
 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 Date: Wed, 22 Feb 2017 17:07:56 -0800
 Subject: [PATCH] Add an option to disable pydoc
@@ -12,6 +12,8 @@ Signed-off-by: Samuel Martin <s.martin49@gmail.com>
 Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
 [ Adam Duskett: ported to Python 3.10.0 ]
 Signed-off-by: Adam Duskett <aduskett@gmail.com>
+[ Vincent Fazio: fix scripts array to reflect upstream ]
+Signed-off-by: Vincent Fazio <vfazio@gmail.com>
 ---
  Makefile.pre.in | 7 ++++++-
  configure.ac    | 6 ++++++
@@ -19,7 +21,7 @@ Signed-off-by: Adam Duskett <aduskett@gmail.com>
  3 files changed, 19 insertions(+), 3 deletions(-)
 
 diff --git a/Makefile.pre.in b/Makefile.pre.in
-index 5a40b7c5484..e87bc1fcd32 100644
+index 5a40b7c548..e87bc1fcd3 100644
 --- a/Makefile.pre.in
 +++ b/Makefile.pre.in
 @@ -1877,7 +1877,9 @@ bininstall: commoninstall altbininstall
@@ -52,7 +54,7 @@ index 5a40b7c5484..e87bc1fcd32 100644
  libinstall:	all $(srcdir)/Modules/xxmodule.c
  	@for i in $(SCRIPTDIR) $(LIBDEST); \
 diff --git a/configure.ac b/configure.ac
-index b4d7d2cca6a..d56d8f9d1c5 100644
+index b4d7d2cca6..d56d8f9d1c 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -4222,6 +4222,12 @@ AS_VAR_IF([posix_threads], [stub], [
@@ -69,7 +71,7 @@ index b4d7d2cca6a..d56d8f9d1c5 100644
  AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
  AC_MSG_CHECKING([if --enable-ipv6 is specified])
 diff --git a/setup.py b/setup.py
-index 53b066cb18b..d8647724650 100644
+index 53b066cb18..25e6f4fc26 100644
 --- a/setup.py
 +++ b/setup.py
 @@ -1597,6 +1597,12 @@ class DummyProcess:
@@ -77,8 +79,8 @@ index 53b066cb18b..d8647724650 100644
      import warnings
      warnings.filterwarnings("ignore",category=DeprecationWarning)
 +
-+    scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
-+               'Lib/smtpd.py']
++    scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3']
++
 +    if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
 +        scripts += [ 'Tools/scripts/pydoc3' ]
 +
@@ -96,5 +98,5 @@ index 53b066cb18b..d8647724650 100644
  
  # --install-platlib
 -- 
-2.44.0
+2.34.1
 

+ 14 - 13
package/python3/0009-Add-an-option-to-disable-lib2to3.patch

@@ -1,4 +1,4 @@
-From 18e19402fab3939223a58481734e685d25c3102b Mon Sep 17 00:00:00 2001
+From 3fbd10c59a777c4ef7ee1bd3fb70808e25e11703 Mon Sep 17 00:00:00 2001
 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 Date: Wed, 22 Feb 2017 17:15:31 -0800
 Subject: [PATCH] Add an option to disable lib2to3
@@ -14,14 +14,16 @@ Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
 Signed-off-by: Adam Duskett <aduskett@gmail.com>
 [ Bernd Kuhls: ported to Python 3.11.4]
 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
+[ Vincent Fazio: fix scripts array to reflect upstream ]
+Signed-off-by: Vincent Fazio <vfazio@gmail.com>
 ---
  Makefile.pre.in | 17 ++++++++++++-----
  configure.ac    |  6 ++++++
- setup.py        |  6 +++---
- 3 files changed, 21 insertions(+), 8 deletions(-)
+ setup.py        |  4 +++-
+ 3 files changed, 21 insertions(+), 6 deletions(-)
 
 diff --git a/Makefile.pre.in b/Makefile.pre.in
-index e87bc1fcd32..1a0ab0de426 100644
+index e87bc1fcd3..1a0ab0de42 100644
 --- a/Makefile.pre.in
 +++ b/Makefile.pre.in
 @@ -1881,7 +1881,9 @@ ifeq (@PYDOC@,yes)
@@ -82,7 +84,7 @@ index e87bc1fcd32..1a0ab0de426 100644
  # bpo-21536: Misc/python-config.sh is generated in the build directory
  # from $(srcdir)Misc/python-config.sh.in.
 diff --git a/configure.ac b/configure.ac
-index d56d8f9d1c5..bf91fb2f824 100644
+index d56d8f9d1c..bf91fb2f82 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -7147,6 +7147,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu
@@ -99,24 +101,23 @@ index d56d8f9d1c5..bf91fb2f824 100644
  AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
  AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib])
 diff --git a/setup.py b/setup.py
-index d8647724650..e02591dae10 100644
+index 25e6f4fc26..78d880f9db 100644
 --- a/setup.py
 +++ b/setup.py
-@@ -1598,11 +1598,11 @@ class DummyProcess:
+@@ -1598,10 +1598,12 @@ class DummyProcess:
      import warnings
      warnings.filterwarnings("ignore",category=DeprecationWarning)
  
--    scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3',
--               'Lib/smtpd.py']
-+    scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
+-    scripts = ['Tools/scripts/idle3', 'Tools/scripts/2to3']
++    scripts = ['Tools/scripts/idle3']
+ 
      if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
          scripts += [ 'Tools/scripts/pydoc3' ]
--
 +    if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
 +        scripts += [ 'Tools/scripts/2to3' ]
+ 
      setup(# PyPI Metadata (PEP 301)
            name = "Python",
-           version = sys.version.split()[0],
 -- 
-2.44.0
+2.34.1
 

+ 14 - 12
package/python3/0017-Add-an-option-to-disable-IDLE.patch

@@ -1,4 +1,4 @@
-From f74c580b9e5bd8c710627b48cea4e152426e71e6 Mon Sep 17 00:00:00 2001
+From dd4ac2662ae1feaa3a29c4088193e48645b080f7 Mon Sep 17 00:00:00 2001
 From: Maxime Ripard <maxime.ripard@free-electrons.com>
 Date: Wed, 22 Feb 2017 17:45:14 -0800
 Subject: [PATCH] Add an option to disable IDLE
@@ -11,14 +11,16 @@ Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
 Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
 [ Adam Duskett: ported to Python 3.10.0 ]
 Signed-off-by: Adam Duskett <aduskett@gmail.com>
+[ Vincent Fazio: fixup setup array to reflect upstream ]
+Signed-off-by: Vincent Fazio <vfazio@gmail.com>
 ---
  Makefile.pre.in | 7 ++++++-
  configure.ac    | 6 ++++++
- setup.py        | 5 ++++-
- 3 files changed, 16 insertions(+), 2 deletions(-)
+ setup.py        | 4 +++-
+ 3 files changed, 15 insertions(+), 2 deletions(-)
 
 diff --git a/Makefile.pre.in b/Makefile.pre.in
-index 8e5f6762d20..4e407cbcfa9 100644
+index 8e5f6762d2..4e407cbcfa 100644
 --- a/Makefile.pre.in
 +++ b/Makefile.pre.in
 @@ -1875,7 +1875,9 @@ bininstall: commoninstall altbininstall
@@ -51,7 +53,7 @@ index 8e5f6762d20..4e407cbcfa9 100644
  libinstall:	all $(srcdir)/Modules/xxmodule.c
  	@for i in $(SCRIPTDIR) $(LIBDEST); \
 diff --git a/configure.ac b/configure.ac
-index cb7e980e5b5..fe497ec9dfb 100644
+index cb7e980e5b..fe497ec9df 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -7206,6 +7206,12 @@ AC_ARG_ENABLE(lib2to3,
@@ -68,25 +70,25 @@ index cb7e980e5b5..fe497ec9dfb 100644
  AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
  AC_CONFIG_FILES([Modules/Setup.bootstrap Modules/Setup.stdlib])
 diff --git a/setup.py b/setup.py
-index e02591dae10..ada914c5501 100644
+index 78d880f9db..ca05faec97 100644
 --- a/setup.py
 +++ b/setup.py
-@@ -1598,11 +1598,14 @@ class DummyProcess:
+@@ -1598,12 +1598,14 @@ class DummyProcess:
      import warnings
      warnings.filterwarnings("ignore",category=DeprecationWarning)
  
--    scripts = ['Tools/scripts/idle3', 'Lib/smtpd.py']
-+    scripts = [ 'Lib/smtpd.py']
+-    scripts = ['Tools/scripts/idle3']
++    scripts = []
+ 
      if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
          scripts += [ 'Tools/scripts/pydoc3' ]
      if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
          scripts += [ 'Tools/scripts/2to3' ]
 +    if not '--disable-idle3' in sysconfig.get_config_var("CONFIG_ARGS"):
 +        scripts += [ 'Tools/scripts/idle3' ]
-+
+ 
      setup(# PyPI Metadata (PEP 301)
            name = "Python",
-           version = sys.version.split()[0],
 -- 
-2.44.0
+2.34.1
 

+ 6 - 17
package/python3/python3.mk

@@ -36,8 +36,7 @@ HOST_PYTHON3_CONF_OPTS += \
 # Make python believe we don't have 'hg', so that it doesn't try to
 # communicate over the network during the build.
 HOST_PYTHON3_CONF_ENV += \
-	LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags" \
-	ac_cv_prog_HAS_HG=/bin/false
+	LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
 
 PYTHON3_DEPENDENCIES = host-python3 libffi
 
@@ -156,14 +155,11 @@ else
 PYTHON3_CONF_OPTS += --disable-ossaudiodev
 endif
 
-# Make python believe we don't have 'hg', so that it doesn't try to
-# communicate over the network during the build.
 PYTHON3_CONF_ENV += \
 	ac_cv_have_long_long_format=yes \
 	ac_cv_file__dev_ptmx=yes \
 	ac_cv_file__dev_ptc=yes \
-	ac_cv_working_tzset=yes \
-	ac_cv_prog_HAS_HG=/bin/false
+	ac_cv_working_tzset=yes
 
 # GCC is always compliant with IEEE754
 ifeq ($(BR2_ENDIAN),"LITTLE")
@@ -200,18 +196,11 @@ PYTHON3_CONF_OPTS += \
 #
 define PYTHON3_REMOVE_USELESS_FILES
 	rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
-	rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)m-config
 	rm -f $(TARGET_DIR)/usr/bin/python3-config
-	rm -f $(TARGET_DIR)/usr/bin/smtpd.py.3
-	rm -f $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/distutils/command/wininst*.exe
-	for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m-*/ \
-		-type f -not -name Makefile` ; do \
-		rm -f $$i ; \
-	done
-	rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/__pycache__/
-	rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/lib-dynload/sysconfigdata/__pycache__
-	rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/collections/__pycache__
-	rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/importlib/__pycache__
+	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)-*/ \
+		-type f -not -name Makefile -exec rm -rf {} \;
+	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ -type d \
+		-name __pycache__ -exec rm -rf {} \;
 endef
 
 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES