Skip to content

Commit 41f77ef

Browse files
authored
Merge pull request #1474 from ocefpaf/fix_version_string_comparison
fix version comparison
2 parents 24a17aa + 4a9a4a5 commit 41f77ef

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ classifiers = [
3737
dependencies = [
3838
"cftime",
3939
"certifi",
40+
"packaging",
4041
"numpy>=2.3.0; platform_system == 'Windows' and platform_machine == 'ARM64'",
4142
"numpy>=1.21.2; platform_system != 'Windows' or platform_machine != 'ARM64'",
4243
]
@@ -45,7 +46,6 @@ dynamic = ["version"]
4546
[project.optional-dependencies]
4647
tests = [
4748
"Cython",
48-
"packaging",
4949
"pytest",
5050
"typing-extensions>=4.15.0",
5151
]

src/netCDF4/_netCDF4.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,7 @@ __version__ = "1.7.4.1"
12881288
# Initialize numpy
12891289
import posixpath
12901290
from cftime import date2num, num2date, date2index
1291+
from packaging.version import Version
12911292
import numpy
12921293
cimport numpy
12931294
import weakref
@@ -2410,7 +2411,7 @@ strings.
24102411

24112412
# flag to indicate that Variables in this Dataset support orthogonal indexing.
24122413
self.__orthogonal_indexing__ = True
2413-
if diskless and __netcdf4libversion__ < '4.2.1':
2414+
if diskless and Version(__netcdf4libversion__) < Version('4.2.1'):
24142415
#diskless = False # don't raise error, instead silently ignore
24152416
raise ValueError('diskless mode requires netcdf lib >= 4.2.1, you have %s' % __netcdf4libversion__)
24162417
# convert filename into string (from os.path object for example),

0 commit comments

Comments
 (0)