diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53c5bd9a..ac5a0dd9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # v4.3.1 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.11 - name: Install Vorta run: | pip install . @@ -37,13 +37,13 @@ jobs: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11'] os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # v4.3.1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/setup.cfg b/setup.cfg index c2c92037..76187557 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ packages = find: package_dir = =src include_package_data = true -python_requires = >=3.7 +python_requires = >=3.8 install_requires = platformdirs >=3.0.0, <4.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0, platformdirs >=2.6.0, <4.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently. @@ -44,9 +44,9 @@ install_requires = psutil setuptools secretstorage; sys_platform != 'darwin' - pyobjc-core < 9.1; sys_platform == 'darwin' - pyobjc-framework-Cocoa < 9.1; sys_platform == 'darwin' - pyobjc-framework-LaunchServices < 9.1; sys_platform == 'darwin' + pyobjc-core < 10; sys_platform == 'darwin' + pyobjc-framework-Cocoa < 10; sys_platform == 'darwin' + pyobjc-framework-LaunchServices < 10; sys_platform == 'darwin' tests_require = pytest pytest-qt diff --git a/src/vorta/autostart.py b/src/vorta/autostart.py index bd1c2273..6e0f5d92 100644 --- a/src/vorta/autostart.py +++ b/src/vorta/autostart.py @@ -1,5 +1,25 @@ import sys +try: + from Cocoa import NSURL, NSBundle + from CoreFoundation import kCFAllocatorDefault + from Foundation import NSDictionary + from LaunchServices import ( + LSSharedFileListCopySnapshot, + LSSharedFileListCreate, + LSSharedFileListInsertItemURL, + LSSharedFileListItemRemove, + LSSharedFileListItemResolve, + kLSSharedFileListItemHidden, + kLSSharedFileListItemLast, + kLSSharedFileListNoUserInteraction, + kLSSharedFileListSessionLoginItems, + ) + + APP_PATH = NSBundle.mainBundle().bundlePath() +except ImportError: + pass + AUTOSTART_DELAY = """StartupNotify=false X-GNOME-Autostart-enabled=true X-GNOME-Autostart-Delay=20""" @@ -11,25 +31,8 @@ def open_app_at_startup(enabled=True): while on Linux it adds a .desktop file at ~/.config/autostart """ if sys.platform == 'darwin': - from Cocoa import NSURL, NSBundle - from CoreFoundation import kCFAllocatorDefault - from Foundation import NSDictionary - # CF = CDLL(find_library('CoreFoundation')) - from LaunchServices import ( - LSSharedFileListCopySnapshot, - LSSharedFileListCreate, - LSSharedFileListInsertItemURL, - LSSharedFileListItemRemove, - LSSharedFileListItemResolve, - kLSSharedFileListItemHidden, - kLSSharedFileListItemLast, - kLSSharedFileListNoUserInteraction, - kLSSharedFileListSessionLoginItems, - ) - - app_path = NSBundle.mainBundle().bundlePath() - url = NSURL.alloc().initFileURLWithPath_(app_path) + url = NSURL.alloc().initFileURLWithPath_(APP_PATH) login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None) props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden) diff --git a/src/vorta/keyring/darwin.py b/src/vorta/keyring/darwin.py index d0f52a3c..91f93610 100644 --- a/src/vorta/keyring/darwin.py +++ b/src/vorta/keyring/darwin.py @@ -9,6 +9,9 @@ """ import logging import sys +from ctypes import c_char +import objc +from Foundation import NSBundle from .abc import VortaKeyring logger = logging.getLogger(__name__) @@ -23,8 +26,6 @@ def _set_keychain(self): """ Lazy import to avoid conflict with pytest-xdist. """ - import objc - from Foundation import NSBundle Security = NSBundle.bundleWithIdentifier_('com.apple.security') @@ -121,7 +122,5 @@ def is_system(self): def _resolve_password(password_length, password_buffer): - from ctypes import c_char - s = (c_char * password_length).from_address(password_buffer.__pointer__)[:] return s.decode() diff --git a/src/vorta/notifications.py b/src/vorta/notifications.py index 320f1e3e..8141951e 100644 --- a/src/vorta/notifications.py +++ b/src/vorta/notifications.py @@ -3,6 +3,11 @@ from PyQt6 import QtCore, QtDBus from vorta.store.models import SettingsModel +try: + from Foundation import NSUserNotification, NSUserNotificationCenter +except ImportError: + pass + logger = logging.getLogger(__name__) @@ -50,8 +55,6 @@ def deliver(self, title, text, level='info'): if self.notifications_suppressed(level): return - from Foundation import NSUserNotification, NSUserNotificationCenter - notification = NSUserNotification.alloc().init() notification.setTitle_(title) notification.setInformativeText_(text)