first commit: base 2024.08

Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
tao89959
2025-02-12 17:59:29 +08:00
committed by maoxiaochuan
commit f3217a7708
14356 changed files with 572894 additions and 0 deletions
@@ -0,0 +1,58 @@
From 5d0f69ce7fc05adbd3c71e113c11da0aedbca33a Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Wed, 22 Feb 2017 16:21:31 -0800
Subject: [PATCH] Make the build of pyc files conditional
This commit adds a new configure option --disable-pyc-build to disable
the compilation of pyc.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[ Andrey Smrinov: ported to Python 3.6 ]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
[ Adam Duskett: ported to Python 3.12.0 ]
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
Makefile.pre.in | 2 ++
configure.ac | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 4a957fb004..9c5f3c031a 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2329,6 +2329,7 @@ libinstall: all $(srcdir)/Modules/xxmodule.c
$(DESTDIR)$(LIBDEST); \
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
@ # Build PYC files for the 3 optimization levels (0, 1, 2)
+ifeq (@PYC_BUILD@,yes)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST) -f \
@@ -2338,6 +2339,7 @@ libinstall: all $(srcdir)/Modules/xxmodule.c
$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+endif
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
diff --git a/configure.ac b/configure.ac
index 8a32cb58f4..611c33949a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1479,6 +1479,12 @@ fi
AC_MSG_CHECKING([LDLIBRARY])
+AC_SUBST(PYC_BUILD)
+
+AC_ARG_ENABLE(pyc-build,
+ AS_HELP_STRING([--disable-pyc-build], [disable build of pyc files]),
+ [ PYC_BUILD="${enableval}" ], [ PYC_BUILD=yes ])
+
# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
# library that we build, but we do not want to link against it (we
# will find it with a -framework option). For this reason there is an
--
2.34.1
@@ -0,0 +1,27 @@
From 3a0d7824f7ddd4dd0336c8419cb4246ba936d711 Mon Sep 17 00:00:00 2001
From: Vanya Sergeev <vsergeev@gmail.com>
Date: Wed, 23 Dec 2015 11:30:33 +0100
Subject: [PATCH] Disable buggy_getaddrinfo configure test when cross-compiling
with IPv6 support
Signed-off-by: Vanya Sergeev <vsergeev@gmail.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 611c33949a..059ac2f883 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5428,7 +5428,7 @@ fi]))
dnl if ac_cv_func_getaddrinfo
])
-if test "$ac_cv_func_getaddrinfo" = no -o "$ac_cv_buggy_getaddrinfo" = yes
+if test "$ac_cv_func_getaddrinfo" = no || test "$cross_compiling" != "yes" -a "$ac_cv_buggy_getaddrinfo" = yes
then
AS_VAR_IF([ipv6], [yes], [
AC_MSG_ERROR([m4_normalize([
--
2.34.1
@@ -0,0 +1,84 @@
From f910bdee70b07792c136aaced3850a08eaaafdee 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
It removes 0.5 MB of data from the target plus the pydoc script
itself.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
[ Adam Duskett: ported to Python 3.12.1 ]
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
Makefile.pre.in | 9 ++++++++-
configure.ac | 6 ++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 9c5f3c031a..2243a658a9 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2050,7 +2050,9 @@ bininstall: commoninstall altbininstall
-rm -f $(DESTDIR)$(BINDIR)/idle3
(cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
-rm -f $(DESTDIR)$(BINDIR)/pydoc3
+ifeq (@PYDOC@,yes)
(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
+endif
-rm -f $(DESTDIR)$(BINDIR)/2to3
(cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
@@ -2102,7 +2104,6 @@ LIBSUBDIRS= asyncio \
lib2to3 lib2to3/fixes lib2to3/pgen2 \
logging \
multiprocessing multiprocessing/dummy \
- pydoc_data \
re \
site-packages \
sqlite3 \
@@ -2257,6 +2258,10 @@ TESTSUBDIRS= idlelib/idle_test \
COMPILEALL_OPTS=-j0
+ifeq (@PYDOC@,yes)
+LIBSUBDIRS += pydoc_data
+endif
+
TEST_MODULES=@TEST_MODULES@
.PHONY: libinstall
@@ -2471,7 +2476,9 @@ libainstall: all scripts
$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
$(INSTALL_SCRIPT) $(SCRIPT_2TO3) $(DESTDIR)$(BINDIR)/2to3-$(VERSION)
$(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION)
+ifeq (@PYDOC@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION)
+endif
@if [ -s Modules/python.exp -a \
"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
echo; echo "Installing support files for building shared extension modules on AIX:"; \
diff --git a/configure.ac b/configure.ac
index 059ac2f883..1a2dd28d1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4511,6 +4511,12 @@ AS_VAR_IF([posix_threads], [stub], [
AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
])
+AC_SUBST(PYDOC)
+
+AC_ARG_ENABLE(pydoc,
+ AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
+ [ PYDOC="${enableval}" ], [ PYDOC=yes ])
+
# Check for enable-ipv6
AH_TEMPLATE([ENABLE_IPV6], [Define if --enable-ipv6 is specified])
AC_MSG_CHECKING([if --enable-ipv6 is specified])
--
2.34.1
@@ -0,0 +1,114 @@
From 572f3164d1dce13db30e897ab0be7c706fa7b731 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
lib2to3 is a library to convert Python 2.x code to Python 3.x. As
such, it is probably not very useful on embedded system targets.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
[ Bernd Kuhls: ported to Python 3.11.4]
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[ Adam Duskett: ported to Python 3.12.1 ]
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
Makefile.pre.in | 19 ++++++++++++++-----
configure.ac | 6 ++++++
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 2243a658a9..3f314d1354 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2054,7 +2054,9 @@ ifeq (@PYDOC@,yes)
(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
endif
-rm -f $(DESTDIR)$(BINDIR)/2to3
+ifeq (@LIB2TO3@,yes)
(cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
+endif
if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
@@ -2101,7 +2103,6 @@ LIBSUBDIRS= asyncio \
idlelib idlelib/Icons \
importlib importlib/resources importlib/metadata \
json \
- lib2to3 lib2to3/fixes lib2to3/pgen2 \
logging \
multiprocessing multiprocessing/dummy \
re \
@@ -2207,10 +2208,6 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_importlib/resources/zipdata02 \
test/test_importlib/source \
test/test_json \
- test/test_lib2to3 \
- test/test_lib2to3/data \
- test/test_lib2to3/data/fixers \
- test/test_lib2to3/data/fixers/myfixes \
test/test_module \
test/test_peg_generator \
test/test_pydoc \
@@ -2262,6 +2259,14 @@ ifeq (@PYDOC@,yes)
LIBSUBDIRS += pydoc_data
endif
+ifeq (@LIB2TO3@,yes)
+LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
+TESTSUBDIRS += test/test_lib2to3 \
+ test/test_lib2to3/data \
+ test/test_lib2to3/data/fixers \
+ test/test_lib2to3/data/fixers/myfixes
+endif
+
TEST_MODULES=@TEST_MODULES@
.PHONY: libinstall
@@ -2345,10 +2350,12 @@ ifeq (@PYC_BUILD@,yes)
-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
endif
+ifeq (@LIB2TO3@,yes)
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
+endif
# bpo-21536: Misc/python-config.sh is generated in the build directory
# from $(srcdir)Misc/python-config.sh.in.
@@ -2474,7 +2481,9 @@ libainstall: all scripts
$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
$(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
+ifeq (@LIB2TO3@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_2TO3) $(DESTDIR)$(BINDIR)/2to3-$(VERSION)
+endif
$(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION)
ifeq (@PYDOC@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION)
diff --git a/configure.ac b/configure.ac
index 1a2dd28d1e..f0354c580d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7561,6 +7561,12 @@ PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_fu
# substitute multiline block, must come after last PY_STDLIB_MOD()
AC_SUBST([MODULE_BLOCK])
+AC_SUBST(LIB2TO3)
+
+AC_ARG_ENABLE(lib2to3,
+ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
+ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
+
# generate output files
AC_CONFIG_FILES(m4_normalize([
Makefile.pre
--
2.34.1
@@ -0,0 +1,83 @@
From ffa7fbceb54918eb518474c8f821fda0a58cf181 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
IDLE is an IDE embedded into python, written using Tk, so it doesn't make
much sense to have it into our build.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
[ Adam Duskett: ported to Python 3.12.1 ]
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
Makefile.pre.in | 9 ++++++++-
configure.ac | 6 ++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 3f314d1354..5fad7f82fb 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2048,7 +2048,9 @@ bininstall: commoninstall altbininstall
-rm -f $(DESTDIR)$(LIBPC)/python3-embed.pc
(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python3-embed.pc)
-rm -f $(DESTDIR)$(BINDIR)/idle3
+ifeq (@IDLE@,yes)
(cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
+endif
-rm -f $(DESTDIR)$(BINDIR)/pydoc3
ifeq (@PYDOC@,yes)
(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
@@ -2100,7 +2102,6 @@ LIBSUBDIRS= asyncio \
ensurepip ensurepip/_bundled \
html \
http \
- idlelib idlelib/Icons \
importlib importlib/resources importlib/metadata \
json \
logging \
@@ -2267,6 +2268,10 @@ TESTSUBDIRS += test/test_lib2to3 \
test/test_lib2to3/data/fixers/myfixes
endif
+ifeq (@IDLE@,yes)
+LIBSUBDIRS += idlelib idlelib/Icons
+endif
+
TEST_MODULES=@TEST_MODULES@
.PHONY: libinstall
@@ -2484,7 +2489,9 @@ libainstall: all scripts
ifeq (@LIB2TO3@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_2TO3) $(DESTDIR)$(BINDIR)/2to3-$(VERSION)
endif
+ifeq (@IDLE@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION)
+endif
ifeq (@PYDOC@,yes)
$(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION)
endif
diff --git a/configure.ac b/configure.ac
index f0354c580d..43086962e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7567,6 +7567,12 @@ AC_ARG_ENABLE(lib2to3,
AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
[ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
+AC_SUBST(IDLE)
+
+AC_ARG_ENABLE(idle3,
+ AS_HELP_STRING([--disable-idle3], [disable idle3 IDE]),
+ [ IDLE="${enableval}" ], [ IDLE=yes ])
+
# generate output files
AC_CONFIG_FILES(m4_normalize([
Makefile.pre
--
2.34.1
@@ -0,0 +1,44 @@
From 267516c76208e63b5a3ec7d4dead6c329d8763bb Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Tue, 6 Feb 2024 22:46:59 +0100
Subject: [PATCH] configure.ac: move PY_STDLIB_MOD_SET_NA further up
We will need PY_STDLIB_MOD_SET_NA in next patches further up in the
configure.ac script.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
configure.ac | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 43086962e9..561e33f550 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,11 @@ AC_DEFUN([PY_CHECK_EMSCRIPTEN_PORT], [
AS_VAR_POPDEF([py_libs])
])
+AC_DEFUN([PY_STDLIB_MOD_SET_NA], [
+ m4_foreach([mod], [$@], [
+ AS_VAR_SET([py_cv_module_]mod, [n/a])])
+])
+
AC_SUBST([BASECPPFLAGS])
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
# If we're building out-of-tree, we need to make sure the following
@@ -7258,11 +7263,6 @@ AC_ARG_ENABLE([test-modules],
AC_MSG_RESULT([$TEST_MODULES])
AC_SUBST([TEST_MODULES])
-AC_DEFUN([PY_STDLIB_MOD_SET_NA], [
- m4_foreach([mod], [$@], [
- AS_VAR_SET([py_cv_module_]mod, [n/a])])
-])
-
# stdlib not available
dnl Modules that are not available on some platforms
dnl AIX has shadow passwords, but access is not via getspent()
--
2.34.1
@@ -0,0 +1,61 @@
From a8566f6ee2a2b859ba5562f2d9f06cb4d271f277 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Tue, 6 Feb 2024 22:12:20 +0100
Subject: [PATCH] Add option to disable the sqlite3 module
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
Makefile.pre.in | 5 ++++-
configure.ac | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 5fad7f82fb..7b6c9811a6 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2108,7 +2108,6 @@ LIBSUBDIRS= asyncio \
multiprocessing multiprocessing/dummy \
re \
site-packages \
- sqlite3 \
tkinter \
tomllib \
turtledemo \
@@ -2272,6 +2271,10 @@ ifeq (@IDLE@,yes)
LIBSUBDIRS += idlelib idlelib/Icons
endif
+ifeq (@SQLITE3@,yes)
+LIBSUBDIRS += sqlite3
+endif
+
TEST_MODULES=@TEST_MODULES@
.PHONY: libinstall
diff --git a/configure.ac b/configure.ac
index 561e33f550..d1c54bd67c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4516,6 +4516,13 @@ AS_VAR_IF([posix_threads], [stub], [
AC_DEFINE([HAVE_PTHREAD_STUBS], [1], [Define if platform requires stubbed pthreads support])
])
+AC_SUBST(SQLITE3)
+AC_ARG_ENABLE(sqlite3,
+ AS_HELP_STRING([--disable-sqlite3], [disable sqlite3]),
+ [ SQLITE3="${enableval}" ], [ SQLITE3=yes ])
+AS_IF([test "$SQLITE3" = "no"],
+ [PY_STDLIB_MOD_SET_NA([_sqlite3])])
+
AC_SUBST(PYDOC)
AC_ARG_ENABLE(pydoc,
--
2.34.1
@@ -0,0 +1,81 @@
From c1ec9fa46cd7679fd009f66a3ebed8de95d84f10 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Wed, 22 Feb 2017 17:23:42 -0800
Subject: [PATCH] Add an option to disable the tk module
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
[ Bernd Kuhls: ported to Python 3.11.4]
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[ Adam Duskett: ported to Python 3.12.1 ]
Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
Makefile.pre.in | 8 +++++---
configure.ac | 7 +++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 7b6c9811a6..6d9527ddd0 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2108,7 +2108,6 @@ LIBSUBDIRS= asyncio \
multiprocessing multiprocessing/dummy \
re \
site-packages \
- tkinter \
tomllib \
turtledemo \
unittest \
@@ -2212,7 +2211,6 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_peg_generator \
test/test_pydoc \
test/test_sqlite3 \
- test/test_tkinter \
test/test_tomllib \
test/test_tomllib/data \
test/test_tomllib/data/invalid \
@@ -2232,7 +2230,6 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_tomllib/data/valid/dates-and-times \
test/test_tomllib/data/valid/multiline-basic-str \
test/test_tools \
- test/test_ttk \
test/test_unittest \
test/test_unittest/testmock \
test/test_warnings \
@@ -2253,6 +2250,11 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_multiprocessing_forkserver \
test/test_multiprocessing_spawn
+ifeq (@TK@,yes)
+LIBSUBDIRS += tkinter
+TESTSUBDIRS += test/test_tkinter test/test_ttk
+endif
+
COMPILEALL_OPTS=-j0
ifeq (@PYDOC@,yes)
diff --git a/configure.ac b/configure.ac
index d1c54bd67c..4c5cbe4153 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4529,6 +4529,13 @@ AC_ARG_ENABLE(pydoc,
AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
[ PYDOC="${enableval}" ], [ PYDOC=yes ])
+AC_SUBST(TK)
+AC_ARG_ENABLE(tk,
+ AS_HELP_STRING([--disable-tk], [disable tk]),
+ [ TK="${enableval}" ], [ TK=yes ])
+AS_IF([test "$TK" = "no"],
+ [PY_STDLIB_MOD_SET_NA([_tkinter])])
+
# Check for enable-ipv6
AH_TEMPLATE([ENABLE_IPV6], [Define if --enable-ipv6 is specified])
AC_MSG_CHECKING([if --enable-ipv6 is specified])
--
2.34.1
@@ -0,0 +1,60 @@
From d7ea122e8ae506019761b92987b141fe7ea55f76 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Wed, 22 Feb 2017 17:31:51 -0800
Subject: [PATCH] Add an option to disable the curses module
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
---
Makefile.pre.in | 5 ++++-
configure.ac | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 6d9527ddd0..283ca1bd60 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2095,7 +2095,6 @@ LIBSUBDIRS= asyncio \
concurrent concurrent/futures \
csv \
ctypes ctypes/macholib \
- curses \
dbm \
email email/mime \
encodings \
@@ -2255,6 +2254,10 @@ LIBSUBDIRS += tkinter
TESTSUBDIRS += test/test_tkinter test/test_ttk
endif
+ifeq (@CURSES@,yes)
+LIBSUBDIRS += curses
+endif
+
COMPILEALL_OPTS=-j0
ifeq (@PYDOC@,yes)
diff --git a/configure.ac b/configure.ac
index 4c5cbe4153..92d663ed40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4523,6 +4523,13 @@ AC_ARG_ENABLE(sqlite3,
AS_IF([test "$SQLITE3" = "no"],
[PY_STDLIB_MOD_SET_NA([_sqlite3])])
+AC_SUBST(CURSES)
+AC_ARG_ENABLE(curses,
+ AS_HELP_STRING([--disable-curses], [disable curses]),
+ [ CURSES="${enableval}" ], [ CURSES=yes ])
+AS_IF([test "$CURSES" = "no"],
+ [PY_STDLIB_MOD_SET_NA([_curses], [_curses_panel])])
+
AC_SUBST(PYDOC)
AC_ARG_ENABLE(pydoc,
--
2.34.1
@@ -0,0 +1,83 @@
From d1701f1c89e9d2319ede200052319183fbb4ae18 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Wed, 22 Feb 2017 17:40:45 -0800
Subject: [PATCH] Add an option to disable expat
This patch replaces the existing --with-system-expat option with a
--with-expat={system,builtin,none} option, which allows to tell Python
whether we want to use the system expat (already installed), the expat
builtin the Python sources, or no expat at all (which disables the
installation of XML modules).
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
[ Andrey Smirnov: ported to Python 3.6 ]
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>
---
Makefile.pre.in | 5 ++++-
configure.ac | 24 +++++++++++++-----------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 283ca1bd60..13f7512f42 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2113,7 +2113,6 @@ LIBSUBDIRS= asyncio \
urllib \
venv venv/scripts venv/scripts/common venv/scripts/posix \
wsgiref \
- $(XMLLIBSUBDIRS) \
xmlrpc \
zipfile zipfile/_path \
zoneinfo \
@@ -2280,6 +2279,10 @@ ifeq (@SQLITE3@,yes)
LIBSUBDIRS += sqlite3
endif
+ifeq (@EXPAT@,yes)
+LIBSUBDIRS += $(XMLLIBSUBDIRS)
+endif
+
TEST_MODULES=@TEST_MODULES@
.PHONY: libinstall
diff --git a/configure.ac b/configure.ac
index 92d663ed40..1cb95f41fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3823,17 +3823,19 @@ LIBS="$withval $LIBS"
[AC_MSG_RESULT([no])])
# Check for use of the system expat library
-AC_MSG_CHECKING([for --with-system-expat])
-AC_ARG_WITH(
- [system_expat],
- [AS_HELP_STRING(
- [--with-system-expat],
- [build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no)]
- )], [], [with_system_expat="no"])
-
-AC_MSG_RESULT([$with_system_expat])
-
-AS_VAR_IF([with_system_expat], [yes], [
+AC_MSG_CHECKING(for --with-expat)
+AC_ARG_WITH(expat,
+ AS_HELP_STRING([--with-expat], [select which expat version to use: system, builtin, none]),
+ [],
+ [with_expat="builtin"])
+AC_MSG_RESULT($with_expat)
+AS_IF([test "$with_expat" != "none"],
+ [EXPAT=yes],
+ [PY_STDLIB_MOD_SET_NA([pyexpat])
+ EXPAT=no])
+AC_SUBST(EXPAT)
+
+AS_VAR_IF([with_expat], [system], [
LIBEXPAT_CFLAGS=${LIBEXPAT_CFLAGS-""}
LIBEXPAT_LDFLAGS=${LIBEXPAT_LDFLAGS-"-lexpat"}
LIBEXPAT_INTERNAL=
--
2.34.1
@@ -0,0 +1,53 @@
From 3eccbd53df3c51c1c6ece217d19f1d01eb9575a7 Mon Sep 17 00:00:00 2001
From: Peter Korsgaard <peter@korsgaard.com>
Date: Fri, 2 Aug 2019 15:53:16 +0200
Subject: [PATCH] configure.ac: fixup $CC --print-multiarch output for
musl/uclibc GCC 8+ toolchains
GCC commit 6834b83784dcf0364eb820e8 (multiarch support for non-glibc linux
systems), which is part of GCC 8+, changed the multiarch logic to use
$arch-linux-musl / $arch-linux-uclibc rather than $arch-linux-gnu.
This then causes the python3 configure script to error out:
checking for the platform triplet based on compiler characteristics... powerpc-linux-gnu
configure: error: internal configure error for the platform triplet, please file a bug report
http://autobuild.buildroot.net/results/cb4/cb49c539501342e45cbe5ade82e588fcdf51f05b
As it requires that the --print-multiarch output (if not empty) matches the
deduced triplet (which always uses -linux-gnu).
It isn't quite clear why --print-multiarch returns something for a
non-multiarch toolchain on some architectures (E.G. PowerPC), but as a
workaround, rewrite the --print-multiarch output to match older GCC versions
to keep the configure script happy.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
[Peter: updated for 3.10.2]
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
[Vincent: fixup offsets for 3.12.4]
---
configure.ac | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1cb95f41fd..d142af404a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1128,7 +1128,11 @@ AC_MSG_CHECKING([for multiarch])
AS_CASE([$ac_sys_system],
[Darwin*], [MULTIARCH=""],
[FreeBSD*], [MULTIARCH=""],
- [MULTIARCH=$($CC --print-multiarch 2>/dev/null)]
+ [
+ # GCC 8+ returns $arch-linux-{musl,uclibc} for musl/uClibc based
+ # toolchains confusing python. Fix that up
+ MULTIARCH=$($CC --print-multiarch 2>/dev/null | sed -E 's/-linux-(musl|uclibc)*$/-linux-gnu/')
+ ]
)
AC_SUBST([MULTIARCH])
AC_MSG_RESULT([$MULTIARCH])
--
2.34.1
@@ -0,0 +1,140 @@
From e7fa6023be567251b409527bd005b93335914501 Mon Sep 17 00:00:00 2001
From: Vincent Fazio <5265893+vfazio@users.noreply.github.com>
Date: Wed, 28 Feb 2024 13:55:04 -0600
Subject: [PATCH] gh-115382: Fix cross compiles when host and target use same
SOABI
Previously, when a build was configured to use a host interpreter via
--with-build-python, the PYTHON_FOR_BUILD config value included a path
in PYTHONPATH that pointed to the target's built external modules.
For "normal" foreign architecture cross compiles, when loading compiled
external libraries, the target libraries were processed first due to
their precedence in sys.path. These libraries were then ruled out due to
a mismatch in the SOABI so the import mechanism continued searching
until it found the host's native modules.
However, if the host interpreter and the target python were on the same
version + SOABI combination, the host interpreter would attempt to load
the target's external modules due to their precedence in sys.path.
Despite the "match", the target build may have been linked against a
different libc or may include unsupported instructions so loading or
executing the target's external modules can lead to crashes.
Now, the path to the target's external modules is no longer defined in
PYTHONPATH to prevent accidentally loading these foreign modules.
One caveat is that during certain build stages, the target's sysconfig
module requires higher precedence than the host's version in order to
accurately query the target build's configuration.
This worked previously due to the target's sysconfig data module having
precedence over the host's (see above). In order to keep this desired
behavior, a new environment variable, _PYTHON_SYSCONFIGDATA_PATH, has
been defined so sysconfig can search this directory for the target's
sysconfig data.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Upstream-issue: https://github.com/python/cpython/issues/115382
Upstream: https://github.com/python/cpython/pull/116294
---
Lib/sysconfig.py | 15 ++++++++++++++-
Lib/test/libregrtest/main.py | 1 +
Lib/test/pythoninfo.py | 1 +
Tools/scripts/run_tests.py | 1 +
configure | 2 +-
configure.ac | 2 +-
6 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 122d441bd1..260aec3127 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -533,7 +533,20 @@ def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# _sysconfigdata is generated at build time, see _generate_posix_vars()
name = _get_sysconfigdata_name()
- _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
+
+ # For cross builds, the path to the target's sysconfigdata must be specified
+ # so it can be imported. It cannot be in PYTHONPATH, as foreign modules in
+ # sys.path can cause crashes when loaded by the host interpreter.
+ # Rely on truthiness as a valueless env variable is still an empty string.
+ # See OS X note in _generate_posix_vars re _sysconfigdata.
+ if (path := os.environ.get('_PYTHON_SYSCONFIGDATA_PATH')):
+ from importlib.machinery import FileFinder, SourceFileLoader, SOURCE_SUFFIXES
+ from importlib.util import module_from_spec
+ spec = FileFinder(path, (SourceFileLoader, SOURCE_SUFFIXES)).find_spec(name)
+ _temp = module_from_spec(spec)
+ spec.loader.exec_module(_temp)
+ else:
+ _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
build_time_vars = _temp.build_time_vars
vars.update(build_time_vars)
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index e41646d2d1..f54e570728 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -576,6 +576,7 @@ def _add_cross_compile_opts(self, regrtest_opts):
'_PYTHON_PROJECT_BASE',
'_PYTHON_HOST_PLATFORM',
'_PYTHON_SYSCONFIGDATA_NAME',
+ "_PYTHON_SYSCONFIGDATA_PATH",
'PYTHONPATH'
}
old_environ = os.environ
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 6efeaad812..d43e52c9e4 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -326,6 +326,7 @@ def format_groups(groups):
"_PYTHON_HOST_PLATFORM",
"_PYTHON_PROJECT_BASE",
"_PYTHON_SYSCONFIGDATA_NAME",
+ "_PYTHON_SYSCONFIGDATA_PATH",
"__PYVENV_LAUNCHER__",
# Sanitizer options
diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
index 445a34ae3e..4077a83424 100644
--- a/Tools/scripts/run_tests.py
+++ b/Tools/scripts/run_tests.py
@@ -42,6 +42,7 @@ def main(regrtest_args):
'_PYTHON_PROJECT_BASE',
'_PYTHON_HOST_PLATFORM',
'_PYTHON_SYSCONFIGDATA_NAME',
+ "_PYTHON_SYSCONFIGDATA_PATH",
'PYTHONPATH'
}
environ = {
diff --git a/configure b/configure
index 6dc8a66e48..a69346db8c 100755
--- a/configure
+++ b/configure
@@ -3689,7 +3689,7 @@ fi
fi
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
PYTHON_FOR_FREEZE="$with_build_python"
- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5
printf "%s\n" "$with_build_python" >&6; }
diff --git a/configure.ac b/configure.ac
index 1cb95f41fd..de420dde2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,7 +169,7 @@ AC_ARG_WITH([build-python],
dnl Build Python interpreter is used for regeneration and freezing.
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
PYTHON_FOR_FREEZE="$with_build_python"
- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python
AC_MSG_RESULT([$with_build_python])
], [
AS_VAR_IF([cross_compiling], [yes],
--
2.34.1
+131
View File
@@ -0,0 +1,131 @@
comment "python3 needs a toolchain w/ wchar, threads, dynamic library"
depends on BR2_USE_MMU
depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
config BR2_PACKAGE_PYTHON3
bool "python3"
depends on BR2_USE_WCHAR
# uses fork()
depends on BR2_USE_MMU
depends on BR2_TOOLCHAIN_HAS_THREADS # libffi
depends on !BR2_STATIC_LIBS
select BR2_PACKAGE_LIBFFI
select BR2_PACKAGE_BLUEZ5_UTILS_HEADERS if BR2_PACKAGE_BLUEZ5_UTILS
help
The python language interpreter.
http://www.python.org/
if BR2_PACKAGE_PYTHON3
choice
prompt "python3 module format to install"
default BR2_PACKAGE_PYTHON3_PYC_ONLY
help
Select Python module format to install on target (py, pyc or
both)
config BR2_PACKAGE_PYTHON3_PY_ONLY
bool ".py sources only"
config BR2_PACKAGE_PYTHON3_PYC_ONLY
bool ".pyc compiled sources only"
config BR2_PACKAGE_PYTHON3_PY_PYC
bool ".py sources and .pyc compiled"
endchoice
menu "core python3 modules"
comment "The following modules are unusual or require extra libraries"
config BR2_PACKAGE_PYTHON3_2TO3
bool "2to3 module"
help
code translation from python 2 to 3
config BR2_PACKAGE_PYTHON3_BERKELEYDB
bool "berkeleydb"
select BR2_PACKAGE_BERKELEYDB
select BR2_PACKAGE_BERKELEYDB_DBM
help
berkeleydb module for Python3
config BR2_PACKAGE_PYTHON3_BZIP2
bool "bz2 module"
select BR2_PACKAGE_BZIP2
help
bzip2 module for Python3
config BR2_PACKAGE_PYTHON3_CODECSCJK
bool "codecscjk module"
help
Chinese/Japanese/Korean codecs module for Python (large).
config BR2_PACKAGE_PYTHON3_CURSES
bool "curses module"
select BR2_PACKAGE_NCURSES
help
curses module for Python3.
config BR2_PACKAGE_PYTHON3_DECIMAL
bool "decimal module"
select BR2_PACKAGE_MPDECIMAL
help
decimal module for Python3.
config BR2_PACKAGE_PYTHON3_OSSAUDIODEV
bool "ossaudiodev module"
help
ossaudiodev module for Python3.
config BR2_PACKAGE_PYTHON3_READLINE
bool "readline"
select BR2_PACKAGE_READLINE
help
readline module for Python3 (required for command-line
editing in the Python shell).
config BR2_PACKAGE_PYTHON3_SSL
bool "ssl"
select BR2_PACKAGE_OPENSSL
select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
select BR2_PACKAGE_LIBOPENSSL_ENABLE_BLAKE2
help
_ssl module for Python3 (required for https in urllib etc).
config BR2_PACKAGE_PYTHON3_UNICODEDATA
bool "unicodedata module"
default y
help
Unicode character database (used by stringprep module)
(large).
config BR2_PACKAGE_PYTHON3_SQLITE
bool "sqlite module"
select BR2_PACKAGE_SQLITE
help
SQLite database support
config BR2_PACKAGE_PYTHON3_PYEXPAT
bool "xml module"
select BR2_PACKAGE_EXPAT
help
pyexpat and xml libraries for Python3.
config BR2_PACKAGE_PYTHON3_XZ
bool "xz module"
select BR2_PACKAGE_XZ
help
xz (a.k.a lzma) module for Python3
config BR2_PACKAGE_PYTHON3_ZLIB
bool "zlib module"
select BR2_PACKAGE_ZLIB
help
zlib support in Python3
endmenu
endif
+31
View File
@@ -0,0 +1,31 @@
config BR2_PACKAGE_HOST_PYTHON3
bool "host python3"
help
The python language interpreter. Host package.
http://www.python.org/
if BR2_PACKAGE_HOST_PYTHON3
config BR2_PACKAGE_HOST_PYTHON3_BZIP2
bool "bzip2"
help
bz2 module for host Python3.
config BR2_PACKAGE_HOST_PYTHON3_XZ
bool "xz"
help
xz (a.k.a lzma) module for host Python3
config BR2_PACKAGE_HOST_PYTHON3_CURSES
bool "curses"
help
curses module for host Python3.
config BR2_PACKAGE_HOST_PYTHON3_SSL
bool "ssl"
select BR2_PACKAGE_HOST_OPENSSL
help
_ssl module for host Python3.
endif
+5
View File
@@ -0,0 +1,5 @@
# From https://www.python.org/downloads/release/python-3125/
md5 02c7d269e077f4034963bba6befdc715 Python-3.12.5.tar.xz
# Locally computed
sha256 fa8a2e12c5e620b09f53e65bcd87550d2e5a1e2e04bf8ba991dcc55113876397 Python-3.12.5.tar.xz
sha256 3b2f81fe21d181c499c59a256c8e1968455d6689d269aa85373bfb6af41da3bf LICENSE
+307
View File
@@ -0,0 +1,307 @@
################################################################################
#
# python3
#
################################################################################
PYTHON3_VERSION_MAJOR = 3.12
PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).5
PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.xz
PYTHON3_SITE = https://python.org/ftp/python/$(PYTHON3_VERSION)
PYTHON3_LICENSE = Python-2.0, others
PYTHON3_LICENSE_FILES = LICENSE
PYTHON3_CPE_ID_VENDOR = python
PYTHON3_CPE_ID_PRODUCT = python
# This host Python is installed in $(HOST_DIR), as it is needed when
# cross-compiling third-party Python modules.
HOST_PYTHON3_CONF_OPTS += \
--without-ensurepip \
--without-cxx-main \
--disable-sqlite3 \
--disable-tk \
--with-expat=system \
--disable-test-modules \
--disable-idle3
# Make sure that LD_LIBRARY_PATH overrides -rpath.
# This is needed because libpython may be installed at the same time that
# python is called.
# TODO: nis and ossaudiodev modules will be dropped in 3.13: https://peps.python.org/pep-0594/
HOST_PYTHON3_CONF_ENV += \
LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags" \
py_cv_module_unicodedata=yes \
py_cv_module__codecs_cn=n/a \
py_cv_module__codecs_hk=n/a \
py_cv_module__codecs_iso2022=n/a \
py_cv_module__codecs_jp=n/a \
py_cv_module__codecs_kr=n/a \
py_cv_module__codecs_tw=n/a \
py_cv_module__uuid=n/a \
py_cv_module_nis=n/a \
py_cv_module_ossaudiodev=n/a
PYTHON3_DEPENDENCIES = host-python3 libffi
HOST_PYTHON3_DEPENDENCIES = \
host-autoconf-archive \
host-expat \
host-libffi \
host-pkgconf \
host-zlib
ifeq ($(BR2_PACKAGE_HOST_PYTHON3_BZIP2),y)
HOST_PYTHON3_DEPENDENCIES += host-bzip2
else
HOST_PYTHON3_CONF_ENV += py_cv_module__bz2=n/a
endif
ifeq ($(BR2_PACKAGE_HOST_PYTHON3_XZ),y)
HOST_PYTHON3_DEPENDENCIES += host-xz
else
HOST_PYTHON3_CONF_ENV += py_cv_module__lzma=n/a
endif
ifeq ($(BR2_PACKAGE_HOST_PYTHON3_CURSES),y)
HOST_PYTHON3_DEPENDENCIES += host-ncurses
else
HOST_PYTHON3_CONF_OPTS += --disable-curses
endif
ifeq ($(BR2_PACKAGE_HOST_PYTHON3_SSL),y)
HOST_PYTHON3_DEPENDENCIES += host-openssl
else
HOST_PYTHON3_CONF_ENV += \
py_cv_module__hashlib=n/a \
py_cv_module__ssl=n/a
endif
PYTHON3_INSTALL_STAGING = YES
ifeq ($(BR2_PACKAGE_PYTHON3_2TO3),y)
PYTHON3_CONF_OPTS += --enable-lib2to3
else
PYTHON3_CONF_OPTS += --disable-lib2to3
endif
ifeq ($(BR2_PACKAGE_PYTHON3_BERKELEYDB),y)
PYTHON3_DEPENDENCIES += berkeleydb
else
PYTHON3_CONF_ENV += py_cv_module__dbm=n/a
endif
ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
PYTHON3_CONF_OPTS += --with-readline
PYTHON3_DEPENDENCIES += readline
else
PYTHON3_CONF_OPTS += --without-readline
endif
ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
PYTHON3_DEPENDENCIES += ncurses
else
PYTHON3_CONF_OPTS += --disable-curses
endif
ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL),y)
PYTHON3_DEPENDENCIES += mpdecimal
PYTHON3_CONF_OPTS += --with-system-libmpdec
else
PYTHON3_CONF_ENV += py_cv_module__decimal=n/a
endif
ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
PYTHON3_DEPENDENCIES += expat
PYTHON3_CONF_OPTS += --with-expat=system
else
PYTHON3_CONF_OPTS += --with-expat=none
endif
ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
PYTHON3_DEPENDENCIES += sqlite
else
PYTHON3_CONF_OPTS += --disable-sqlite3
endif
ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
PYTHON3_DEPENDENCIES += openssl
PYTHON3_CONF_OPTS += --with-openssl=$(STAGING_DIR)/usr
else
PYTHON3_CONF_ENV += \
py_cv_module__hashlib=n/a \
py_cv_module__ssl=n/a
endif
ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK),y)
PYTHON3_CONF_ENV += \
py_cv_module__codecs_cn=n/a \
py_cv_module__codecs_hk=n/a \
py_cv_module__codecs_iso2022=n/a \
py_cv_module__codecs_jp=n/a \
py_cv_module__codecs_kr=n/a \
py_cv_module__codecs_tw=n/a
endif
ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
PYTHON3_CONF_ENV += py_cv_module_unicodedata=n/a
endif
# Disable auto-detection of uuid.h (util-linux)
# which would add _uuid module support, instead
# default to the pure python implementation
PYTHON3_CONF_ENV += py_cv_module__uuid=n/a
ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
PYTHON3_DEPENDENCIES += bzip2
else
PYTHON3_CONF_ENV += py_cv_module__bz2=n/a
endif
ifeq ($(BR2_PACKAGE_PYTHON3_XZ),y)
PYTHON3_DEPENDENCIES += xz
else
PYTHON3_CONF_ENV += py_cv_module__lzma=n/a
endif
ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
PYTHON3_DEPENDENCIES += zlib
else
PYTHON3_CONF_ENV += py_cv_module_zlib=n/a
endif
ifneq ($(BR2_PACKAGE_PYTHON3_OSSAUDIODEV),y)
PYTHON3_CONF_ENV += py_cv_module_ossaudiodev=n/a
endif
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 \
py_cv_module_nis=n/a
# GCC is always compliant with IEEE754
ifeq ($(BR2_ENDIAN),"LITTLE")
PYTHON3_CONF_ENV += ac_cv_little_endian_double=yes
else
PYTHON3_CONF_ENV += ac_cv_big_endian_double=yes
endif
ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y)
PYTHON3_DEPENDENCIES += gettext
endif
PYTHON3_CONF_OPTS += \
--without-ensurepip \
--without-cxx-main \
--with-build-python=$(HOST_DIR)/bin/python3 \
--with-system-ffi \
--disable-pydoc \
--disable-test-modules \
--disable-tk \
--disable-idle3 \
--disable-pyc-build
#
# Remove useless files. In the config/ directory, only the Makefile
# and the pyconfig.h files are needed at runtime.
#
define PYTHON3_REMOVE_USELESS_FILES
rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
rm -f $(TARGET_DIR)/usr/bin/python3-config
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)*/ \
-depth -type f -not -name Makefile -exec rm -rf {} \;
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ -depth -type d \
-name __pycache__ -exec rm -rf {} \;
endef
PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
#
# Make sure libpython gets stripped out on target
#
define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
endef
PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
PYTHON3_AUTORECONF = YES
PYTHON3_AUTORECONF_OPTS = --include=$(HOST_DIR)/share/autoconf-archive
define PYTHON3_INSTALL_SYMLINK
ln -fs python3 $(TARGET_DIR)/usr/bin/python
endef
PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
define HOST_PYTHON3_INSTALL_SYMLINK
ln -fs python3 $(HOST_DIR)/bin/python
ln -fs python3-config $(HOST_DIR)/bin/python-config
endef
HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK
# Provided to other packages
PYTHON3_PATH = $(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/
# Support for socket.AF_BLUETOOTH
ifeq ($(BR2_PACKAGE_BLUEZ5_UTILS_HEADERS),y)
PYTHON3_DEPENDENCIES += bluez5_utils-headers
endif
$(eval $(autotools-package))
$(eval $(host-autotools-package))
ifeq ($(BR2_REPRODUCIBLE),y)
define PYTHON3_FIX_TIME
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | \
xargs -0 --no-run-if-empty touch -d @$(SOURCE_DATE_EPOCH)
endef
endif
define PYTHON3_CREATE_PYC_FILES
$(PYTHON3_FIX_TIME)
PYTHONPATH="$(PYTHON3_PATH)" \
$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) \
$(PYTHON3_DIR)/Lib/compileall.py \
$(if $(VERBOSE),,-q) \
$(if $(BR2_PACKAGE_PYTHON3_PYC_ONLY),-b) \
-s $(TARGET_DIR) \
-p / \
$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)
endef
ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PY_PYC),y)
PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
endif
ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
define PYTHON3_REMOVE_PY_FILES
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' \
$(if $(strip $(KEEP_PYTHON_PY_FILES)),-not \( $(call finddirclauses,$(TARGET_DIR),$(KEEP_PYTHON_PY_FILES)) \) ) \
-print0 | \
xargs -0 --no-run-if-empty rm -f
endef
PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
endif
# Normally, *.pyc files should not have been compiled, but just in
# case, we make sure we remove all of them.
ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
define PYTHON3_REMOVE_PYC_FILES
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | \
xargs -0 --no-run-if-empty rm -f
endef
PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
endif
# In all cases, we don't want to keep the optimized .opt-1.pyc and
# .opt-2.pyc files, since they can't work without their non-optimized
# variant.
define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.opt-1.pyc' -print0 -o -name '*.opt-2.pyc' -print0 | \
xargs -0 --no-run-if-empty rm -f
endef
PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES