Fix loading plugins when program is frozen

1.3
IceArmy 2011-06-21 10:44:55 -07:00
parent d3910f1efe
commit 8064c294b3
1 changed files with 7 additions and 1 deletions

View File

@ -18,6 +18,7 @@
'''
import os
import sys
from glob import glob
from collections import defaultdict
@ -109,8 +110,13 @@ def load_plugins():
have my_plugin.py inside the folder called.
'''
# path is different when frozen
if hasattr(sys, 'frozen'):
path = os.path.dirname(os.path.abspath(sys.executable))
else:
path = os.path.dirname(os.path.abspath(__file__))
# get plugin list
plugin_list = glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'plugins/*/*.py'))
plugin_list = glob(os.path.join(path, 'plugins/*/*.py'))
# now convert list to [('plugin_folder', 'file'), ...]
plugin_list = [(os.path.split(os.path.dirname(f))[1], os.path.splitext(os.path.split(f)[1])[0]) for f in plugin_list]