diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 30dae527..2110d203 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +import sys from sys import platform import json from os import mkdir @@ -17,6 +18,12 @@ from ttkHyperlinkLabel import HyperlinkLabel if __debug__: from traceback import print_exc +from config import appname, applongname, config +if platform == 'win32' and getattr(sys, 'frozen', False): + # By default py2exe tries to write log to dirname(sys.executable) which fails when installed + import tempfile + sys.stderr = open(join(tempfile.gettempdir(), '%s.log' % appname), 'wt') + import l10n l10n.Translations().install() @@ -31,7 +38,6 @@ import flightlog import eddb import stats import prefs -from config import appname, applongname, config from hotkey import hotkeymgr from monitor import monitor diff --git a/py2exe.cmd b/py2exe.cmd new file mode 100755 index 00000000..0d01b7a7 --- /dev/null +++ b/py2exe.cmd @@ -0,0 +1,2 @@ +@REM http://www.py2exe.org/index.cgi/OptimizedBytecode +"C:\Program Files (x86)\Python27\python.exe" -OO setup.py py2exe diff --git a/setup.py b/setup.py index 0025eef7..ab63e28d 100755 --- a/setup.py +++ b/setup.py @@ -114,7 +114,7 @@ setup( version = VERSION, app = [APP], windows = [ {'dest_base': APPNAME, - 'script': 'winlauncher.py', + 'script': APP, 'icon_resources': [(0, '%s.ico' % APPNAME)], 'copyright': u'© 2015 Jonathan Harris', 'name': APPNAME, # WinSparkle diff --git a/winlauncher.py b/winlauncher.py deleted file mode 100644 index d86fd0e8..00000000 --- a/winlauncher.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -# Launcher when running py2exe - -import sys -getattr(sys, 'frozen') # Only intended to be run under py2exe - -# By deault py2exe tries to write log to dirname(sys.executable) which fails when installed -from os.path import join -import tempfile -from config import appname -sys.stderr = open(join(tempfile.gettempdir(), '%s.log' % appname), 'wt') - -import Tkinter as tk -from EDMarketConnector import AppWindow - -# Run the app -root = tk.Tk() -app = AppWindow(root) -root.mainloop()