https://github.com/python/cpython/commit/df26596979fd5c4524f18ccb7e5f68dcf518fe7e
commit: df26596979fd5c4524f18ccb7e5f68dcf518fe7e
branch: 3.13
author: Malcolm Smith <[email protected]>
committer: freakboy3742 <[email protected]>
date: 2026-08-03T21:36:40+08:00
summary:

[3.13] GH-138800: Fix variable substitution in python3.pc for Android 
(GH-144776) (#155111)

Clarifies the difference between LIBPYTHON, which is the library name,
and the flags needed to build modules, which also need the linking path.
(cherry picked from commit 5918085bb6f4a3a48193cacb9bb99b044d4e0452)

Co-authored-by: Yaksh Bariya <[email protected]>
Co-authored-by: Ɓukasz Langa <[email protected]>

files:
A Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst
M Makefile.pre.in
M Modules/makesetup
M configure
M configure.ac

diff --git a/Makefile.pre.in b/Makefile.pre.in
index af810350709d59c..2363b99a25c266e 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -270,6 +270,7 @@ DIST=               $(DISTFILES) $(DISTDIRS)
 LIBRARY=       @LIBRARY@
 LDLIBRARY=      @LDLIBRARY@
 BLDLIBRARY=     @BLDLIBRARY@
+MODULE_LDFLAGS_SHARED=$(if $(LIBPYTHON),$(BLDLIBRARY))
 PY3LIBRARY=     @PY3LIBRARY@
 DLLLIBRARY=    @DLLLIBRARY@
 LDLIBRARYDIR=   @LDLIBRARYDIR@
diff --git 
a/Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst 
b/Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst
new file mode 100644
index 000000000000000..54b084d9d61277f
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-03-07-02-09-57.gh-issue-138800.VD8qbz.rst
@@ -0,0 +1 @@
+Fix library name in python3.pc on Android.
diff --git a/Modules/makesetup b/Modules/makesetup
index 8bb971b152a5225..b6ceafe3827c13d 100755
--- a/Modules/makesetup
+++ b/Modules/makesetup
@@ -274,7 +274,7 @@ sed -e 's/[         ]*#.*//' -e '/^[        ]*$/d' |
                                ;;
                        esac
                        rule="$file: $objs"
-                       rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o 
$file"
+                       rule="$rule; \$(BLDSHARED) $objs $libs 
\$(MODULE_LDFLAGS_SHARED) -o $file"
                        echo "$rule" >>$rulesf
                done
        done
diff --git a/configure b/configure
index d59f4c6a8577ff5..c42bffecdcfcdd8 100755
--- a/configure
+++ b/configure
@@ -24956,18 +24956,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
 printf "%s\n" "$LDVERSION" >&6; }
 
 # Configure the flags and dependencies used when compiling shared modules.
-# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
-# systems (e.g. Meson) to decide whether to link extension modules against
-# libpython.
 
 
 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
+
+# On most platforms, extension modules aren't linked against libpython, so
+# LIBPYTHON must be empty.
 LIBPYTHON=''
 
 # On Android and Cygwin the shared libraries must be linked with libpython.
+# LIBPYTHON is used by python-config, python3.pc, the commands for building the
+# stdlib's own extension modules, and external package build systems via
+# sysconfig, so its value must be suitable for all those contexts.
 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test 
"$MACHDEP" = "cygwin"); then
   MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
-  LIBPYTHON="\$(BLDLIBRARY)"
+  LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
 fi
 
 # On iOS the shared libraries must be linked with the Python framework
diff --git a/configure.ac b/configure.ac
index 634675109b1bdc4..047005fd7177b6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6335,18 +6335,21 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
 AC_MSG_RESULT([$LDVERSION])
 
 # Configure the flags and dependencies used when compiling shared modules.
-# Do not rename LIBPYTHON - it's accessed via sysconfig by package build
-# systems (e.g. Meson) to decide whether to link extension modules against
-# libpython.
 AC_SUBST([MODULE_DEPS_SHARED])
 AC_SUBST([LIBPYTHON])
 MODULE_DEPS_SHARED='$(MODULE_DEPS_STATIC) $(EXPORTSYMS)'
+
+# On most platforms, extension modules aren't linked against libpython, so
+# LIBPYTHON must be empty.
 LIBPYTHON=''
 
 # On Android and Cygwin the shared libraries must be linked with libpython.
+# LIBPYTHON is used by python-config, python3.pc, the commands for building the
+# stdlib's own extension modules, and external package build systems via
+# sysconfig, so its value must be suitable for all those contexts.
 if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test 
"$MACHDEP" = "cygwin"); then
   MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(LDLIBRARY)"
-  LIBPYTHON="\$(BLDLIBRARY)"
+  LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
 fi
 
 # On iOS the shared libraries must be linked with the Python framework

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to