diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index bfe5a1bff..b9c575af2 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -25,6 +25,8 @@ organisation on `GitHub `__. * Fixed parsing of AMBER and GROMACS GLYCAM force field topologies. +* Fix hang in ``sire.load`` function when shared GROMACS topology path is missing. + `2025.4.0 `__ - February 2026 --------------------------------------------------------------------------------------------- diff --git a/src/sire/_load.py b/src/sire/_load.py index 27891d69d..66334ce8a 100644 --- a/src/sire/_load.py +++ b/src/sire/_load.py @@ -77,11 +77,16 @@ def _get_gromacs_dir(): if not os.path.exists(gromacs_tbz2): try: + import socket import urllib.request - urllib.request.urlretrieve(f"{tutorial_url}/gromacs.tar.bz2", gromacs_tbz2) - except Exception: - # we cannot download - just give up + with urllib.request.urlopen( + f"{tutorial_url}/gromacs.tar.bz2", timeout=5 + ) as response: + with open(gromacs_tbz2, "wb") as f: + f.write(response.read()) + except (Exception, socket.timeout): + # we cannot download - continue without GROMACS return None if not os.path.exists(gromacs_tbz2): @@ -443,7 +448,7 @@ def load( gromacs_path = _get_gromacs_dir() m = { - "GROMACS_PATH": _get_gromacs_dir(), + "GROMACS_PATH": gromacs_path, "show_warnings": show_warnings, "parallel": parallel, "ignore_topology_frame": ignore_topology_frame,