1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Fix pyobjc imports, bump minimum Python version (#1698)

This commit is contained in:
Manu 2023-04-29 12:26:01 +01:00 committed by GitHub
parent 20b7b4936c
commit 4d65912d65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 33 deletions

View file

@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python 3.8 - name: Set up Python 3.11
uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # v4.3.1 uses: actions/setup-python@v4
with: with:
python-version: 3.8 python-version: 3.11
- name: Install Vorta - name: Install Vorta
run: | run: |
pip install . pip install .
@ -37,13 +37,13 @@ jobs:
fail-fast: false fail-fast: false
matrix: 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] os: [ubuntu-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # v4.3.1 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}

View file

@ -35,7 +35,7 @@ packages = find:
package_dir = package_dir =
=src =src
include_package_data = true include_package_data = true
python_requires = >=3.7 python_requires = >=3.8
install_requires = install_requires =
platformdirs >=3.0.0, <4.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0, 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. platformdirs >=2.6.0, <4.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently.
@ -44,9 +44,9 @@ install_requires =
psutil psutil
setuptools setuptools
secretstorage; sys_platform != 'darwin' secretstorage; sys_platform != 'darwin'
pyobjc-core < 9.1; sys_platform == 'darwin' pyobjc-core < 10; sys_platform == 'darwin'
pyobjc-framework-Cocoa < 9.1; sys_platform == 'darwin' pyobjc-framework-Cocoa < 10; sys_platform == 'darwin'
pyobjc-framework-LaunchServices < 9.1; sys_platform == 'darwin' pyobjc-framework-LaunchServices < 10; sys_platform == 'darwin'
tests_require = tests_require =
pytest pytest
pytest-qt pytest-qt

View file

@ -1,5 +1,25 @@
import sys 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 AUTOSTART_DELAY = """StartupNotify=false
X-GNOME-Autostart-enabled=true X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=20""" 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 while on Linux it adds a .desktop file at ~/.config/autostart
""" """
if sys.platform == 'darwin': if sys.platform == 'darwin':
from Cocoa import NSURL, NSBundle
from CoreFoundation import kCFAllocatorDefault
from Foundation import NSDictionary
# CF = CDLL(find_library('CoreFoundation')) url = NSURL.alloc().initFileURLWithPath_(APP_PATH)
from LaunchServices import (
LSSharedFileListCopySnapshot,
LSSharedFileListCreate,
LSSharedFileListInsertItemURL,
LSSharedFileListItemRemove,
LSSharedFileListItemResolve,
kLSSharedFileListItemHidden,
kLSSharedFileListItemLast,
kLSSharedFileListNoUserInteraction,
kLSSharedFileListSessionLoginItems,
)
app_path = NSBundle.mainBundle().bundlePath()
url = NSURL.alloc().initFileURLWithPath_(app_path)
login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None) login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)
props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden) props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden)

View file

@ -9,6 +9,9 @@
""" """
import logging import logging
import sys import sys
from ctypes import c_char
import objc
from Foundation import NSBundle
from .abc import VortaKeyring from .abc import VortaKeyring
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -23,8 +26,6 @@ def _set_keychain(self):
""" """
Lazy import to avoid conflict with pytest-xdist. Lazy import to avoid conflict with pytest-xdist.
""" """
import objc
from Foundation import NSBundle
Security = NSBundle.bundleWithIdentifier_('com.apple.security') Security = NSBundle.bundleWithIdentifier_('com.apple.security')
@ -121,7 +122,5 @@ def is_system(self):
def _resolve_password(password_length, password_buffer): def _resolve_password(password_length, password_buffer):
from ctypes import c_char
s = (c_char * password_length).from_address(password_buffer.__pointer__)[:] s = (c_char * password_length).from_address(password_buffer.__pointer__)[:]
return s.decode() return s.decode()

View file

@ -3,6 +3,11 @@
from PyQt6 import QtCore, QtDBus from PyQt6 import QtCore, QtDBus
from vorta.store.models import SettingsModel from vorta.store.models import SettingsModel
try:
from Foundation import NSUserNotification, NSUserNotificationCenter
except ImportError:
pass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -50,8 +55,6 @@ def deliver(self, title, text, level='info'):
if self.notifications_suppressed(level): if self.notifications_suppressed(level):
return return
from Foundation import NSUserNotification, NSUserNotificationCenter
notification = NSUserNotification.alloc().init() notification = NSUserNotification.alloc().init()
notification.setTitle_(title) notification.setTitle_(title)
notification.setInformativeText_(text) notification.setInformativeText_(text)