Skip to content

Commit b8682e4

Browse files
author
Jeff Whitaker
authored
Merge pull request #1251 from Unidata/v1.6.4rel
fix for https OpenDAP URLs with linux wheels (issue #1246)
2 parents 2044386 + a79802d commit b8682e4

File tree

8 files changed

+44
-9
lines changed

8 files changed

+44
-9
lines changed

.github/workflows/build_latest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
env:
88
PNETCDF_VERSION: 1.12.1
9-
NETCDF_VERSION: 4.9.1
9+
NETCDF_VERSION: 4.9.2
1010
NETCDF_DIR: ${{ github.workspace }}/..
1111
NETCDF_EXTRA_CONFIG: --enable-pnetcdf
1212
CC: mpicc.mpich

.github/workflows/miniconda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
init-shell: bash
3131
create-args: >-
3232
python=${{ matrix.python-version }}
33-
numpy cython pip pytest hdf5 libnetcdf cftime zlib
33+
numpy cython pip pytest hdf5 libnetcdf cftime zlib certifi
3434
--channel conda-forge
3535
3636
- name: Install netcdf4-python
@@ -61,7 +61,7 @@ jobs:
6161
init-shell: bash
6262
create-args: >-
6363
python=${{ matrix.python-version }}
64-
numpy cython pip pytest mpi4py hdf5=*=mpi* libnetcdf=*=mpi* cftime zlib
64+
numpy cython pip pytest mpi4py hdf5=*=mpi* libnetcdf=*=mpi* cftime zlib certifi
6565
--channel conda-forge
6666
6767
- name: Install netcdf4-python with mpi

Changelog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version 1.6.4 (tag v1.6.4rel)
2-
==============================
2+
===============================
3+
* set path to SSL certificates internally, so https DAP URLs work with wheels
4+
(issue #1246, requires nc_rc_set function available starting with netcdf-c
5+
4.9.1, plus bugfix in netcdf-c PR #2690).
6+
Added certifi as a dependency.
37
* Added `isopen` method to `MFDataset` object to check if underlying files are open.
48

59
version 1.6.3 (tag v1.6.3rel)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
## News
1111
For details on the latest updates, see the [Changelog](https://github.com/Unidata/netcdf4-python/blob/master/Changelog).
1212

13+
6/4/2023: Version [1.6.4](https://pypi.python.org/pypi/netCDF4/1.6.4) released. Now requires
14+
[certifi](https://github.com/certifi/python-certifi) to locate SSL certificates - this allows
15+
OpenDAP https URLs to work with linux wheels (issue [#1246](https://github.com/Unidata/netcdf4-python/issues/1246).
16+
1317
3/3/2023: Version [1.6.3](https://pypi.python.org/pypi/netCDF4/1.6.3) released.
1418

1519
11/15/2022: Version [1.6.2](https://pypi.python.org/pypi/netCDF4/1.6.2) released. Fix for

include/netCDF4.pxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ cdef extern from "netcdf.h":
366366
int nc_inq_enum_member(int ncid, nc_type xtype, int idx, char *name, void *value) nogil
367367

368368
int nc_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier) nogil
369+
int nc_rc_set(char* key, char* value) nogil
369370

370371
IF HAS_QUANTIZATION_SUPPORT:
371372
cdef extern from "netcdf.h":

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ classifiers = [
4242
]
4343
dependencies = [
4444
"cftime",
45+
"certifi",
4546
"numpy",
4647
]
4748
dynamic = ["version"]

setup.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def check_api(inc_dirs,netcdf_lib_version):
6060
has_blosc = False
6161
has_ncfilter = False
6262
has_set_alignment = False
63+
has_nc_rc_set = False
6364

6465
for d in inc_dirs:
6566
try:
@@ -83,6 +84,8 @@ def check_api(inc_dirs,netcdf_lib_version):
8384
has_quantize = True
8485
if line.startswith('nc_set_alignment'):
8586
has_set_alignment = True
87+
if line.startswith('EXTERNL int nc_rc_set'):
88+
has_nc_rc_set = True
8689

8790
if has_nc_open_mem:
8891
try:
@@ -150,7 +153,8 @@ def check_api(inc_dirs,netcdf_lib_version):
150153
return has_rename_grp, has_nc_inq_path, has_nc_inq_format_extended, \
151154
has_cdf5_format, has_nc_open_mem, has_nc_create_mem, \
152155
has_parallel4_support, has_pnetcdf_support, has_szip_support, has_quantize, \
153-
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter
156+
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter, \
157+
has_nc_rc_set
154158

155159

156160
def getnetcdfvers(libdirs):
@@ -564,7 +568,7 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
564568
has_rename_grp, has_nc_inq_path, has_nc_inq_format_extended, \
565569
has_cdf5_format, has_nc_open_mem, has_nc_create_mem, \
566570
has_parallel4_support, has_pnetcdf_support, has_szip_support, has_quantize, \
567-
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter = \
571+
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter, has_nc_rc_set = \
568572
check_api(inc_dirs,netcdf_lib_version)
569573
# for netcdf 4.4.x CDF5 format is always enabled.
570574
if netcdf_lib_version is not None and\
@@ -686,6 +690,13 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
686690
sys.stdout.write('netcdf lib does not have nc_inq_filter_avail function\n')
687691
f.write('DEF HAS_NCFILTER = 0\n')
688692

693+
if has_nc_rc_set:
694+
sys.stdout.write('netcdf lib has nc_rc_set function\n')
695+
f.write('DEF HAS_NCRCSET = 1\n')
696+
else:
697+
sys.stdout.write('netcdf lib does not have nc_rc_set function\n')
698+
f.write('DEF HAS_NCRCSET = 0\n')
699+
689700
f.close()
690701

691702
if has_parallel4_support or has_pnetcdf_support:

src/netCDF4/_netCDF4.pyx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Version 1.6.3
2+
Version 1.6.4
33
-------------
44
55
# Introduction
@@ -1228,7 +1228,7 @@ from .utils import (_StartCountStride, _quantize, _find_dim, _walk_grps,
12281228
import sys
12291229
import functools
12301230

1231-
__version__ = "1.6.3"
1231+
__version__ = "1.6.4"
12321232

12331233
# Initialize numpy
12341234
import posixpath
@@ -1259,14 +1259,28 @@ ELSE:
12591259
ctypedef object Comm
12601260
ctypedef object Info
12611261

1262+
# set path to SSL certificates (issue #1246)
1263+
IF HAS_NCRCSET: # available starting in version 4.9.1
1264+
import certifi
1265+
cdef _set_curl_certpath(certpath):
1266+
cdef char *cert_path
1267+
cdef char *key
1268+
cdef int ierr
1269+
bytestr = _strencode(certpath)
1270+
cert_path = bytestr
1271+
ierr = nc_rc_set("HTTP.SSL.CAINFO",cert_path)
1272+
if ierr != 0:
1273+
raise RuntimeError('error setting path to SSL certificates')
1274+
_set_curl_certpath(certifi.where())
1275+
12621276
# check for required version of netcdf-4 and hdf5.
12631277

12641278
def _gethdf5libversion():
12651279
cdef unsigned int majorvers, minorvers, releasevers
12661280
cdef herr_t ierr
12671281
with nogil:
12681282
ierr = H5get_libversion( &majorvers, &minorvers, &releasevers)
1269-
if ierr < 0:
1283+
if ierr != 0:
12701284
raise RuntimeError('error getting HDF5 library version info')
12711285
return '%d.%d.%d' % (majorvers,minorvers,releasevers)
12721286

0 commit comments

Comments
 (0)