Skip to content

Commit

Permalink
hooks: correctly locate macOS python.org built-in tcl/tk (#5013)
Browse files Browse the repository at this point in the history
The python.org OS X python distributions installs a
built-in version tcl/tk in a path similar to the system
installation. This makes pyinstaller confused and
think the python.org built-in tcl/tk is the system installation.
This commit fixes the path to check to be more careful.
  • Loading branch information
ssantichaivekin committed Sep 28, 2020
1 parent bfc8b08 commit 9fe4367
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions PyInstaller/hooks/hook-_tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree):
""" % init_resource)


def _find_tcl_tk_darwin_frameworks(binaries):
def _find_tcl_tk_darwin_system_frameworks(binaries):
"""
Get an OS X-specific 2-tuple of the absolute paths of the top-level
external data directories for both Tcl and Tk, respectively.
Under OS X, Tcl and Tk are installed as Frameworks requiring special care.
This function finds the OS X system installation of Tcl and Tk.
System OS X Tcl and Tk are installed as Frameworks requiring special care.
Returns
-------
Expand Down Expand Up @@ -186,10 +187,15 @@ def _find_tcl_tk(hook_api):

# _tkinter depends on Tcl/Tk compiled as frameworks.
path_to_tcl = bins[0][1]
if 'Library/Frameworks' in path_to_tcl:
tcl_tk = _find_tcl_tk_darwin_frameworks(bins)
# OS X system installation of Tcl/Tk.
# [/System]/Library/Frameworks/Tcl.framework/Resources/Scripts/Tcl
if 'Library/Frameworks/Tcl.framework' in path_to_tcl:
tcl_tk = _find_tcl_tk_darwin_system_frameworks(bins)
# Tcl/Tk compiled as on Linux other Unixes.
# For example this is the case of Tcl/Tk from macports.
# This is the case of Tcl/Tk from macports and Tck/Tk built into
# python.org OS X python distributions.
# python.org built-in tcl/tk is located at
# /Library/Frameworks/Python.framework/Versions/3.x/lib/libtcl8.6.dylib
else:
tcl_tk = _find_tcl_tk_dir()

Expand Down
2 changes: 2 additions & 0 deletions news/5013.hooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(OSX) Correctly locate the tcl/tk framework bundled with official
python.org python builds from v.3.6.5 on.

0 comments on commit 9fe4367

Please sign in to comment.