git: 922e7f41450b - main - lang/python: restore USES=python variables and SUB_LIST (no-op)

From: Charlie Li <vishwin_at_FreeBSD.org>
Date: Tue, 28 Feb 2023 00:00:45 UTC
The branch main has been updated by vishwin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=922e7f41450be113e7301c672c8ed3eb352cc8df

commit 922e7f41450be113e7301c672c8ed3eb352cc8df
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2023-02-27 23:56:41 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2023-02-27 23:59:30 +0000

    lang/python: restore USES=python variables and SUB_LIST (no-op)
    
    Has been a to do item for time. These are independent from but used
    by the bytecode trigger.
---
 Mk/Uses/python.mk       | 25 ++++++++++++++++++++-----
 lang/python310/Makefile |  9 ++-------
 lang/python311/Makefile |  9 ++-------
 lang/python37/Makefile  |  8 ++------
 lang/python38/Makefile  |  8 ++------
 lang/python39/Makefile  |  9 ++-------
 6 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/Mk/Uses/python.mk b/Mk/Uses/python.mk
index e8b9d2b59343..2da705f42be1 100644
--- a/Mk/Uses/python.mk
+++ b/Mk/Uses/python.mk
@@ -257,17 +257,20 @@
 #			  packages for different Python versions.
 #			  default: -py${PYTHON_SUFFIX}
 #
-# Using USES=python also will add some useful entries to PLIST_SUB:
+# Using USES=python also will add some useful entries to SUB_LIST and PLIST_SUB:
 #
-#	PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;}
-#	PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
+#	PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR}
+#	PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR}
 #	PYTHON_PLATFORM=${PYTHON_PLATFORM}
-#	PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
+#	PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR}
 #	PYTHON_SUFFIX=${PYTHON_SUFFIX}
 #	PYTHON_VER=${PYTHON_VER}
 #	PYTHON_VERSION=${PYTHON_VERSION}
 #
-# and PYTHON2 and PYTHON3 will be set according to the Python version:
+# where PYTHON_INCLUDEDIR, PYTHON_LIBDIR and PYTHON_SITELIBDIR have their PREFIX
+# stripped for PLIST_SUB.
+#
+# PYTHON2 and PYTHON3 will also be set according to the Python version:
 #
 #	PYTHON2="" PYTHON3="@comment " for Python 2.x
 #	PYTHON2="@comment " PYTHON3="" for Python 3.x
@@ -785,6 +788,16 @@ ${_stage}_DEPENDS+=	${PYTHON_CMD}:${PYTHON_PORTSDIR}
 PREFIX=		${PYTHONBASE}
 .  endif
 
+# Substitutions for SUB_FILES
+SUB_LIST+=	PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR} \
+		PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR} \
+		PYTHON_PLATFORM=${PYTHON_PLATFORM} \
+		PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR} \
+		PYTHON_SUFFIX=${PYTHON_SUFFIX} \
+		PYTHON_EXT_SUFFIX=${PYTHON_EXT_SUFFIX} \
+		PYTHON_VER=${PYTHON_VER} \
+		PYTHON_VERSION=${PYTHON_VERSION}
+
 # Substitutions for pkg-plist
 # Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the
 # base directory in the plist file.
@@ -797,8 +810,10 @@ PLIST_SUB+=	PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} \
 		PYTHON_VER=${PYTHON_VER} \
 		PYTHON_VERSION=${PYTHON_VERSION}
 .  if ${PYTHON_REL} < 30000
+SUB_LIST+=	PYTHON2="" PYTHON3="@comment "
 PLIST_SUB+=	PYTHON2="" PYTHON3="@comment "
 .  else
+SUB_LIST+=	PYTHON2="@comment " PYTHON3=""
 PLIST_SUB+=	PYTHON2="@comment " PYTHON3=""
 .  endif
 
diff --git a/lang/python310/Makefile b/lang/python310/Makefile
index f3c13fc09ffd..14f3cc6bce3f 100644
--- a/lang/python310/Makefile
+++ b/lang/python310/Makefile
@@ -15,8 +15,8 @@ LICENSE=	PSFL
 
 LIB_DEPENDS=	libffi.so:devel/libffi
 
