Skip to content
Snippets Groups Projects
Commit 953a599c authored by Zbigniew Jędrzejewski-Szmek's avatar Zbigniew Jędrzejewski-Szmek Committed by Chris Lamb
Browse files

Replace distutils.LooseVersion by Version

Every import of distuils now raises a warning, and the module is
slated for removal.

The recommended replacement is packaging.version. It has Version and
LegacyVersion. LegacyVersion documents itself as "This class
implements the previous de facto sorting algorithm used by
setuptools". (Comparisons of packaging.LegacyVersion and
packaging.Version are intentionally borked, so packaging.LegacyVersion
should not be mixed with packaging.Version or packaging.parse(), which
can return packaging.Version.) But use of LegacyVersion also raises
a deprecation warning, with removal slated for the next release.

The runtime requirement on 'distutils' is dropped, since it is not
needed any more.
parent beebe3fd
No related branches found
No related tags found
1 merge request!87Stop using deprecated distutils
......@@ -100,7 +100,6 @@ Vcs-Browser: https://salsa.debian.org/reproducible-builds/diffoscope
Package: diffoscope-minimal
Architecture: all
Depends:
python3-distutils,
python3-pkg-resources,
${misc:Depends},
${python3:Depends},
......
......@@ -22,8 +22,8 @@ import pytest
import subprocess
from diffoscope.config import Config
from distutils.version import LooseVersion
from diffoscope.comparators.ar import ArFile
from diffoscope.versions import Version
from ..utils import diff_ignore_line_numbers
from ..utils.data import load_fixture, get_data
......@@ -69,18 +69,18 @@ def differences(rlib1, rlib2):
@pytest.fixture
def rlib_dis_expected_diff():
actual_ver = llvm_version()
actual_ver = Version(llvm_version())
if LooseVersion(str(actual_ver)) >= LooseVersion("3.8"):
if actual_ver >= "3.8":
diff_file = "rlib_llvm_dis_expected_diff"
if LooseVersion(str(actual_ver)) >= LooseVersion("5.0"):
if actual_ver >= "5.0":
diff_file = "rlib_llvm_dis_expected_diff_5"
if LooseVersion(str(actual_ver)) >= LooseVersion("7.0"):
if actual_ver >= "7.0":
diff_file = "rlib_llvm_dis_expected_diff_7"
if LooseVersion(str(actual_ver)) >= LooseVersion("10.0"):
if actual_ver >= "10.0":
diff_file = "rlib_llvm_dis_expected_diff_10"
return get_data(diff_file)
......
......@@ -21,10 +21,9 @@ import sys
import json
import pytest
from distutils.version import LooseVersion
from diffoscope.main import main
from diffoscope.progress import ProgressManager, StatusFD
from diffoscope.versions import Version
from .utils.tools import skip_unless_module_exists
......@@ -56,7 +55,7 @@ def progressbar_err():
actual_ver = progressbar_version()
for k, v in expected_err.items():
if LooseVersion(actual_ver) < LooseVersion(k):
if Version(actual_ver) < Version(k):
return v
return ""
......
......@@ -24,9 +24,8 @@ import functools
import importlib.util
import subprocess
from distutils.version import LooseVersion
from diffoscope.tools import get_package_provider, find_executable
from diffoscope.versions import Version
def file_version():
......@@ -104,7 +103,7 @@ def skip_unless_tools_exist(*required):
)
def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=Version):
if tools_missing(tool):
return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
......@@ -118,7 +117,7 @@ def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
)
def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=Version):
if tools_missing(tool) and module_is_not_importable(tool):
return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
......@@ -132,7 +131,7 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
)
def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=LooseVersion):
def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=Version):
if tools_missing(tool) and module_is_not_importable(tool):
return skipif(True, reason=reason(tool), tools=(tool,))
if callable(actual_ver):
......@@ -147,7 +146,7 @@ def skip_unless_tool_is_at_most(tool, actual_ver, max_ver, vcls=LooseVersion):
def skip_unless_tool_is_between(
tool, actual_ver, min_ver, max_ver, vcls=LooseVersion
tool, actual_ver, min_ver, max_ver, vcls=Version
):
if tools_missing(tool):
return skipif(True, reason=reason(tool), tools=(tool,))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment