diff --git a/src/netCDF4/_netCDF4.pyx b/src/netCDF4/_netCDF4.pyx index 7c92f09bd..d5e486de6 100644 --- a/src/netCDF4/_netCDF4.pyx +++ b/src/netCDF4/_netCDF4.pyx @@ -1318,6 +1318,15 @@ if __has_nc_rc_set__: if nc_rc_set("HTTP.SSL.CAINFO", _strencode(certifi.where())) != 0: raise RuntimeError('error setting path to SSL certificates') +# set .netrc if availble in cwd or home (issue #1299) +if __has_nc_rc_set__: + filename = ".netrc" + for path in [pathlib.Path(filename), pathlib.Path.home().joinpath(filename)]: + if path.exists(): + if nc_rc_set("HTTP.NETRC", _strencode(path)) != 0: + raise RuntimeError('error setting path to .netrc file') + break + def rc_get(key): """ **```rc_get(key)```**