Skip to content

Commit 2680eb8

Browse files
committed
change logic managing adding dll directories to path on Windows
1 parent 3381d14 commit 2680eb8

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

dpctl/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@
129129
"utils",
130130
]
131131

132-
if hasattr(os, "add_dll_directory"):
133-
# Include folder containing DPCTLSyclInterface.dll to search path
134-
os.add_dll_directory(os.path.dirname(__file__))
135-
136132

137133
def get_include():
138134
r"""

dpctl/_init_helper.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@
1818
import os.path
1919
import sys
2020

21-
is_venv_win32 = (
22-
sys.platform == "win32"
23-
and sys.base_exec_prefix != sys.exec_prefix
24-
and os.path.isfile(os.path.join(sys.exec_prefix, "pyvenv.cfg"))
21+
is_venv = sys.base_exec_prefix != sys.exec_prefix and os.path.isfile(
22+
os.path.join(sys.exec_prefix, "pyvenv.cfg")
2523
)
2624

27-
if is_venv_win32: # pragma: no cover
28-
# For virtual environments on Windows, add folder
29-
# with DPC++ libraries to the DLL search path gh-1745
30-
dll_dir = os.path.join(sys.exec_prefix, "Library", "bin")
31-
if os.path.isdir(dll_dir):
32-
os.add_dll_directory(dll_dir)
33-
34-
del is_venv_win32
25+
if sys.platform == "win32": # pragma: no cover
26+
# Include folder containing DPCTLSyclInterface.dll to search path
27+
os.add_dll_directory(os.path.dirname(__file__))
28+
if is_venv:
29+
# For virtual environments on Windows, add folder
30+
# with DPC++ libraries to the DLL search path gh-1745
31+
dll_dir = os.path.join(sys.exec_prefix, "Library", "bin")
32+
if os.path.isdir(dll_dir):
33+
os.add_dll_directory(dll_dir)
34+
os.environ["PATH"] = os.pathsep.join(
35+
[os.getenv("PATH", ""), dll_dir]
36+
)
37+
38+
del is_venv
3539

3640
is_linux = sys.platform.startswith("linux")
3741

0 commit comments

Comments
 (0)