1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-21 23:33:13 +00:00

Remove pkg_resources use (#2098)

This commit is contained in:
Manu 2024-10-20 14:04:25 +01:00 committed by GitHub
parent 5dada30d9e
commit 0e8432602d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 31 deletions

View file

@ -30,7 +30,6 @@ a = Analysis([os.path.join(SRC_DIR, '__main__.py')],
'vorta.keyring.darwin', 'vorta.keyring.darwin',
'vorta.keyring.kwallet', 'vorta.keyring.kwallet',
'vorta.keyring.secretstorage', 'vorta.keyring.secretstorage',
'pkg_resources.py2_warn',
], ],
hookspath=[], hookspath=[],
runtime_hooks=[], runtime_hooks=[],

View file

@ -15,10 +15,7 @@ classifiers =
Operating System :: MacOS Operating System :: MacOS
Operating System :: POSIX Operating System :: POSIX
License :: OSI Approved :: GNU General Public License v3 (GPLv3) License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Programming Language :: Python :: 3.7 Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: System :: Archiving :: Backup Topic :: System :: Archiving :: Backup
Topic :: System :: Systems Administration Topic :: System :: Systems Administration
Topic :: Utilities Topic :: Utilities
@ -37,17 +34,18 @@ package_dir =
include_package_data = true include_package_data = true
python_requires = >=3.8 python_requires = >=3.8
install_requires = install_requires =
platformdirs >=3.0.0, <5.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0, packaging
platformdirs >=2.6.0, <5.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently.
pyqt6
peewee peewee
platformdirs >=2.6.0, <5.0.0; sys_platform != 'darwin' # for others: 2.6+ works consistently.
platformdirs >=3.0.0, <5.0.0; sys_platform == 'darwin' # for macOS: breaking changes in 3.0.0,
psutil psutil
setuptools
secretstorage; sys_platform != 'darwin'
pyobjc-core < 10; sys_platform == 'darwin' pyobjc-core < 10; sys_platform == 'darwin'
pyobjc-framework-Cocoa < 10; sys_platform == 'darwin' pyobjc-framework-Cocoa < 10; sys_platform == 'darwin'
pyobjc-framework-LaunchServices < 10; sys_platform == 'darwin'
pyobjc-framework-CoreWLAN < 10; sys_platform == 'darwin' pyobjc-framework-CoreWLAN < 10; sys_platform == 'darwin'
pyobjc-framework-LaunchServices < 10; sys_platform == 'darwin'
pyqt6
secretstorage; sys_platform != 'darwin'
setuptools
tests_require = tests_require =
pytest pytest
pytest-qt pytest-qt
@ -97,7 +95,7 @@ extension-pkg-whitelist=PyQt6
load-plugins= load-plugins=
[pylint.messages control] [pylint.messages control]
disable= W0503,W0511,C0301,R0903,R0201,W0212,C0114,C0115,C0116,C0103,E0611,E1120,C0415,R0914,R0912,R0915 disable= W0511,C0301,R0903,W0212,C0114,C0115,C0116,C0103,E0611,E1120,C0415,R0914,R0912,R0915
[pylint.format] [pylint.format]
max-line-length=120 max-line-length=120

View file

@ -1,13 +1,13 @@
from pkg_resources import parse_version from packaging.version import Version
MIN_BORG_FOR_FEATURE = { MIN_BORG_FOR_FEATURE = {
'BLAKE2': parse_version('1.1.4'), "BLAKE2": Version("1.1.4"),
'ZSTD': parse_version('1.1.4'), "ZSTD": Version("1.1.4"),
'JSON_LOG': parse_version('1.1.0'), "JSON_LOG": Version("1.1.0"),
'DIFF_JSON_LINES': parse_version('1.1.16'), "DIFF_JSON_LINES": Version("1.1.16"),
'COMPACT_SUBCOMMAND': parse_version('1.2.0a1'), "COMPACT_SUBCOMMAND": Version("1.2.0a1"),
'V122': parse_version('1.2.2'), "V122": Version("1.2.2"),
'V2': parse_version('2.0.0b10'), "V2": Version("2.0.0b10"),
# add new version-checks here. # add new version-checks here.
} }
@ -19,12 +19,12 @@ class BorgCompatibility:
to customize Borg commands by version in the future. to customize Borg commands by version in the future.
""" """
version = '1.1.0' version = "1.1.0"
path = '' path = ""
def set_version(self, version, path): def set_version(self, version, path):
self.version = version self.version = version
self.path = path self.path = path
def check(self, feature_name): def check(self, feature_name):
return parse_version(self.version) >= MIN_BORG_FOR_FEATURE[feature_name] return Version(self.version) >= MIN_BORG_FOR_FEATURE[feature_name]

