Skip to content

Commit bfb599f

Browse files
authored
Fix: Windows add_dll_directory Expand (#272)
Expand paths in `PATH` environment variable before adding them and make them absolute paths.
1 parent 1b50287 commit bfb599f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/amrex/space1d/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
# add anything in PATH
1515
paths = os.environ.get("PATH", "")
1616
for p in paths.split(";"):
17-
if os.path.exists(p):
18-
os.add_dll_directory(p)
17+
p_abs = os.path.abspath(os.path.expanduser(os.path.expandvars(p)))
18+
if os.path.exists(p_abs):
19+
os.add_dll_directory(p_abs)
1920

2021
# import core bindings to C++
2122
from . import amrex_1d_pybind

src/amrex/space2d/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
# add anything in PATH
1515
paths = os.environ.get("PATH", "")
1616
for p in paths.split(";"):
17-
if os.path.exists(p):
18-
os.add_dll_directory(p)
17+
p_abs = os.path.abspath(os.path.expanduser(os.path.expandvars(p)))
18+
if os.path.exists(p_abs):
19+
os.add_dll_directory(p_abs)
1920

2021
# import core bindings to C++
2122
from . import amrex_2d_pybind

src/amrex/space3d/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
# add anything in PATH
1515
paths = os.environ.get("PATH", "")
1616
for p in paths.split(";"):
17-
if os.path.exists(p):
18-
os.add_dll_directory(p)
17+
p_abs = os.path.abspath(os.path.expanduser(os.path.expandvars(p)))
18+
if os.path.exists(p_abs):
19+
os.add_dll_directory(p_abs)
1920

2021
# import core bindings to C++
2122
from . import amrex_3d_pybind

0 commit comments

Comments
 (0)