Skip to content

Commit

Permalink
test/internal: drop distutils usage
Browse files Browse the repository at this point in the history
distutils will be removed in 3.12 and usage with 3.10 will lead to a
DeprecationWarning.
So replace the functionality following the migration advice from PEP 632.

Signed-off-by: Erik Larsson <[email protected]>
  • Loading branch information
whooo authored and William Roberts committed Apr 19, 2022
1 parent edd3373 commit 692de66
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ setup_requires =
pkgconfig
cryptography>=3.0
asn1crypto
packaging
install_requires =
cffi>=1.0.0
asn1crypto
cryptography>=3.0
packaging

[options.extras_require]
dev =
Expand Down
4 changes: 2 additions & 2 deletions test/TSS2_BaseTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2

from distutils import spawn
import shutil
import logging
import os
import random
Expand Down Expand Up @@ -154,7 +154,7 @@ class TpmSimulator(object):
def getSimulator():

for sim in TpmSimulator.SIMULATORS:
exe = spawn.find_executable(sim.exe)
exe = shutil.which(sim.exe)
if not exe:
print(f'Could not find executable: "{sim.exe}"', file=sys.stderr)
continue
Expand Down
11 changes: 8 additions & 3 deletions tpm2_pytss/internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import sys
from typing import List
from distutils.version import LooseVersion
from packaging.version import Version

from .._libtpm2_pytss import ffi, lib
from ..TSS2_Exception import TSS2_Exception
Expand Down Expand Up @@ -244,7 +244,12 @@ def _check_bug_fixed(
def _lib_version_atleast(tss2_lib, version):
if tss2_lib not in _versions:
return False
libv = LooseVersion(_versions[tss2_lib])
lv = LooseVersion(version)
# Needed to remove git commit from version strings
lib_parts = _versions[tss2_lib].rsplit("-", 1)
fixed_lib_version = lib_parts[0]
version_parts = version.rsplit("-", 1)
fixed_version = version_parts[0]
libv = Version(fixed_lib_version)
lv = Version(fixed_version)

return libv >= lv

0 comments on commit 692de66

Please sign in to comment.