fix: propagate Tcl library path across Tk-created interpreters#958
Merged
jjhelmus merged 1 commit intoastral-sh:mainfrom Feb 17, 2026
Merged
Conversation
Contributor
|
After looking into |
Contributor
Author
|
To be honest, I didn't realize this was still in draft haha. Yeah, it's ready :) Thanks for taking a look! |
Set `TCL_LIBRARY` around `Tcl_AppInit` so all Tk-created interps can find the packaged Tcl/Tk.
ba1a4df to
42a50d8
Compare
jjhelmus
approved these changes
Feb 17, 2026
Contributor
|
LGTM. Thanks for the fix @shaanmajid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #939
Problem
tkinter fails with "Can't find a usable init.tcl" on macOS when both:
sys.prefix != sys.base_prefix(e.g., when using venv, uvx, uv run --isolated)Root cause
On macOS Aqua, when stdin is non-TTY, Tk's init path
(Tk_CreateConsoleWindow->TkpInit) creates a secondary Tcl interpreter. The existing patch setstcl_libraryon the main interpreter, but this secondary interpreter doesn't inherit it and falls back to compiled-in search paths that don't exist in a relocated/venv context.Fix
Temporarily set the
TCL_LIBRARYenvironment variable around theTcl_AppInitcall inTkapp_New. The env var is visible to all interpreters Tk creates internally during init, then unset immediately after to avoid environment pollution. Alsoextends
_get_tcl_lib_path()to compute the Tcl library path on Unix (previously Windows-only).Patches updated for Python 3.10–3.14.