Skip to content

Commit

Permalink
Merge pull request pyinstaller#1176 from pjrobertson/develop
Browse files Browse the repository at this point in the history
Handle ActiveTcl installs on OS X. Fixes pyinstaller#621
  • Loading branch information
htgoebel committed Feb 2, 2015
2 parents 4b60c46 + 06cccc0 commit 67610f2
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion PyInstaller/hooks/hook-_tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,58 @@ def _handle_broken_tk():
v['TIX_LIBRARY'] = abs_path


def _warn_if_actvivetcl_or_teapot_install(tcl_root, tcltree):
"""
Workaround ActiveTcl on OS X
PyInstaller does not package all requirements of ActiveTcl
(most notably teapot, which is not typically required). This
means packages built against ActiveTcl usually won't run on
non-host systems.
This method checks if ActiveTcl is being used, and if so logs
a warning if the problematic code is not commented out.
https://github.com/pyinstaller/pyinstaller/issues/621
"""

from PyInstaller.lib.macholib import util
if util.in_system_path(tcl_root):
# system libraries do not experience this problem
return

# get the path to the 'init.tcl' script
try:
init_resource = [r[1] for r in tcltree if r[1].endswith('init.tcl')][0]
except IndexError:
# couldn't find the init script, return
return

mentions_activetcl = False
mentions_teapot = False
with open(init_resource, 'r') as init_file:
for line in init_file.readlines():
line = line.strip().lower()
if line.startswith('#'):
continue
if 'activetcl' in line:
mentions_activetcl = True
if 'teapot' in line:
mentions_teapot = True
if mentions_activetcl and mentions_teapot:
break

if mentions_activetcl and mentions_teapot:
logger.warning("""It seems you are using an ActiveTcl build of Tcl/Tk.\
This may not package correctly with PyInstaller.
To fix the problem, please try commenting out all mentions of 'teapot' in:
%s
See https://github.com/pyinstaller/pyinstaller/issues/621 for more information"""
% init_resource)


def _find_tk_darwin_frameworks(binaries):
"""
Tcl and Tk are installed as Mac OS X Frameworks.
Expand Down Expand Up @@ -137,6 +189,11 @@ def _collect_tkfiles(mod):

tcltree = Tree(tcl_root, os.path.join('_MEI', tcldir),
excludes=['demos', '*.lib', 'tclConfig.sh'])

if is_darwin:
# handle workaround for ActiveTcl on OS X
_warn_if_actvivetcl_or_teapot_install(tcl_root, tcltree)

tktree = Tree(tk_root, os.path.join('_MEI', tkdir),
excludes=['demos', '*.lib', 'tkConfig.sh'])
return (tcltree + tktree)
Expand All @@ -146,7 +203,7 @@ def hook(mod):
# If not supported platform, skip TCL/TK detection.
if not (is_win or is_darwin or is_unix):
logger.info("... skipping TCL/TK detection on this platform (%s)",
sys.platform)
sys.platform)
return mod

# Get the Tcl/Tk data files for bundling with executable.
Expand Down

0 comments on commit 67610f2

Please sign in to comment.