-USES=		compiler:c11 cpe ncurses pathfix pkgconfig readline \
-		shebangfix ssl tar:xz
+USES=		compiler:c11 cpe ncurses pathfix pkgconfig \
+		python:${PYTHON_DISTVERSION:R},env readline shebangfix ssl tar:xz
 PATHFIX_MAKEFILEIN=	Makefile.pre.in
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
@@ -26,11 +26,6 @@ SHEBANG_FILES+=	Lib/test/ziptestdata/exe_with_z64 \
 		Lib/test/ziptestdata/exe_with_zip \
 		Lib/test/ziptestdata/header.sh
 
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER=		${PYTHON_DISTVERSION:R}
-PYTHON_VERSION=		python${PYTHON_VER}
-PYTHON_SUFFIX=		${PYTHON_VER:S/.//g}
-
 DISABLED_EXTENSIONS=	_sqlite3 _tkinter _gdbm
 CONFIGURE_ARGS+=	--enable-shared --without-ensurepip \
 			--with-system-ffi
diff --git a/lang/python311/Makefile b/lang/python311/Makefile
index 96c4215f8b0e..b3eecab8010f 100644
--- a/lang/python311/Makefile
+++ b/lang/python311/Makefile
@@ -15,8 +15,8 @@ LICENSE=	PSFL
 
 LIB_DEPENDS=	libffi.so:devel/libffi
 
-USES=		compiler:c11 cpe ncurses pathfix pkgconfig readline \
-		shebangfix ssl tar:xz
+USES=		compiler:c11 cpe ncurses pathfix pkgconfig \
+		python:${PYTHON_DISTVERSION:R},env readline shebangfix ssl tar:xz
 PATHFIX_MAKEFILEIN=	Makefile.pre.in
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
@@ -26,11 +26,6 @@ SHEBANG_FILES+=	Lib/test/ziptestdata/exe_with_z64 \
 		Lib/test/ziptestdata/exe_with_zip \
 		Lib/test/ziptestdata/header.sh
 
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER=		${PYTHON_DISTVERSION:R}
-PYTHON_VERSION=		python${PYTHON_VER}
-PYTHON_SUFFIX=		${PYTHON_VER:S/.//g}
-
 DISABLED_EXTENSIONS=	_sqlite3 _tkinter _gdbm
 CONFIGURE_ARGS+=	--enable-shared --without-ensurepip \
 			--with-system-ffi
diff --git a/lang/python37/Makefile b/lang/python37/Makefile
index ec98e226f309..97ba530004e6 100644
--- a/lang/python37/Makefile
+++ b/lang/python37/Makefile
@@ -19,18 +19,14 @@ EXPIRATION_DATE=	2023-06-27
 LIB_DEPENDS=	libffi.so:devel/libffi \
 		libmpdec.so:math/mpdecimal
 
-USES=		cpe ncurses pathfix pkgconfig readline shebangfix ssl tar:xz
+USES=		cpe ncurses pathfix pkgconfig python:${PYTHON_DISTVERSION:R},env readline \
+		shebangfix ssl tar:xz
 PATHFIX_MAKEFILEIN=	Makefile.pre.in
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
 python_CMD=	${PREFIX}/bin/python${PYTHON_DISTVERSION:R}
 SHEBANG_FILES=	Lib/*.py Lib/*/*.py Lib/*/*/*.py Lib/*/*/*/*.py
 
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER=		${PYTHON_DISTVERSION:R}
-PYTHON_VERSION=		python${PYTHON_VER}
-PYTHON_SUFFIX=		${PYTHON_VER:S/.//g}
-
 DISABLED_EXTENSIONS=	_sqlite3 _tkinter _gdbm
 CONFIGURE_ARGS+=	--enable-shared --with-system-ffi --with-system-libmpdec --without-ensurepip
 CONFIGURE_ENV+=		OPT="" # Null out OPT to respect user CFLAGS and remove optimizations
diff --git a/lang/python38/Makefile b/lang/python38/Makefile
index 07d227c23956..1bb042d79d77 100644
--- a/lang/python38/Makefile
+++ b/lang/python38/Makefile
@@ -15,7 +15,8 @@ LICENSE=	PSFL
 
 LIB_DEPENDS=	libffi.so:devel/libffi
 
-USES=		cpe ncurses pathfix pkgconfig readline shebangfix ssl tar:xz
+USES=		cpe ncurses pathfix pkgconfig python:${PYTHON_DISTVERSION:R},env readline \
+		shebangfix ssl tar:xz
 PATHFIX_MAKEFILEIN=	Makefile.pre.in
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
@@ -25,11 +26,6 @@ SHEBANG_FILES+=	Lib/test/ziptestdata/exe_with_z64 \
 		Lib/test/ziptestdata/exe_with_zip \
 		Lib/test/ziptestdata/header.sh
 
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER=		${PYTHON_DISTVERSION:R}
-PYTHON_VERSION=		python${PYTHON_VER}
-PYTHON_SUFFIX=		${PYTHON_VER:S/.//g}
-
 DISABLED_EXTENSIONS=	_sqlite3 _tkinter _gdbm
 CONFIGURE_ARGS+=	--enable-shared --without-ensurepip \
 			--with-system-ffi
diff --git a/lang/python39/Makefile b/lang/python39/Makefile
index c93a47e69fc3..858e90eed6bb 100644
--- a/lang/python39/Makefile
+++ b/lang/python39/Makefile
@@ -15,8 +15,8 @@ LICENSE=	PSFL
 
 LIB_DEPENDS=	libffi.so:devel/libffi
 
-USES=		compiler:c11 cpe ncurses pathfix pkgconfig readline \
-		shebangfix ssl tar:xz
+USES=		compiler:c11 cpe ncurses pathfix pkgconfig \
+		python:${PYTHON_DISTVERSION:R},env readline shebangfix ssl tar:xz
 PATHFIX_MAKEFILEIN=	Makefile.pre.in
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
@@ -26,11 +26,6 @@ SHEBANG_FILES+=	Lib/test/ziptestdata/exe_with_z64 \
 		Lib/test/ziptestdata/exe_with_zip \
 		Lib/test/ziptestdata/header.sh
 
-# Duplicate python.mk variables. TODO: Let lang/python?? ports use python.mk bits.
-PYTHON_VER=		${PYTHON_DISTVERSION:R}
-PYTHON_VERSION=		python${PYTHON_VER}
-PYTHON_SUFFIX=		${PYTHON_VER:S/.//g}
-
 DISABLED_EXTENSIONS=	_sqlite3 _tkinter _gdbm
 CONFIGURE_ARGS+=	--enable-shared --without-ensurepip \
 			--with-system-ffi