Skip to content

Commit

Permalink
Remove deprecated distutils for python 3.12 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
borntohonk committed Dec 14, 2024
1 parent 4f79d3f commit d97f678
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ext/pint/testsuite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


import doctest
from distutils.version import StrictVersion
from packaging.utils import canonical_version
import re
import unittest

Expand All @@ -14,13 +14,13 @@
def requires_numpy18():
if not HAS_NUMPY:
return unittest.skip('Requires NumPy')
return unittest.skipUnless(StrictVersion(NUMPY_VER) >= StrictVersion('1.8'), 'Requires NumPy >= 1.8')
return unittest.skipUnless(canonical_version(NUMPY_VER) >= canonical_version('1.8'), 'Requires NumPy >= 1.8')


def requires_numpy_previous_than(version):
if not HAS_NUMPY:
return unittest.skip('Requires NumPy')
return unittest.skipUnless(StrictVersion(NUMPY_VER) < StrictVersion(version), 'Requires NumPy < %s' % version)
return unittest.skipUnless(canonical_version(NUMPY_VER) < canonical_version(version), 'Requires NumPy < %s' % version)


def requires_numpy():
Expand Down
6 changes: 3 additions & 3 deletions lib/pkg_resources/tests/test_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
import stat
import distutils.dist
import distutils.command.install_egg_info
import setuptools.command.install_egg_info

try:
from unittest import mock
Expand Down Expand Up @@ -344,8 +344,8 @@ def create_foo_pkg(self, env, version):
"""
ld = "This package has unicode metadata! ❄"
attrs = dict(name='foo', version=version, long_description=ld)
dist = distutils.dist.Distribution(attrs)
iei_cmd = distutils.command.install_egg_info.install_egg_info(dist)
dist = setuptools.dist.Distribution(attrs)
iei_cmd = setuptools.command.install_egg_info.install_egg_info(dist)
iei_cmd.initialize_options()
iei_cmd.install_dir = env.paths['lib']
iei_cmd.finalize_options()
Expand Down
4 changes: 2 additions & 2 deletions medusa/updater/update_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import unicode_literals

import logging
from distutils.version import LooseVersion
from packaging.version import Version

from github import GithubException

Expand Down Expand Up @@ -42,7 +42,7 @@ def newest_version(self):
def is_latest_version(self):
"""Compare the current installed version with the remote version."""
try:
if LooseVersion(self.newest_version) > LooseVersion(self.current_version):
if Version(self.newest_version) > Version(self.current_version):
return False
except (GithubException, RequestException) as error:
log.warning("Unable to contact GitHub, can't get latest version: {0!r}", error)
Expand Down

0 comments on commit d97f678

Please sign in to comment.