commit 9d40fb2ea8b347e08b4b64897537e2197d4325e3
parent 16c72d286c119562a591dc06303dfeefa3ccfa01
Author: ThomasV <thomasv@gitorious>
Date: Mon, 26 Jan 2015 16:53:59 +0100
detect if we are in a pyinstaller bundle
Diffstat:
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/electrum b/electrum
@@ -27,7 +27,8 @@ import time
import traceback
-is_local = os.path.dirname(os.path.realpath(__file__)) == os.getcwd()
+is_bundle = getattr(sys, 'frozen', False)
+is_local = not is_bundle and os.path.dirname(os.path.realpath(__file__)) == os.getcwd()
is_android = 'ANDROID_DATA' in os.environ
if is_local:
@@ -66,7 +67,7 @@ except Exception:
# load local module as electrum
-if __builtin__.use_local_modules:
+if is_bundle or is_local or is_android:
import imp
imp.load_module('electrum', *imp.find_module('lib'))
imp.load_module('electrum_gui', *imp.find_module('gui'))
@@ -214,7 +215,7 @@ if __name__ == '__main__':
cmd = args[0]
if cmd == 'gui':
- init_plugins(config)
+ init_plugins(config, is_bundle or is_local or is_android)
gui_name = config.get('gui', 'classic')
if gui_name in ['lite', 'classic']:
gui_name = 'qt'
diff --git a/lib/plugins.py b/lib/plugins.py
@@ -6,11 +6,11 @@ from i18n import _
plugins = []
-def init_plugins(config):
+def init_plugins(config, local):
import imp, pkgutil, __builtin__, os
global plugins
- if __builtin__.use_local_modules:
+ if local:
fp, pathname, description = imp.find_module('plugins')
plugin_names = [name for a, name, b in pkgutil.iter_modules([pathname])]
plugin_names = filter( lambda name: os.path.exists(os.path.join(pathname,name+'.py')), plugin_names)
diff --git a/lib/util.py b/lib/util.py
@@ -66,7 +66,11 @@ def data_dir():
if __builtin__.use_local_modules:
return local_data_dir()
else:
- return appdata_dir()
+ if getattr(sys, 'frozen'):
+ basedir = sys._MEIPASS
+ return os.path.join(basedir, 'data')
+ else:
+ return appdata_dir()
def usr_share_dir():
return os.path.join(sys.prefix, "share")