Skip to content

Commit f30db15

Browse files
committed
fix: updated the deprecated pkg_resources with packaging.version
1 parent c334808 commit f30db15

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/sage/features/fricas.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import subprocess
1616
from . import Executable, FeatureTestResult
17+
from packaging.version import Version
1718

1819

1920
class FriCAS(Executable):
@@ -43,6 +44,12 @@ def __init__(self):
4344
def get_version(self):
4445
r"""
4546
Retrieve the installed FriCAS version
47+
48+
EXAMPLES::
49+
50+
sage: from sage.features.fricas import FriCAS
51+
sage: FriCAS().get_version() # optional - fricas
52+
'1.3.8'
4653
"""
4754
try:
4855
output = subprocess.check_output(['fricas', '--version'], stderr=subprocess.STDOUT)
@@ -79,11 +86,13 @@ def is_functional(self):
7986
return FeatureTestResult(self, False,
8087
reason="Could not determine FriCAS version")
8188

82-
from pkg_resources import parse_version
83-
if parse_version(version) < parse_version(self.MINIMUM_VERSION):
84-
return FeatureTestResult(self, False,
85-
reason=f"FriCAS version {version} is too old; minimum required is {self.MINIMUM_VERSION}")
86-
return FeatureTestResult(self, True)
89+
try:
90+
if Version(version) < Version(self.MINIMUM_VERSION):
91+
return FeatureTestResult(self, False,
92+
reason=f"FriCAS version {version} is too old; minimum required is {self.MINIMUM_VERSION}")
93+
return FeatureTestResult(self, True)
94+
except ValueError:
95+
return FeatureTestResult(self, False, reason="Invalid Version Format")
8796

8897

8998
def all_features():

0 commit comments

Comments
 (0)