Skip to content
Snippets Groups Projects
Commit e679697a authored by kiilerix's avatar kiilerix
Browse files

tests: use packaging from setuptools instead of deprecated distutils

When invoking StrictVersion in 3.12 we got:
    DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.

distutils is dead in the standard library, and we have to move towards using
`setuptools` as general extern dependency. Instead of also requiring the extern
`packaging`, we will just use the packaging that is vendored in setuptools.
parent be227c60
No related branches found
No related tags found
3 merge requests!1041Merge default into stable,!997tests: use shlex.quote instead of pipes.quote,!902Misc newer Python version fixes from Mads
import distutils.version
import os
import re
import socket
......@@ -7,6 +6,11 @@
import sys
import tempfile
try:
from setuptools.extern.packaging.version import Version
except ImportError:
from distutils.version import StrictVersion as Version
tempprefix = 'hg-hghave-'
checks = {
......@@ -1118,11 +1122,12 @@
blackcmd = 'black --version'
version_regex = b'black, (?:version )?([0-9a-b.]+)'
version = matchoutput(blackcmd, version_regex)
sv = distutils.version.StrictVersion
return version and sv(_bytes2sys(version.group(1))) >= sv('23.3.0')
if not version:
return False
return Version(_bytes2sys(version.group(1))) >= Version('23.3.0')
@check('pytype', 'the pytype type checker')
def has_pytype():
pytypecmd = 'pytype --version'
version = matchoutput(pytypecmd, b'[0-9a-b.]+')
......@@ -1123,11 +1128,12 @@
@check('pytype', 'the pytype type checker')
def has_pytype():
pytypecmd = 'pytype --version'
version = matchoutput(pytypecmd, b'[0-9a-b.]+')
sv = distutils.version.StrictVersion
return version and sv(_bytes2sys(version.group(0))) >= sv('2019.10.17')
if not version:
return False
return Version(_bytes2sys(version.group(0))) >= Version('2019.10.17')
@check("rustfmt", "rustfmt tool at version nightly-2024-07-16")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment