Skip to content

Commit 23532f0

Browse files
authored
Merge pull request #1514 from Unidata/post1.7.5_testfix
fix test_cli, turn on zstd compression filter test.
2 parents 5719670 + 2ea5c75 commit 23532f0

10 files changed

Lines changed: 52 additions & 14 deletions

File tree

‎.github/workflows/build_old.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
#CC: mpicc.mpich
1313
CC: mpicc
1414
#NO_NET: 1
15+
SKIP_FILTER_TEST: 1
1516
strategy:
1617
matrix:
1718
python-version: ["3.14"]

‎Changelog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
version 1.7.5.1 (tag v1.7.5.1rel)
2+
=================================
3+
* make sure zstd compression filter test always runs unless specifically disabled, fix cli test so it runs on
4+
32-bit x86. New wheels for linux that include plugins (they were left out of the 1.7.5 release).
5+
* fix version comparison logic that was broken when using netcdf-c >= 4.10.0 - this was the cause of
6+
issue #1515 (diskless persisted datasets are no longer persisted).
7+
18
version 1.7.5 (tag v1.7.5rel)
29
=============================
310
* remove python 3.10 support (it reaches EOL October 31, 2026).

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ environment = {HDF5_DIR='C:\\\\Users\\runneradmin\\micromamba\\envs\\build\\Libr
182182
[[tool.cibuildwheel.overrides]]
183183
select = "*-win_arm64"
184184
inherit.environment = "append"
185-
environment = { HDF5_DIR = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows', netCDF4_DIR = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows', PATH = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows\\\\bin;${PATH}', NO_CDL = '1' }
185+
# no filter plugins on windows arm64
186+
environment = { SKIP_FILTER_TEST=1, HDF5_DIR = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows', netCDF4_DIR = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows', PATH = 'C:\\\\vcpkg\\\\installed\\\\arm64-windows\\\\bin;${PATH}', NO_CDL = '1' }
186187
repair-wheel-command = [
187188
"delvewheel show {wheel}",
188189
"delvewheel repair -w {dest_dir} {wheel}",

‎src/netCDF4/_netCDF4.pyx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Version 1.7.5
1+
"""Version 1.7.5.1
22
-------------
33
44
# Introduction
@@ -1283,7 +1283,7 @@ import sys
12831283
import functools
12841284
from typing import Union
12851285

1286-
__version__ = "1.7.5"
1286+
__version__ = "1.7.5.1"
12871287

12881288
# Initialize numpy
12891289
import posixpath
@@ -1493,7 +1493,9 @@ def set_alignment(threshold, alignment):
14931493

14941494
__netcdf4libversion__ = getlibversion().split()[0]
14951495
__hdf5libversion__ = _gethdf5libversion()
1496-
_needsworkaround_issue485 = __netcdf4libversion__ < "4.4.0" or \
1496+
# parsed lib version for comparisons (string comparison breaks for 4.10+)
1497+
_nclibversion = Version(__netcdf4libversion__.split('-')[0])
1498+
_needsworkaround_issue485 = _nclibversion < Version("4.4.0") or \
14971499
(__netcdf4libversion__.startswith("4.4.0") and \
14981500
"-development" in __netcdf4libversion__)
14991501

@@ -1605,7 +1607,7 @@ is_native_big = numpy.dtype('>f4').byteorder == c'='
16051607
# so it will compile with versions <= 4.2.
16061608
NC_DISKLESS = 0x0008
16071609
# introduced in 4.6.2
1608-
if __netcdf4libversion__[0:5] >= "4.6.2":
1610+
if _nclibversion >= Version("4.6.2"):
16091611
NC_PERSIST = 0x4000
16101612
else: # prior to 4.6.2 this flag doesn't work, so make the same as NC_DISKLESS
16111613
NC_PERSIST = NC_DISKLESS
@@ -4499,7 +4501,7 @@ does not do anything."""
44994501
# a fix for strided slice access using HDF5 was added
45004502
# in 4.6.2.
45014503
# always use nc_get_vars for strided access with OpenDAP (issue #838).
4502-
if __netcdf4libversion__ >= "4.6.2" or\
4504+
if _nclibversion >= Version("4.6.2") or\
45034505
self._grp.filepath().startswith('http'):
45044506
self._use_get_vars = True
45054507
else:
@@ -4574,7 +4576,7 @@ does not do anything."""
45744576
if (self._grp.path != '/'): ncdump.append('path = %s' % self._grp.path)
45754577
ncdump.append('unlimited dimensions: %s' % ', '.join(unlimdims))
45764578
ncdump.append('current shape = %r' % (self.shape,))
4577-
if __netcdf4libversion__ < '4.5.1' and\
4579+
if _nclibversion < Version('4.5.1') and\
45784580
self._grp.file_format.startswith('NETCDF3'):
45794581
# issue #908: no_fill not correct for NETCDF3 files before 4.5.1
45804582
# before 4.5.1 there was no way to turn off filling on a
@@ -5267,7 +5269,7 @@ rename a `Variable` attribute named `oldname` to `newname`."""
52675269
# issue 209: don't return masked array if variable filling
52685270
# is disabled.
52695271
else:
5270-
if __netcdf4libversion__ < '4.5.1' and\
5272+
if _nclibversion < Version('4.5.1') and\
52715273
self._grp.file_format.startswith('NETCDF3'):
52725274
# issue #908: no_fill not correct for NETCDF3 files before 4.5.1
52735275
# before 4.5.1 there was no way to turn off filling on a

‎test/parse_clean_version.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from packaging.version import Version, InvalidVersion
2+
import re
3+
4+
def parse_clean_version(version_str: str) -> Version:
5+
# Normalize "-development" or any variation like "-dev" to ".dev0"
6+
cleaned = re.sub(r'[-_.]?development', '.dev0', version_str, flags=re.IGNORECASE)
7+
# Catch cases where it's just raw text hyphens (e.g., 1.0.0-dev -> 1.0.0.dev0)
8+
cleaned = re.sub(r'-dev(\d*)', r'.dev\1', cleaned, flags=re.IGNORECASE)
9+
try:
10+
return Version(cleaned)
11+
except InvalidVersion:
12+
# Fallback regex to pull just the numerical digits if it's still breaking
13+
match = re.search(r'(\d+(\.\d+)+)', version_str)
14+
if match:
15+
return Version(match.group(1))
16+
raise

‎test/test_cli.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@ def test_nc4tonc3_chunk(tmp_path, chunk, monkeypatch):
7777
utils.nc4tonc3()
7878
assert convert.call_args.kwargs["nchunk"] == (10 if chunk is None else chunk)
7979
with Dataset(destination) as dataset:
80-
assert dataset.file_format == "NETCDF3_64BIT_OFFSET"
80+
if sys.maxsize > 2**32:
81+
assert dataset.file_format == "NETCDF3_64BIT_OFFSET"
82+
else:
83+
assert dataset.file_format == "NETCDF3_64BIT"
8184
np.testing.assert_array_equal(dataset.variables["values"][:], values)

‎test/test_compression_zstd.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def write_netcdf(filename,dtype='f8',complevel: CompressionLevel = 6):
2323
nc.close()
2424

2525

26-
@unittest.skipIf(no_plugins or not has_zstd_filter, "zstd filter not available")
26+
# always run zstd test unless SKIP_FILTER_TEST set, so we know if filters are installed in wheels.
27+
@unittest.skipIf(os.getenv("SKIP_FILTER_TEST"), "skipping zstd filter test")
28+
#@unittest.skipIf(no_plugins or not has_zstd_filter, "zstd filter not available")
2729
class CompressionTestCase(unittest.TestCase):
2830
def setUp(self):
2931
self.filename1 = filename1

‎test/test_diskless.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import unittest, os, tempfile
2+
from packaging.version import Version
3+
from parse_clean_version import parse_clean_version
24
import numpy as np
35
from numpy.random.mtrand import uniform
46
from numpy.testing import assert_array_equal, assert_array_almost_equal
@@ -17,7 +19,7 @@
1719

1820

1921
@unittest.skipIf(
20-
netCDF4.__netcdf4libversion__ < "4.2.1"
22+
parse_clean_version(netCDF4.__netcdf4libversion__) < Version('4.2.1')
2123
or netCDF4.__has_parallel4_support__
2224
or netCDF4.__has_pnetcdf_support__,
2325
"no diskless support",
@@ -74,7 +76,7 @@ def runTest(self):
7476
assert os.path.isfile(self.file)==False
7577
# open persisted file.
7678
# first, check that file does actually exist on disk
77-
assert os.path.isfile(self.file2)==True
79+
assert os.path.isfile(self.file2) and os.path.getsize(self.file2) > 0
7880
f = netCDF4.Dataset(self.file2)
7981
foo = f.variables['data1']
8082
# check shape.

‎test/test_masked5.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
22
import os
33
import tempfile
4+
from packaging.version import Version
5+
from parse_clean_version import parse_clean_version
46

57
import numpy as np
68
from numpy import ma
@@ -55,7 +57,7 @@ def test_scaled(self):
5557
# issue 730
5658
# this part fails with netcdf 4.1.3
5759
# a bug in vlen strings?
58-
if __netcdf4libversion__ >= '4.4.0':
60+
if parse_clean_version(__netcdf4libversion__) >= Version('4.4.0'):
5961
assert v2[0] == 'first'
6062
assert v2[1] == '<missing>'
6163

‎test/test_vlen.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import unittest
33
import os
44
import tempfile
5+
from packaging.version import Version
56
from netCDF4 import Dataset
67
import numpy as np
78
from numpy.testing import assert_array_equal
9+
from parse_clean_version import parse_clean_version
810

911
FILE_NAME = tempfile.NamedTemporaryFile(suffix='.nc', delete=False).name
1012
VL_NAME = 'vlen_type'
@@ -163,7 +165,7 @@ class VlenAppendTestCase(unittest.TestCase):
163165
def setUp(self):
164166

165167
import netCDF4
166-
if netCDF4.__netcdf4libversion__ < "4.4.1":
168+
if parse_clean_version(netCDF4.__netcdf4libversion__) < Version("4.4.1"):
167169
self.skip = True
168170
try:
169171
self.skipTest("This test requires NetCDF 4.4.1 or later.")

0 commit comments

Comments
 (0)