浏览代码

Merge pull request #5786 from ThomasWaldmann/no-distutils-but-packaging-master

get rid of distutils, using packaging
TW 4 年之前
父节点
当前提交
76063ab219
共有 4 个文件被更改,包括 23 次插入15 次删除
  1. 3 3
      .github/workflows/ci.yml
  2. 14 7
      setup.py
  3. 3 2
      src/borg/__init__.py
  4. 3 3
      src/borg/xattr.py

+ 3 - 3
.github/workflows/ci.yml

@@ -63,9 +63,9 @@ jobs:
             - os: ubuntu-20.04
               python-version: '3.9'
               toxenv: py39-fuse3
-            #- os: ubuntu-20.04
-            #  python-version: '3.10-dev'
-            #  toxenv: py310-fuse3
+            - os: ubuntu-20.04
+              python-version: '3.10-dev'
+              toxenv: py310-fuse3
             - os: macos-latest
               # note: it seems that 3.8 and 3.9 are currently broken,
               # neverending RuntimeError crashes...

+ 14 - 7
setup.py

@@ -11,9 +11,8 @@ except ImportError:
     multiprocessing = None
 
 from setuptools.command.build_ext import build_ext
-from setuptools import setup, find_packages, Extension
+from setuptools import setup, find_packages, Extension, Command
 from setuptools.command.sdist import sdist
-from distutils.command.clean import clean
 
 try:
     from Cython.Build import cythonize
@@ -71,6 +70,7 @@ install_requires = [
     # Please note:
     # using any other version is not supported by borg development and
     # any feedback related to issues caused by this will be ignored.
+    'packaging',
 ]
 
 # note for package maintainers: if you package borgbackup for distribution,
@@ -137,9 +137,16 @@ def rm(file):
         pass
 
 
-class Clean(clean):
+class Clean(Command):
+    user_options = []
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
     def run(self):
-        super().run()
         for source in cython_sources:
             genc = source.replace('.pyx', '.c')
             rm(genc)
@@ -153,7 +160,7 @@ cmdclass = {
     'build_usage': setup_docs.build_usage,
     'build_man': setup_docs.build_man,
     'sdist': Sdist,
-    'clean': Clean,
+    'clean2': Clean,
 }
 
 ext_modules = []
@@ -220,8 +227,8 @@ if not on_rtd:
 
     # sometimes there's no need to cythonize
     # this breaks chained commands like 'clean sdist'
-    cythonizing = len(sys.argv) > 1 and sys.argv[1] not in ('clean', 'egg_info', '--help-commands', '--version') \
-                  and '--help' not in sys.argv[1:]
+    cythonizing = len(sys.argv) > 1 and sys.argv[1] not in (
+        ('clean', 'clean2', 'egg_info', '--help-commands', '--version')) and '--help' not in sys.argv[1:]
 
     if cythonize and cythonizing:
         cython_opts = dict(

+ 3 - 2
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
 # being 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

+ 3 - 3
src/borg/xattr.py

@@ -7,7 +7,7 @@ import subprocess
 import sys
 import tempfile
 
-from distutils.version import LooseVersion
+from packaging.version import parse as parse_version
 
 from .helpers import prepare_subprocess_env
 
@@ -29,8 +29,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