1#----------------------------------------------------------------------------- 2# Copyright (c) 2005-2019, PyInstaller Development Team. 3# 4# Distributed under the terms of the GNU General Public License with exception 5# for distributing bootloader. 6# 7# The full license is in the file COPYING.txt, distributed with this software. 8#----------------------------------------------------------------------------- 9 10 11# Ensure environment variables TCL_LIBRARY and TK_LIBRARY are set properly. 12# and data files are bundled. 13 14 15import glob 16import os 17 18 19# In Python 3 module name is 'tkinter' 20try: 21 from tkinter import * 22except ImportError: 23 from Tkinter import * 24 25 26def compare(test_name, expect, frozen): 27 expect = os.path.normpath(expect) 28 print(test_name) 29 print((' Expected: ' + expect)) 30 print((' Current: ' + frozen)) 31 print('') 32 # Path must match. 33 if not frozen == expect: 34 raise SystemExit('Data directory is not set properly.') 35 # Directory must exist. 36 if not os.path.exists(frozen): 37 raise SystemExit('Data directory does not exist.') 38 # Directory must contain some .tcl files and not to be empty. 39 if not len(glob.glob(frozen + '/*.tcl')) > 0: 40 raise SystemExit('Data directory does not contain .tcl files.') 41 42 43tcl_dir = os.environ['TCL_LIBRARY'] 44tk_dir = os.environ['TK_LIBRARY'] 45 46 47compare('Tcl', os.path.join(sys.prefix, 'tcl'), tcl_dir) 48compare('Tk', os.path.join(sys.prefix, 'tk'), tk_dir) 49