pyinstaller / vorta.spec: make platform independent (#122)

* pyinstaller / vorta.spec: make platform independent

- cwd must be the repo dir, __FILE__ is not available here
- the borg binary for the platform must be in bin/borg (no matter
  whether we build for Linux or macOS or ...)
- moved some settings to top of the file
- whitespace clean up

* fat binary: must not fork on linux either

also: refactor slightly
This commit is contained in:
TW 2019-01-13 03:03:00 +01:00 committed by Manuel Riel
parent c5494f455c
commit d2f618babf
3 changed files with 30 additions and 21 deletions

View File

@ -15,10 +15,9 @@ def main():
args = parse_args() args = parse_args()
frozen_binary = getattr(sys, 'frozen', False) frozen_binary = getattr(sys, 'frozen', False)
# Don't fork if user specifies it or when running from onedir app bundle on macOS. need_foreground = frozen_binary and sys.platform in ('darwin', 'linux')
if (hasattr(args, 'foreground') and args.foreground) or (frozen_binary and sys.platform == 'darwin'): want_foreground = getattr(args, 'foreground', False)
pass if not (want_foreground or need_foreground):
else:
print('Forking to background (see system tray).') print('Forking to background (see system tray).')
if os.fork(): if os.fork():
sys.exit() sys.exit()

View File

@ -1,27 +1,37 @@
# -*- mode: python -*- # -*- mode: python -*-
block_cipher = None import os
CREATE_VORTA_DIR = False # create dist/vorta-dir/ output?
BLOCK_CIPHER = None
# it is assumed that the cwd is the git repo dir:
REPO_DIR = os.path.abspath('.')
SRC_DIR = os.path.join(REPO_DIR, 'src')
a = Analysis(['src/vorta/__main__.py'], a = Analysis(['src/vorta/__main__.py'],
pathex=['/Users/manu/Workspace/vorta/src'], pathex=[SRC_DIR],
binaries=[ binaries=[
('bin/macosx64/borg', 'bin'), ('bin/borg', 'bin'), # (<borg fat binary for this platform>, <dest. folder>)
], ],
datas=[ datas=[
('src/vorta/assets/UI/*', 'assets/UI'), ('src/vorta/assets/UI/*', 'assets/UI'),
('src/vorta/assets/icons/*', 'assets/icons'), ('src/vorta/assets/icons/*', 'assets/icons'),
], ],
hiddenimports=['vorta.views.collection_rc', hiddenimports=[
'vorta.views.collection_rc',
], ],
hookspath=[], hookspath=[],
runtime_hooks=[], runtime_hooks=[],
excludes=[], excludes=[],
win_no_prefer_redirects=False, win_no_prefer_redirects=False,
win_private_assemblies=False, win_private_assemblies=False,
cipher=block_cipher, cipher=BLOCK_CIPHER,
noarchive=False) noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher) pyz = PYZ(a.pure, a.zipped_data, cipher=BLOCK_CIPHER)
exe = EXE(pyz, exe = EXE(pyz,
a.scripts, a.scripts,
a.binaries, a.binaries,
@ -34,22 +44,22 @@ exe = EXE(pyz,
strip=False, strip=False,
upx=True, upx=True,
runtime_tmpdir=None, runtime_tmpdir=None,
console=True ) console=True)
app = BUNDLE(exe, app = BUNDLE(exe,
name='Vorta.app', name='Vorta.app',
icon='src/vorta/assets/icons/app-icon.icns', icon='src/vorta/assets/icons/app-icon.icns',
bundle_identifier='com.borgbase.client.macos', bundle_identifier='com.borgbase.client.macos',
info_plist={ info_plist={
'NSHighResolutionCapable': 'True', 'NSHighResolutionCapable': 'True',
'LSUIElement': '1', 'LSUIElement': '1',
'CFBundleShortVersionString': '0.6.4', 'CFBundleShortVersionString': '0.6.4',
'CFBundleVersion': '0.6.4', 'CFBundleVersion': '0.6.4',
'NSAppleEventsUsageDescription': 'Please allow', 'NSAppleEventsUsageDescription': 'Please allow',
'SUFeedURL': 'https://borgbase.github.io/vorta/appcast.xml' 'SUFeedURL': 'https://borgbase.github.io/vorta/appcast.xml',
}, })
)
if False: if CREATE_VORTA_DIR:
coll = COLLECT(exe, coll = COLLECT(exe,
a.binaries, a.binaries,
a.zipfiles, a.zipfiles,