From 1cbdcba5e94773cab20461a1f79d5147a5f0992d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 1 May 2021 15:20:45 +0200 Subject: [PATCH] get rid of distutils, use packaging --- setup.py | 4 +++- src/borg/__init__.py | 5 +++-- src/borg/xattr.py | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 136bb844e..e20ac1afe 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,9 @@ if my_python < min_python: # Are we building on ReadTheDocs? on_rtd = os.environ.get('READTHEDOCS') -install_requires = [] +install_requires = [ + 'packaging', +] # note for package maintainers: if you package borgbackup for distribution, # please add llfuse as a *requirement* on all platforms that have a working diff --git a/src/borg/__init__.py b/src/borg/__init__.py index c2b201860..4350ebc07 100644 --- a/src/borg/__init__.py +++ b/src/borg/__init__.py @@ -1,11 +1,12 @@ -from distutils.version import LooseVersion +from packaging.version import parse as parse_version # IMPORTANT keep imports from borg here to a minimum because our testsuite depends on # beeing able to import borg.constants and then monkey patching borg.constants.PBKDF2_ITERATIONS from ._version import version as __version__ -__version_tuple__ = tuple(LooseVersion(__version__).version[:3]) +_v = parse_version(__version__) +__version_tuple__ = _v._version.release # assert that all semver components are integers # this is mainly to show errors when people repackage poorly diff --git a/src/borg/xattr.py b/src/borg/xattr.py index 8cdd18968..a28d6d205 100644 --- a/src/borg/xattr.py +++ b/src/borg/xattr.py @@ -8,7 +8,7 @@ import sys import tempfile from ctypes import CDLL, create_string_buffer, c_ssize_t, c_size_t, c_char_p, c_int, c_uint32, get_errno from ctypes.util import find_library -from distutils.version import LooseVersion +from packaging.version import parse as parse_version from .helpers import Buffer, prepare_subprocess_env @@ -90,8 +90,8 @@ if sys.platform.startswith('linux'): if preload.startswith("libfakeroot"): env = prepare_subprocess_env(system=True) fakeroot_output = subprocess.check_output(['fakeroot', '-v'], env=env) - fakeroot_version = LooseVersion(fakeroot_output.decode('ascii').split()[-1]) - if fakeroot_version >= LooseVersion("1.20.2"): + fakeroot_version = parse_version(fakeroot_output.decode('ascii').split()[-1]) + if fakeroot_version >= parse_version("1.20.2"): # 1.20.2 has been confirmed to have xattr support # 1.18.2 has been confirmed not to have xattr support # Versions in-between are unknown