From ab08bbaccc19d2308b3717a2470de63658d4cdd6 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Tue, 29 Oct 2024 14:43:23 +0100 Subject: [PATCH] Set HTTP.NETRC if .netrc file found --- src/netCDF4/_netCDF4.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/netCDF4/_netCDF4.pyx b/src/netCDF4/_netCDF4.pyx index 7c92f09bd..9f3199640 100644 --- a/src/netCDF4/_netCDF4.pyx +++ b/src/netCDF4/_netCDF4.pyx @@ -1318,6 +1318,14 @@ 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__: + for path in [pathlib.Path(".netrc"), pathlib.Path.home().joinpath(".netrc")]: + 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)```**