git: 62b50f7bd59a - main - x11-toolkits/py-tkinter: remove Python 2 support

From: Charlie Li <vishwin_at_FreeBSD.org>
Date: Mon, 10 Mar 2025 19:29:20 UTC
The branch main has been updated by vishwin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=62b50f7bd59a6da561894816e2ec0b3352b9208f

commit 62b50f7bd59a6da561894816e2ec0b3352b9208f
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2025-03-10 19:23:54 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2025-03-10 19:28:14 +0000

    x11-toolkits/py-tkinter: remove Python 2 support
    
    No remaining consumers in the tree after re-including _tkinter into
    lang/python27 itself. This is to prepare for conversion to
    USE_PYTHON=pep517, as none of such tooling works with Python 2.
    
    PR: 268283
---
 x11-toolkits/py-tkinter/Makefile        |  7 ++----
 x11-toolkits/py-tkinter/files/setup.py  |  9 ++++----
 x11-toolkits/py-tkinter/files/setup3.py | 40 ---------------------------------
 3 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/x11-toolkits/py-tkinter/Makefile b/x11-toolkits/py-tkinter/Makefile
index f3e2c18fd926..c1d4ad3ca163 100644
--- a/x11-toolkits/py-tkinter/Makefile
+++ b/x11-toolkits/py-tkinter/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	tkinter
 DISTVERSION=	${PYTHON_DISTVERSION}
-PORTREVISION=	8
+PORTREVISION=	9
 CATEGORIES=	x11-toolkits python
 MASTER_SITES=	PYTHON/ftp/python/${DISTVERSION}
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -13,7 +13,7 @@ LICENSE=	PSFL
 
 PORTSCOUT=	ignore:1
 
-USES=		compiler:c11 python:2.7+ tar:xz tk
+USES=		compiler:c11 python tar:xz tk
 USE_PYTHON=	distutils autoplist allflavors
 
 DIST_SUBDIR=	python
@@ -25,10 +25,7 @@ PYDISTUTILS_INSTALLARGS+=	--install-lib ${PYTHON_LIBDIR}/lib-dynload
 .include <bsd.port.pre.mk>
 
 post-extract:
-.if ${PYTHON_REL} < 30000
 	@${SED} -e "s|%%TK_VER%%|${TK_VER}|" ${FILESDIR}/setup.py > ${WRKSRC}/setup.py
-.else
-	@${SED} -e "s|%%TK_VER%%|${TK_VER}|" ${FILESDIR}/setup3.py > ${WRKSRC}/setup.py
 .endif
 
 post-install:
diff --git a/x11-toolkits/py-tkinter/files/setup.py b/x11-toolkits/py-tkinter/files/setup.py
index 99dd0d7fd1cf..bcf53d093857 100644
--- a/x11-toolkits/py-tkinter/files/setup.py
+++ b/x11-toolkits/py-tkinter/files/setup.py
@@ -11,10 +11,9 @@ try:
     from distutils.command.install import install
     from distutils.core import setup, Extension
 except:
-    raise SystemExit, "Distutils problem"
+    raise SystemExit("Distutils problem")
 
-install.sub_commands = filter(lambda (cmd, avl): 'egg' not in cmd,
-                              install.sub_commands)
+install.sub_commands = [x for x in install.sub_commands if 'egg' not in x[0]]
 
 tkversion = "%%TK_VER%%"
 prefix = sysconfig.PREFIX
@@ -26,8 +25,8 @@ inc_dirs = [prefix + "/include",
             x11base + "/include"]
 lib_dirs = [prefix + "/lib", x11base + "/lib"]
 # use string.replace() for the benefit of Python 1.5 users
-libs = ["tcl" + string.replace(tkversion, ".", ""),
-        "tk" + string.replace(tkversion, ".", ""),
+libs = ["tcl" + tkversion.replace(".", ""),
+        "tk" + tkversion.replace(".", ""),
         "X11"]
 
 setup(name = "Tkinter",
diff --git a/x11-toolkits/py-tkinter/files/setup3.py b/x11-toolkits/py-tkinter/files/setup3.py
deleted file mode 100644
index bcf53d093857..000000000000
--- a/x11-toolkits/py-tkinter/files/setup3.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-# To use:
-#       python setup.py install
-#
-
-import os, string
-
-try:
-    import distutils
-    from distutils import sysconfig
-    from distutils.command.install import install
-    from distutils.core import setup, Extension
-except:
-    raise SystemExit("Distutils problem")
-
-install.sub_commands = [x for x in install.sub_commands if 'egg' not in x[0]]
-
-tkversion = "%%TK_VER%%"
-prefix = sysconfig.PREFIX
-# Python 1.5 doesn't have os.getenv()?
-x11base = os.environ['LOCALBASE'] or '/usr/X11R6'
-inc_dirs = [prefix + "/include",
-            prefix + "/include/tcl" + tkversion,
-            prefix + "/include/tk" + tkversion,
-            x11base + "/include"]
-lib_dirs = [prefix + "/lib", x11base + "/lib"]
-# use string.replace() for the benefit of Python 1.5 users
-libs = ["tcl" + tkversion.replace(".", ""),
-        "tk" + tkversion.replace(".", ""),
-        "X11"]
-
-setup(name = "Tkinter",
-      description = "Tk Extension to Python",
-
-      ext_modules = [Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
-                               define_macros=[('WITH_APPINIT', 1)],
-                               include_dirs = inc_dirs,
-                               libraries = libs,
-                               library_dirs = lib_dirs)]
-      )