Skip to content

Commit

Permalink
Use module.__path__[0] instead of module.__file__ (#2769)
Browse files Browse the repository at this point in the history
Fix #2751.

If `__init__.py` does not exist, `module.__file__` is `None` (it is
expected to give the path to `__init__.py`). In this case,
`module.__path__[0]` will give the directory path.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz authored Aug 31, 2023
1 parent f97b4f2 commit 787e2d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deepmd/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dlopen_library(module: str, filename: str):
except ModuleNotFoundError:
pass
else:
libs = sorted(Path(m.__file__).parent.glob(filename))
libs = sorted(Path(m.__path__[0]).glob(filename))
# hope that there is only one version installed...
if len(libs):
ctypes.CDLL(str(libs[0].absolute()))
Expand Down

0 comments on commit 787e2d3

Please sign in to comment.