Skip to content

Commit

Permalink
Windows: Add PATH to .dll directories
Browse files Browse the repository at this point in the history
Python 3.8+ on Windows: DLL search paths for dependent
shared libraries.

Refs.:
- python/cpython#80266
- https://docs.python.org/3.8/library/os.html#os.add_dll_directory
  • Loading branch information
ax3l committed Nov 20, 2022
1 parent 21f0158 commit 8cbc1f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ jobs:
cmake --build build --config Debug -j 2
if(!$?) { Exit $LASTEXITCODE }
dumpbin /dependents build\lib\site-packages\amrex\amrex_pybind.cp311-win_amd64.pyd
cmake --build build --config Debug --target install
if(!$?) { Exit $LASTEXITCODE }
cmake --build build --config Debug --target pip_install
if(!$?) { Exit $LASTEXITCODE }
- name: Unit tests
run: |
set PATH="C:/Program Files (x86)/pyAMReX/bin/;%PATH%"
ctest --test-dir build -C Debug --output-on-failure
21 changes: 21 additions & 0 deletions src/amrex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import os

# Python 3.8+ on Windows: DLL search paths for dependent
# shared libraries
# Refs.:
# - https://github.com/python/cpython/issues/80266
# - https://docs.python.org/3.8/library/os.html#os.add_dll_directory
if os.name == "nt":
# add anything in the current directory
pwd = __file__.rsplit(os.sep, 1)[0] + os.sep
os.add_dll_directory(pwd)
# add anything in PATH
paths = os.environ.get("PATH", "")
for p in paths.split(";"):
print(f"p={p}")
if os.path.exists(p):
os.add_dll_directory(p)
else:
print(" ... does NOT exist")

# import core bindings to C++
from . import amrex_pybind
from .amrex_pybind import * # noqa

Expand Down

0 comments on commit 8cbc1f3

Please sign in to comment.