Package macOS app as DMG. Add Sparkle Framework.

This commit is contained in:
Manu 2018-11-21 16:17:27 +08:00
parent 18226e4bcf
commit 7fe2ab2f01
7 changed files with 46 additions and 60 deletions

View File

@ -1,58 +0,0 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.1-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "setup.cfg" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -U setuptools pip
pip install .
pip install -r requirements-dev.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "setup.cfg" }}
# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
# https://nose.readthedocs.io
- run:
name: run tests
command: |
. venv/bin/activate
pytest
- store_artifacts:
path: test-reports
destination: test-reports

3
.gitignore vendored
View File

@ -4,7 +4,8 @@ build/
dist/
docs/
*.autosave
bin/
bin/macosx64/Sparkle.framework
bin/macosx64/borg
__pycache__
Makefile
.eggs

17
appdmg.json Normal file
View File

@ -0,0 +1,17 @@
{
"title": "Vorta Backups",
"contents": [
{ "x": 448, "y": 144, "type": "link", "path": "/Applications" },
{ "x": 162, "y": 144, "type": "file", "path": "dist/Vorta.app" }
],
"format": "ULFO",
"code-sign": {
"signing-identity": "Developer ID Application: Manuel Riel (CNMSCAXT48)"
},
"window": {
"size": {
"height": 300,
"width": 600
}
}
}

0
bin/macosx64/.gitkeep Normal file
View File

View File

@ -5,6 +5,7 @@ import peewee
import vorta.models
from vorta.application import VortaApp
from vorta.config import SETTINGS_DIR
import vorta.updater
from vorta._version import __version__
@ -20,6 +21,7 @@ def main():
vorta.models.init_db(sqlite_db)
app = VortaApp(sys.argv)
app.updater = vorta.updater.get_updater()
sys.exit(app.exec_())

22
src/vorta/updater.py Normal file
View File

@ -0,0 +1,22 @@
import sys
import os
def get_updater():
if sys.platform == 'darwin' and getattr(sys, 'frozen', False):
"""
Use sparkle framework on macOS.
Examples: https://programtalk.com/python-examples/objc.loadBundle/
"""
from objc import loadBundle
bundle_path = os.path.join(os.path.dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework')
loadBundle('Sparkle', globals(), bundle_path)
sparkle = SUUpdater.sharedUpdater()
sparkle.setAutomaticallyChecksForUpdates_(True)
sparkle.setAutomaticallyDownloadsUpdates_(False)
sparkle.checkForUpdatesInBackground()
return sparkle
else: # TODO: implement for Linux
return None

View File

@ -5,7 +5,7 @@ block_cipher = None
a = Analysis(['src/vorta/__main__.py'],
pathex=['/Users/manu/Workspace/vorta/src'],
binaries=[
('bin/macosx64/borg', 'bin')
('bin/macosx64/borg', 'bin'),
],
datas=[
('src/vorta/assets/UI/*', 'assets/UI'),
@ -43,7 +43,9 @@ app = BUNDLE(exe,
'NSHighResolutionCapable': 'True',
'LSUIElement': '1',
'CFBundleShortVersionString': '0.4.1',
'CFBundleVersion': '0.4.1',
'NSAppleEventsUsageDescription': 'Please allow',
'SUFeedURL': 'https://borgbase.github.io/vorta/appcast-pre.xml'
},
)
if False: