1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-18 16:03:12 +03:00

setup.py: darwin OPTIONS & misc formatting

This commit is contained in:
Athanasius 2020-10-08 12:28:10 +01:00
parent bc5f805b5a
commit b417745e7e

View File

@ -16,6 +16,7 @@ import sys
from distutils.core import setup from distutils.core import setup
from os.path import exists, isdir, join from os.path import exists, isdir, join
from tempfile import gettempdir from tempfile import gettempdir
from typing import Set
import semantic_version import semantic_version
@ -23,12 +24,12 @@ from config import appcmdname, applongname, appname, appversion, copyright, upda
if sys.platform == 'win32': if sys.platform == 'win32':
assert platform.architecture()[0] == '32bit', 'Assumes a Python built for 32bit' assert platform.architecture()[0] == '32bit', 'Assumes a Python built for 32bit'
import py2exe import py2exe # noqa: F401 # Yes, this *is* used
dist_dir = 'dist.win32' dist_dir = 'dist.win32'
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
dist_dir = 'dist.macosx' dist_dir = 'dist.macosx'
else: else:
assert False, 'Unsupported platform %s' % sys.platform assert False, f'Unsupported platform {sys.platform}'
# Split version, as py2exe wants the 'base' for version # Split version, as py2exe wants the 'base' for version
semver = semantic_version.Version.coerce(appversion) semver = semantic_version.Version.coerce(appversion)
@ -47,28 +48,54 @@ SDKPATH = r'C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86'
# OSX paths # OSX paths
SPARKLE = '/Library/Frameworks/Sparkle.framework' SPARKLE = '/Library/Frameworks/Sparkle.framework'
# Patch py2app recipe enumerator to skip the sip recipe since it's too enthusiastic - we'll list additional Qt modules explicitly
if sys.platform == 'darwin': if sys.platform == 'darwin':
from py2app import recipes # Patch py2app recipe enumerator to skip the sip recipe since it's too
# enthusiastic - we'll list additional Qt modules explicitly
import py2app.build_app import py2app.build_app
def iterRecipes(module=recipes): from py2app import recipes
def iter_recipes(module=recipes):
"""Enumerate recipes via alternate method."""
for name in dir(module): for name in dir(module):
if name.startswith('_') or name == 'sip': if name.startswith('_') or name == 'sip':
continue continue
check = getattr(getattr(module, name), 'check', None) check = getattr(getattr(module, name), 'check', None)
if check is not None: if check is not None:
yield (name, check) yield (name, check)
py2app.build_app.iterRecipes = iterRecipes
py2app.build_app.iterRecipes = iter_recipes
APP = 'EDMarketConnector.py' APP = 'EDMarketConnector.py'
APPCMD = 'EDMC.py' APPCMD = 'EDMC.py'
SHORTappversion = ''.join(appversion.split('.')[:3]) SHORTappversion = ''.join(appversion.split('.')[:3])
PLUGINS = [ 'plugins/coriolis.py', 'plugins/eddb.py', 'plugins/eddn.py', 'plugins/edsm.py', 'plugins/edsy.py', 'plugins/inara.py' ] PLUGINS = [
'plugins/coriolis.py',
'plugins/eddb.py',
'plugins/eddn.py',
'plugins/edsm.py',
'plugins/edsy.py',
'plugins/inara.py',
]
if sys.platform == 'darwin': if sys.platform == 'darwin':
OPTIONS = { 'py2app': def get_cfbundle_localizations() -> Set:
{'dist_dir': dist_dir, """
Build a set of the localisation files.
See https://github.com/sparkle-project/Sparkle/issues/238
"""
return sorted(
(
[x[:-len('.lproj')] for x in os.listdir(join(SPARKLE, 'Resources')) if x.endswith('.lproj')]
) | (
[x[:-len('.strings')] for x in os.listdir('L10n') if x.endswith('.strings')]
)
)
OPTIONS = {
'py2app': {
'dist_dir': dist_dir,
'optimize': 2, 'optimize': 2,
'packages': [ 'packages': [
'requests', 'requests',
@ -78,23 +105,45 @@ if sys.platform=='darwin':
'shutil', # Included for plugins 'shutil', # Included for plugins
'zipfile', # Included for plugins 'zipfile', # Included for plugins
], ],
'frameworks': [ 'Sparkle.framework' ], 'frameworks': [
'excludes': [ 'distutils', '_markerlib', 'PIL', 'pkg_resources', 'simplejson', 'unittest' ], 'Sparkle.framework'
'iconfile': '%s.icns' % appname, ],
'include_plugins': [('plugins', x) for x in PLUGINS], 'excludes': [
'resources': [ 'commodity.csv', 'rare_commodity.csv', 'snd_good.wav', 'snd_bad.wav', 'modules.p', 'ships.p', 'stations.p', 'systems.p'], 'distutils',
'_markerlib',
'PIL',
'pkg_resources',
'simplejson',
'unittest'
],
'iconfile': f'{appname}.icns',
'include_plugins': [
('plugins', x) for x in PLUGINS
],
'resources': [
'commodity.csv',
'rare_commodity.csv',
'snd_good.wav',
'snd_bad.wav',
'modules.p',
'ships.p',
'stations.p',
'systems.p'
],
'site_packages': False, 'site_packages': False,
'plist': { 'plist': {
'CFBundleName': applongname, 'CFBundleName': applongname,
'CFBundleIdentifier': 'uk.org.marginal.%s' % appname.lower(), 'CFBundleIdentifier': f'uk.org.marginal.{appname.lower()}',
'CFBundleLocalizations': sorted(set([x[:-len('.lproj')] for x in os.listdir(join(SPARKLE, 'Resources')) if x.endswith('.lproj')]) | set([x[:-len('.strings')] for x in os.listdir('L10n') if x.endswith('.strings')])), # https://github.com/sparkle-project/Sparkle/issues/238 'CFBundleLocalizations': get_cfbundle_localizations(),
'CFBundleShortVersionString': appversion, 'CFBundleShortVersionString': appversion,
'CFBundleVersion': appversion, 'CFBundleVersion': appversion,
'CFBundleURLTypes': [ 'CFBundleURLTypes': [
{ {
'CFBundleTypeRole': 'Viewer', 'CFBundleTypeRole': 'Viewer',
'CFBundleURLName': 'uk.org.marginal.%s.URLScheme' % appname.lower(), 'CFBundleURLName': f'uk.org.marginal.{appname.lower()}.URLScheme',
'CFBundleURLSchemes': ['edmc'], 'CFBundleURLSchemes': [
'edmc'
],
} }
], ],
'LSMinimumSystemVersion': '10.10', 'LSMinimumSystemVersion': '10.10',