View file

@ -2,8 +2,8 @@
import subprocess import subprocess
import pytest import pytest
from packaging.version import Version
from peewee import SqliteDatabase from peewee import SqliteDatabase
from pkg_resources import parse_version
import vorta import vorta
import vorta.application import vorta.application
@ -45,7 +45,7 @@ def borg_version():
# test window does not automatically set borg version # test window does not automatically set borg version
borg_compat.set_version(borg_version, borg_compat.path) borg_compat.set_version(borg_version, borg_compat.path)
parsed_borg_version = parse_version(borg_version) parsed_borg_version = Version(borg_version)
return borg_version, parsed_borg_version return borg_version, parsed_borg_version
@ -54,7 +54,7 @@ def create_test_repo(tmpdir_factory, borg_version):
repo_path = tmpdir_factory.mktemp('repo') repo_path = tmpdir_factory.mktemp('repo')
source_files_dir = tmpdir_factory.mktemp('borg_src') source_files_dir = tmpdir_factory.mktemp('borg_src')
is_borg_v2 = borg_version[1] >= parse_version('2.0.0b1') is_borg_v2 = borg_version[1] >= Version('2.0.0b1')
if is_borg_v2: if is_borg_v2:
subprocess.run(['borg', '-r', str(repo_path), 'rcreate', '--encryption=none'], check=True) subprocess.run(['borg', '-r', str(repo_path), 'rcreate', '--encryption=none'], check=True)
@ -225,7 +225,7 @@ def min_borg_version(borg_version, request):
if request.node.get_closest_marker('min_borg_version'): if request.node.get_closest_marker('min_borg_version'):
parsed_borg_version = borg_version[1] parsed_borg_version = borg_version[1]
if parsed_borg_version < parse_version(request.node.get_closest_marker('min_borg_version').args[0]): if parsed_borg_version < Version(request.node.get_closest_marker('min_borg_version').args[0]):
pytest.skip( pytest.skip(
'skipped due to borg version requirement for test: {}'.format( 'skipped due to borg version requirement for test: {}'.format(
request.node.get_closest_marker('min_borg_version').args[0] request.node.get_closest_marker('min_borg_version').args[0]

View file

@ -3,7 +3,7 @@
""" """
import pytest import pytest
from pkg_resources import parse_version from packaging.version import Version
import vorta.borg import vorta.borg
import vorta.utils import vorta.utils
@ -343,7 +343,7 @@ def test_archive_diff_lines(
): ):
"""Test that the diff lines are parsed correctly for supported borg versions""" """Test that the diff lines are parsed correctly for supported borg versions"""
parsed_borg_version = borg_version[1] parsed_borg_version = borg_version[1]
supports_fifo = parsed_borg_version > parse_version("1.1.18") supports_fifo = parsed_borg_version > Version("1.1.18")
supports_chrdev = create_test_repo[2] supports_chrdev = create_test_repo[2]
params = BorgDiffJob.prepare( params = BorgDiffJob.prepare(
@ -372,8 +372,8 @@ def test_archive_diff_lines(
item item
for item in expected for item in expected
if ( if (
("min_version" not in item or parse_version(item["min_version"]) <= parsed_borg_version) ("min_version" not in item or Version(item["min_version"]) <= parsed_borg_version)
and ("max_version" not in item or parse_version(item["max_version"]) >= parsed_borg_version) and ("max_version" not in item or Version(item["max_version"]) >= parsed_borg_version)
and (item["data"]["file_type"] != FileType.FIFO or supports_fifo) and (item["data"]["file_type"] != FileType.FIFO or supports_fifo)
and (item["data"]["file_type"] != FileType.CHRDEV or supports_chrdev) and (item["data"]["file_type"] != FileType.CHRDEV or supports_chrdev)
) )