1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Put plugins and strings in their own folders in packaged app

Load plugins with name 'plugin_*' in order to not pollute the global namespace.

Addresses #230
This commit is contained in:
Jonathan Harris 2017-08-16 14:36:12 +01:00
parent 5e5ac2db31
commit b206015eef
5 changed files with 73 additions and 65 deletions

View File

@ -120,12 +120,6 @@
<Component Guid="{62DF41B7-0BE8-48F3-BB22-90E9201A6D8C}">
<File KeyPath="yes" Source="SourceDir\cacert.pem" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\cs.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\de.strings" />
</Component>
<Component Guid="{6762E871-5FA1-4C2F-A3C9-6A9954CC018C}">
<File KeyPath="yes" Source="SourceDir\EDMarketConnector.ico" />
</Component>
@ -135,60 +129,24 @@
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\EDMC.exe" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\eddb.py" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\edsm.py" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\es.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\fi.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\fr.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\it.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\ja.strings" />
</Component>
<Component Guid="{A18814B6-B491-42AB-A433-2AD66A823AD7}">
<File KeyPath="yes" Source="SourceDir\library.zip" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\lv.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\modules.p" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\nl.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\pl.strings" />
</Component>
<Component Guid="{87A99AAA-792F-4092-9D00-5106D99D00AD}">
<File KeyPath="yes" Source="SourceDir\pyexpat.pyd" />
</Component>
<Component Guid="{685773F2-78E4-4A16-BE0D-C7AB9575C856}">
<File KeyPath="yes" Source="SourceDir\python27.dll" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\ru.strings" />
</Component>
<Component Guid="{9DBAB544-E815-40A5-866A-391B68919344}">
<File KeyPath="yes" Source="SourceDir\select.pyd" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\ships.p" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\sr-Latn.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\snd_good.wav" />
</Component>
@ -207,9 +165,6 @@
<Component Guid="{CE5A6F3A-8F6B-4C16-BCDC-F1BB89C9F1AF}">
<File KeyPath="yes" Source="SourceDir\tk85.dll" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\uk.strings" />
</Component>
<Component Guid="{E8E3701A-8AA1-4D46-A56D-7AF08D6AFCD4}">
<File KeyPath="yes" Source="SourceDir\unicodedata.pyd" />
</Component>
@ -219,6 +174,55 @@
<Component Guid="{3117D2CF-1D87-4B99-BE44-7BDDFE8C8E60}">
<File KeyPath="yes" Source="SourceDir\WinSparkle.dll" />
</Component>
<Directory Id="L10n" Name="L10n">
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\cs.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\de.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\es.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\fi.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\fr.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\it.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\ja.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\lv.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\nl.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\pl.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\ru.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\sr-Latn.strings" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\L10n\uk.strings" />
</Component>
</Directory>
<Directory Id="plugins" Name="plugins">
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\plugins\eddb.py" />
</Component>
<Component Guid="*">
<File KeyPath="yes" Source="SourceDir\plugins\edsm.py" />
</Component>
</Directory>
<Directory Id="tcl" Name="tcl">
<Directory Id="tcl8.5" Name="tcl8.5">
<Component Guid="{C085794D-6644-4915-B1C3-3060BE9E3F3B}">

View File

@ -123,7 +123,7 @@ class Config:
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.internal_plugin_dir = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Resources')) or join(dirname(__file__), 'plugins')
self.internal_plugin_dir = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Library', 'plugins')) or join(dirname(__file__), 'plugins')
self.default_journal_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], 'Frontier Developments', 'Elite Dangerous')
@ -185,7 +185,7 @@ class Config:
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.internal_plugin_dir = getattr(sys, 'frozen', False) and dirname(sys.executable) or join(dirname(__file__), 'plugins')
self.internal_plugin_dir = join(dirname(getattr(sys, 'frozen', False) and sys.executable or __file__), 'plugins')
# expanduser in Python 2 on Windows doesn't handle non-ASCII - http://bugs.python.org/issue13207
self.home = KnownFolderPath(FOLDERID_Profile) or u'\\'

View File

@ -129,7 +129,7 @@ class Translations:
if platform=='darwin':
return normpath(join(dirname(sys.executable), os.pardir, 'Resources'))
else:
return dirname(sys.executable)
return join(dirname(sys.executable), 'L10n')
elif __file__:
return join(dirname(__file__), 'L10n')
else:

View File

@ -11,7 +11,7 @@ from traceback import print_exc
import Tkinter as tk
import myNotebook as nb
from config import config, appname
from config import config
# List of loaded Plugins
@ -41,7 +41,7 @@ class Plugin(object):
if loadfile:
sys.stdout.write('loading plugin %s from "%s"\n' % (name, loadfile.encode('utf-8')))
with open(loadfile, 'rb') as plugfile:
module = imp.load_module(name, plugfile, loadfile.encode(sys.getfilesystemencoding()),
module = imp.load_module('plugin_%s' % name, plugfile, loadfile.encode(sys.getfilesystemencoding()),
('.py', 'r', imp.PY_SOURCE))
newname = module.plugin_start()
self.name = newname and unicode(newname) or name
@ -112,7 +112,7 @@ def load_plugins(master):
internal = []
for name in os.listdir(config.internal_plugin_dir):
if name.endswith('.py') and not name[0] in ['.', '_'] and not name.startswith(appname):
if name.endswith('.py') and not name[0] in ['.', '_']:
try:
plugin = Plugin(name[:-3], os.path.join(config.internal_plugin_dir, name))
plugin.folder = None # Suppress listing in Plugins prefs tab

View File

@ -75,7 +75,7 @@ if sys.platform=='darwin':
'frameworks': [ 'Sparkle.framework' ],
'excludes': [ 'certifi', 'PIL', 'simplejson' ],
'iconfile': '%s.icns' % APPNAME,
'extra_scripts': PLUGINS,
'include_plugins': [('plugins', x) for x in PLUGINS],
'resources': ['snd_good.wav', 'snd_bad.wav', 'modules.p', 'ships.p', 'stations.p', 'systems.p'],
'semi_standalone': True,
'site_packages': False,
@ -108,19 +108,23 @@ elif sys.platform=='win32':
}
import requests
DATA_FILES = [ ('', [requests.certs.where(),
'WinSparkle.dll',
'WinSparkle.pdb', # For debugging - don't include in package
'snd_good.wav',
'snd_bad.wav',
'modules.p',
'ships.p',
'stations.p',
'systems.p',
'%s.VisualElementsManifest.xml' % APPNAME,
'%s.ico' % APPNAME ] +
PLUGINS +
[join('L10n',x) for x in os.listdir('L10n') if x.endswith('.strings')] ) ]
DATA_FILES = [
('', [
requests.certs.where(),
'WinSparkle.dll',
'WinSparkle.pdb', # For debugging - don't include in package
'snd_good.wav',
'snd_bad.wav',
'modules.p',
'ships.p',
'stations.p',
'systems.p',
'%s.VisualElementsManifest.xml' % APPNAME,
'%s.ico' % APPNAME
]),
('L10n', [join('L10n',x) for x in os.listdir('L10n') if x.endswith('.strings')]),
('plugins', PLUGINS),
]
setup(
name = APPLONGNAME,