After discussion with maintainer, here's my patch to have TkInter work with Tk 8.6.TkInter's setup.py program searches for libs using patterns like libtkXX.a
and libtkXX.so, not taking into account OpenBSD's .so versioning.
Since static libs are only built for 8.5, setup.py will find libtk85.a
and configure for 8.5 but will not find libtk8.6.so and fail.
This should be fixed upstream, I guess.
Instead of patching setup.py for the desired Tk version,
simply pass the correct parameters in CONFIGURE_ARGS.
This way, it's easy to select 8.5 or 8.6, and there's
no need to "sync" the setup.py patch and the port Makefile.
I experienced weirdness trying to build TkInter 2.7 against Tk 8.6:
it seems the install script would relink against 8.5?
Anyway, it's probably best to keep TkInter 2.7 with Tk 8.5.
I'm not sure if my patch is completely ok (2.7 PLIST, style of Makefile changes). Does it make sense to put all the TkInter bits inside .if ${BUILD_PACKAGES:M-tkinter} ? Are the changes to CHANGES.OpenBSD ok/necessary?When built successfully, this or similar incantation should work: $ echo 'from tkinter import *; print(Tk().tk.eval("info patchlevel")); exit' | python3.10
8.6.12
I also noticed that Python 3.10 doesn't uninstall cleanly.
Stu
(patch also attached)

Index: Makefile.inc
===================================================================
RCS file: /cvs/ports/lang/python/Makefile.inc,v
retrieving revision 1.147
diff -u -p -u -p -r1.147 Makefile.inc
--- Makefile.inc        26 May 2022 15:13:55 -0000      1.147
+++ Makefile.inc        5 Jun 2022 13:11:38 -0000
@@ -8,7 +8,7 @@ COMMENT-bsddb = Berkeley db module for P
 COMMENT-gdbm = GNU dbm module for Python
 COMMENT-idle = IDE for Python
 COMMENT-tests =        Python test suite
-COMMENT-tkinter = tk GUI module for Python
+COMMENT-tkinter = Tk GUI module for Python
 COMMENT-tools =        extra tools for Python

 VERSION =      ${FULL_VERSION:R}
