Skip to content

Commit

Permalink
Fix for CONPY-226:
Browse files Browse the repository at this point in the history
Replaced deprecated call to distutils.version.StrictVersion by
packaging.version.Version
  • Loading branch information
9EOR9 committed Oct 9, 2022
1 parent 37623b1 commit 1d700ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mariadb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import mariadb.cursors

from mariadb.constants import STATUS, TPC_STATE, INFO
from distutils.version import StrictVersion
from packaging import version

_DEFAULT_CHARSET = "utf8mb4"
_DEFAULT_COLLATION = "utf8mb4_general_ci"
Expand Down Expand Up @@ -68,8 +68,8 @@ def __init__(self, *args, **kwargs):
# we need to check if it's supported by Connector/C
if "host" in kwargs:
host = kwargs.get("host")
if StrictVersion(mariadb.mariadbapi_version) <\
StrictVersion('3.3.0') and ',' in host:
if version.Version(mariadb.mariadbapi_version) <\
version.Version('3.3.0') and ',' in host:
raise mariadb.ProgrammingError("Host failover list requires "
"MariaDB Connector/C 3.3.0 "
"or newer")
Expand Down
4 changes: 2 additions & 2 deletions mariadb_posix.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

import subprocess
from distutils.version import StrictVersion
from packaging import version
import sys
import os

Expand Down Expand Up @@ -60,7 +60,7 @@ def get_config(options):
config_prg = "mariadb_config"

cc_version = mariadb_config(config_prg, "cc_version")
if StrictVersion(cc_version[0]) < StrictVersion(required_version):
if version.Version(cc_version[0]) < version.Version(required_version):
print('MariaDB Connector/Python requires MariaDB Connector/C '
'>= %s, found version %s' % (required_version, cc_version[0]))
sys.exit(2)
Expand Down
6 changes: 3 additions & 3 deletions mariadb_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import platform
import sys
from distutils.version import StrictVersion
from packaging import version

from winreg import ConnectRegistry, OpenKey, QueryValueEx,\
HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_64KEY
Expand Down Expand Up @@ -45,8 +45,8 @@ def get_config(options):
'MariaDB Connector C 64-bit',
access=KEY_READ | KEY_WOW64_64KEY)
cc_version = QueryValueEx(connector_key, "Version")
if (StrictVersion(cc_version[0]) <
StrictVersion(required_version)):
if (version.Version(cc_version[0]) <
version.Version(required_version)):
print("MariaDB Connector/Python requires "
"MariaDB Connector/C "
">= %s (found version: %s") \
Expand Down

0 comments on commit 1d700ad

Please sign in to comment.