Skip to content

Commit 131ed57

Browse files
committed
Try tkinter
1 parent 2a73fbd commit 131ed57

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed

build-macos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python3.12
22
# This Source Code Form is subject to the terms of the Mozilla Public
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

cpython-unix/build-cpython.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ fi
184184
# See https://bugs.python.org/issue37060.
185185
patch -p1 -i ${ROOT}/patch-ctypes-static-binary.patch
186186

187+
patch -p1 -i ${ROOT}/patch-tkinter.patch
188+
187189
# Older versions of Python need patching to work with modern mpdecimal.
188190
if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_9}" ]; then
189191
patch -p1 -i ${ROOT}/patch-decimal-modern-mpdecimal.patch

cpython-unix/build-main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def main():
6969
"cpython-3.12",
7070
"cpython-3.13",
7171
},
72-
default="cpython-3.11",
72+
default="cpython-3.13",
7373
help="Python distribution to build",
7474
)
7575
parser.add_argument(

cpython-unix/patch-tkinter.patch

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
2+
index bfec04bb6c1..6f3cfba6bbf 100644
3+
--- a/Lib/tkinter/__init__.py
4+
+++ b/Lib/tkinter/__init__.py
5+
@@ -54,6 +54,12 @@
6+
_magic_re = re.compile(r'([\\{}])')
7+
_space_re = re.compile(r'([\s])', re.ASCII)
8+
9+
+# Facilitate discovery of the Tcl/Tk libraries.
10+
+import os
11+
+
12+
+os.environ['TCL_LIBRARY'] = sys.base_prefix + '/tcl/tcl' + _tkinter.TCL_VERSION
13+
+os.environ['TK_LIBRARY'] = sys.base_prefix + '/tcl/tk' + _tkinter.TK_VERSION
14+
+
15+
16+
def _join(value):
17+
"""Internal function."""
18+
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
19+
index 45897817a56..03652c86c1b 100644
20+
--- a/Modules/_tkinter.c
21+
+++ b/Modules/_tkinter.c
22+
@@ -26,9 +26,8 @@ Copyright (C) 1994 Steen Lumholt.
23+
#endif
24+
25+
#include "Python.h"
26+
-#ifdef MS_WINDOWS
27+
-# include "pycore_fileutils.h" // _Py_stat()
28+
-#endif
29+
+
30+
+#include "pycore_fileutils.h" // _Py_stat()
31+
32+
#include "pycore_long.h" // _PyLong_IsNegative()
33+
34+
@@ -132,6 +131,7 @@ typedef int Tcl_Size;
35+
#ifdef MS_WINDOWS
36+
#include <conio.h>
37+
#define WAIT_FOR_STDIN
38+
+#endif
39+
40+
static PyObject *
41+
_get_tcl_lib_path(void)
42+
@@ -149,7 +149,7 @@ _get_tcl_lib_path(void)
43+
}
44+
45+
/* Check expected location for an installed Python first */
46+
- tcl_library_path = PyUnicode_FromString("\\tcl\\tcl" TCL_VERSION);
47+
+ tcl_library_path = PyUnicode_FromString("/tcl/tcl" TCL_VERSION);
48+
if (tcl_library_path == NULL) {
49+
return NULL;
50+
}
51+
@@ -167,7 +167,7 @@ _get_tcl_lib_path(void)
52+
errno = 0;
53+
#ifdef Py_TCLTK_DIR
54+
tcl_library_path = PyUnicode_FromString(
55+
- Py_TCLTK_DIR "\\lib\\tcl" TCL_VERSION);
56+
+ Py_TCLTK_DIR "/lib/tcl" TCL_VERSION);
57+
if (tcl_library_path == NULL) {
58+
return NULL;
59+
}
60+
@@ -189,7 +189,6 @@ _get_tcl_lib_path(void)
61+
}
62+
return tcl_library_path;
63+
}
64+
-#endif /* MS_WINDOWS */
65+
66+
/* The threading situation is complicated. Tcl is not thread-safe, except
67+
when configured with --enable-threads.
68+
@@ -702,7 +701,6 @@ Tkapp_New(const char *screenName, const char *className,
69+
PyMem_Free(args);
70+
}
71+
72+
-#ifdef MS_WINDOWS
73+
{
74+
PyObject *str_path;
75+
PyObject *utf8_path;
76+
@@ -727,7 +725,6 @@ Tkapp_New(const char *screenName, const char *className,
77+
}
78+
}
79+
}
80+
-#endif
81+
82+
if (Tcl_AppInit(v->interp) != TCL_OK) {
83+
PyObject *result = Tkinter_Error(v);
84+
@@ -3520,7 +3517,6 @@ PyInit__tkinter(void)
85+
if (uexe && PyUnicode_Check(uexe)) { // sys.executable can be None
86+
cexe = PyUnicode_EncodeFSDefault(uexe);
87+
if (cexe) {
88+
-#ifdef MS_WINDOWS
89+
int set_var = 0;
90+
PyObject *str_path;
91+
wchar_t *wcs_path;
92+
@@ -3551,9 +3547,6 @@ PyInit__tkinter(void)
93+
SetEnvironmentVariableW(L"TCL_LIBRARY", NULL);
94+
PyMem_Free(wcs_path);
95+
}
96+
-#else
97+
- Tcl_FindExecutable(PyBytes_AS_STRING(cexe));
98+
-#endif /* MS_WINDOWS */
99+
}
100+
Py_XDECREF(cexe);
101+
}

0 commit comments

Comments
 (0)