@@ -94,12 +94,9 @@ RUN_DEPENDS-idle =   lang/python/${VERSION
                        ${RUN_DEPENDS}
 WANTLIB-idle =

-MODULES +=             x11/tk
-# Tcl/Tk version needs to be in sync with patch-setup_py's one
-MODTK_VERSION =                8.5
 LIB_DEPENDS-tkinter =  lang/python/${VERSION},-main \
                        ${MODTK_LIB_DEPENDS}
-WANTLIB-tkinter =      X11 pthread python${VERSION} \
+WANTLIB-tkinter =      pthread python${VERSION} \
                        ${MODTK_WANTLIB}

 AUTOCONF_VERSION =     2.69
@@ -117,6 +114,19 @@ CONFIGURE_ARGS +=  --enable-loadable-sqli
 CONFIGURE_ARGS +=      --with-lto
 .  endif
 TEST_IS_INTERACTIVE =  Yes
+.endif
+
+.include <bsd.port.arch.mk>
+
+.if ${BUILD_PACKAGES:M-tkinter}
+MODULES +=             x11/tk
+CONFIGURE_ARGS += --with-tcltk-includes='-I${MODTCL_INCDIR} -I${MODTK_INCDIR} -I${X11BASE}/include' \
+                       --with-tcltk-libs='-L${X11BASE}/lib -l${MODTCL_LIB} 
-l${MODTK_LIB}'
+.  if ${VERSION} == "2.7"
+MODTK_VERSION =                8.5
+.  else
+MODTK_VERSION =                8.6
+.  endif
 .endif

CONFIGURE_ENV += OPT='${CFLAGS} -fPIC' CPPFLAGS='-I${LOCALBASE}/include' \
Index: 2.7/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/2.7/Makefile,v
retrieving revision 1.76
diff -u -p -u -p -r1.76 Makefile
--- 2.7/Makefile        28 Mar 2022 15:48:24 -0000      1.76
+++ 2.7/Makefile        5 Jun 2022 13:11:38 -0000
@@ -8,12 +8,12 @@ SHARED_LIBS =         python2.7 0.0
 VERSION_SPEC =         >=2.7,<2.8
 PORTROACH =            limit:^2\.7

-REVISION-main =                7
+REVISION-main =                8
 REVISION-idle =                1
 REVISION-tests =       1
 REVISION-bsddb =       0
 REVISION-gdbm =                0
-REVISION-tkinter =     0
+REVISION-tkinter =     1
 REVISION-tools =       0

 CONFIGURE_ARGS +=      --with-ensurepip=no
Index: 2.7/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/2.7/files/CHANGES.OpenBSD,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 CHANGES.OpenBSD
--- 2.7/files/CHANGES.OpenBSD   11 Mar 2022 19:29:11 -0000      1.7
+++ 2.7/files/CHANGES.OpenBSD   5 Jun 2022 13:11:38 -0000
@@ -7,5 +7,8 @@ of changes made to this version of Pytho

3. RAND_egd support has been disabled, as it is not available in LibreSSL.

+4.  Enable proper building of TkInter against Tcl/Tk 8.5;
+the TkInter configure script doesn't look for OpenBSD-style sonames.
+
 These changes are available in the OpenBSD CVS repository
 <http://www.openbsd.org/anoncvs.html> in ports/lang/python/2.7.
Index: 2.7/patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/lang/python/2.7/patches/patch-setup_py,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 patch-setup_py
--- 2.7/patches/patch-setup_py  11 Mar 2022 19:29:11 -0000      1.16
+++ 2.7/patches/patch-setup_py  5 Jun 2022 13:11:38 -0000
@@ -84,17 +84,7 @@ Index: setup.py
          frameworks = ['-framework', 'Tcl', '-framework', 'Tk']

# All existing framework builds of Tcl/Tk don't support 64-bit
-@@ -1936,8 +1946,7 @@ class PyBuildExt(build_ext):
- # The versions with dots are used on Unix, and the versions without
-         # dots on Windows, for detection by cygwin.
-         tcllib = tklib = tcl_includes = tk_includes = None
-- for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
--                        '8.2', '82', '8.1', '81', '8.0', '80']:
-+        for version in ['85']:
-             tklib = self.compiler.find_library_file(lib_dirs,
- 'tk' + version)
-             tcllib = self.compiler.find_library_file(lib_dirs,
-@@ -1980,17 +1989,9 @@ class PyBuildExt(build_ext):
+@@ -1980,17 +1990,9 @@ class PyBuildExt(build_ext):
          if host_platform == 'sunos5':
              include_dirs.append('/usr/openwin/include')
              added_lib_dirs.append('/usr/openwin/lib')
Index: 2.7/pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/lang/python/2.7/pkg/PLIST-main,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 PLIST-main
--- 2.7/pkg/PLIST-main  11 Mar 2022 19:29:11 -0000      1.30
+++ 2.7/pkg/PLIST-main  5 Jun 2022 13:11:38 -0000
@@ -1593,9 +1593,11 @@ lib/python2.7/lib-dynload/Python-${FULL_
 @so lib/python2.7/lib-dynload/crypt.so
 @so lib/python2.7/lib-dynload/datetime.so
 @so lib/python2.7/lib-dynload/dbm.so
+@so lib/python2.7/lib-dynload/dl.so
 @so lib/python2.7/lib-dynload/fcntl.so
 @so lib/python2.7/lib-dynload/future_builtins.so
 @so lib/python2.7/lib-dynload/grp.so
+@so lib/python2.7/lib-dynload/imageop.so
 @so lib/python2.7/lib-dynload/itertools.so
 @so lib/python2.7/lib-dynload/math.so
 @so lib/python2.7/lib-dynload/mmap.so
Index: 3.10/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.10/Makefile,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 Makefile
--- 3.10/Makefile       29 Apr 2022 03:34:57 -0000      1.10
+++ 3.10/Makefile       5 Jun 2022 13:11:38 -0000
@@ -8,6 +8,6 @@ SHARED_LIBS =           python3.10 0.0
 VERSION_SPEC =         >=3.10,<3.11
 PORTROACH =            limit:^3\.10

-REVISION =             1
+REVISION =             2

 .include <bsd.port.mk>
Index: 3.10/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/3.10/files/CHANGES.OpenBSD,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 CHANGES.OpenBSD
--- 3.10/files/CHANGES.OpenBSD  28 Apr 2022 14:47:56 -0000      1.4
+++ 3.10/files/CHANGES.OpenBSD  5 Jun 2022 13:11:38 -0000
@@ -23,5 +23,8 @@ in PY_CPPFLAGS/PY_LDFLAGS and thus leaki
 OpenBSD's version of llvm-ar is installed as /usr/bin/ar, and the
 compiler as passed to ports builds is /usr/bin/cc.

+7.  Enable proper building of TkInter against Tcl/Tk 8.5 or 8.6;
+the TkInter configure script doesn't look for OpenBSD-style sonames.
+
 These changes are available in the OpenBSD CVS repository
-<http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.9.
+<http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.10.
Index: 3.10/patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/lang/python/3.10/patches/patch-setup_py,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 patch-setup_py
--- 3.10/patches/patch-setup_py 3 Apr 2022 21:33:23 -0000       1.4
+++ 3.10/patches/patch-setup_py 5 Jun 2022 13:11:38 -0000
@@ -19,13 +19,3 @@ Index: setup.py
                  uuid_libs = ["uuid"]
              else:
                  uuid_libs = []
-@@ -2116,8 +2118,7 @@ class PyBuildExt(build_ext):
- # The versions with dots are used on Unix, and the versions without
-         # dots on Windows, for detection by cygwin.
-         tcllib = tklib = tcl_includes = tk_includes = None
-- for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
--                        '8.2', '82', '8.1', '81', '8.0', '80']:
-+        for version in ['85']:
-             tklib = self.compiler.find_library_file(self.lib_dirs,
- 'tk' + version)
-             tcllib = self.compiler.find_library_file(self.lib_dirs,
Index: 3.8/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.8/Makefile,v
retrieving revision 1.31
diff -u -p -u -p -r1.31 Makefile
--- 3.8/Makefile        28 Apr 2022 14:47:56 -0000      1.31
+++ 3.8/Makefile        5 Jun 2022 13:11:38 -0000
@@ -8,6 +8,6 @@ SHARED_LIBS =           python3.8 0.0
 VERSION_SPEC =         >=3.8,<3.9
 PORTROACH =            limit:^3\.8

-REVISION =             1
+REVISION =             2

 .include <bsd.port.mk>
Index: 3.8/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/3.8/files/CHANGES.OpenBSD,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 CHANGES.OpenBSD
--- 3.8/files/CHANGES.OpenBSD   28 Apr 2022 14:47:56 -0000      1.8
+++ 3.8/files/CHANGES.OpenBSD   5 Jun 2022 13:11:38 -0000
@@ -19,5 +19,8 @@ in PY_CPPFLAGS/PY_LDFLAGS and thus leaki
 OpenBSD's version of llvm-ar is installed as /usr/bin/ar, and the
 compiler as passed to ports builds is /usr/bin/cc.

+7.  Enable proper building of TkInter against Tcl/Tk 8.5 or 8.6;
+the TkInter configure script doesn't look for OpenBSD-style sonames.
+
 These changes are available in the OpenBSD CVS repository
 <http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.8.
Index: 3.8/patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/lang/python/3.8/patches/patch-setup_py,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 patch-setup_py
--- 3.8/patches/patch-setup_py  3 Apr 2022 21:30:12 -0000       1.5
+++ 3.8/patches/patch-setup_py  5 Jun 2022 13:11:38 -0000
@@ -19,13 +19,3 @@ Index: setup.py
                  uuid_libs = ['uuid']
              else:
                  uuid_libs = []
-@@ -1847,8 +1849,7 @@ class PyBuildExt(build_ext):
- # The versions with dots are used on Unix, and the versions without
-         # dots on Windows, for detection by cygwin.
-         tcllib = tklib = tcl_includes = tk_includes = None
-- for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
--                        '8.2', '82', '8.1', '81', '8.0', '80']:
-+        for version in ['85']:
-             tklib = self.compiler.find_library_file(self.lib_dirs,
- 'tk' + version)
-             tcllib = self.compiler.find_library_file(self.lib_dirs,
Index: 3.9/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.9/Makefile,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 Makefile
--- 3.9/Makefile        26 May 2022 16:28:19 -0000      1.24
+++ 3.9/Makefile        5 Jun 2022 13:11:38 -0000
@@ -8,6 +8,8 @@ SHARED_LIBS =           python3.9 0.0
 VERSION_SPEC =         >=3.9,<3.10
 PORTROACH =            limit:^3\.9

+REVISION =             0
+
 # This is the MODPY_DEFAULT_VERSION_3 version of Python:
 # - override "@comment" setting so that bin/python3 etc are installed
 PY_DEFAULTONLY =
Index: 3.9/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/3.9/files/CHANGES.OpenBSD,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 CHANGES.OpenBSD
--- 3.9/files/CHANGES.OpenBSD   28 Apr 2022 14:47:56 -0000      1.8
+++ 3.9/files/CHANGES.OpenBSD   5 Jun 2022 13:11:38 -0000
@@ -19,5 +19,8 @@ in PY_CPPFLAGS/PY_LDFLAGS and thus leaki
 OpenBSD's version of llvm-ar is installed as /usr/bin/ar, and the
 compiler as passed to ports builds is /usr/bin/cc.

+7.  Enable proper building of TkInter against Tcl/Tk 8.5 or 8.6;
+the TkInter configure script doesn't look for OpenBSD-style sonames.
+
 These changes are available in the OpenBSD CVS repository
 <http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.9.
Index: 3.9/patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/lang/python/3.9/patches/patch-setup_py,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 patch-setup_py
--- 3.9/patches/patch-setup_py  3 Apr 2022 21:32:06 -0000       1.7
+++ 3.9/patches/patch-setup_py  5 Jun 2022 13:11:38 -0000
@@ -19,13 +19,3 @@ Index: setup.py
                  uuid_libs = ["uuid"]
              else:
                  uuid_libs = []
-@@ -1997,8 +1999,7 @@ class PyBuildExt(build_ext):
- # The versions with dots are used on Unix, and the versions without
-         # dots on Windows, for detection by cygwin.
-         tcllib = tklib = tcl_includes = tk_includes = None
-- for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
--                        '8.2', '82', '8.1', '81', '8.0', '80']:
-+        for version in ['85']:
-             tklib = self.compiler.find_library_file(self.lib_dirs,
- 'tk' + version)
-             tcllib = self.compiler.find_library_file(self.lib_dirs,

Attachment: pytk.diff.gz
Description: application/gzip

Reply via email to