Skip to content

Commit efa1a19

Browse files
Fix import dpnp on Win & python 3.10 (#1189)
* Fix import dpnp on Win & python 3.10 * PATH is used by python till 3.10 * Update dpnp/__init__.py Co-authored-by: Oleksandr Pavlyk <[email protected]> * Update dpnp/__init__.py Co-authored-by: Oleksandr Pavlyk <[email protected]> * Update dpnp/__init__.py Co-authored-by: Oleksandr Pavlyk <[email protected]> * Update dpnp/__init__.py Co-authored-by: Oleksandr Pavlyk <[email protected]> * Apply review comments Co-authored-by: Oleksandr Pavlyk <[email protected]>
1 parent 8b44b4a commit efa1a19

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dpnp/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# *****************************************************************************
3-
# Copyright (c) 2016-2020, Intel Corporation
3+
# Copyright (c) 2016-2022, Intel Corporation
44
# All rights reserved.
55
#
66
# Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,16 @@
3030
import dpctl
3131
dpctlpath = os.path.dirname(dpctl.__file__)
3232

33-
os.environ["PATH"] += os.pathsep + mypath + os.pathsep + dpctlpath
33+
# For Windows OS with Python >= 3.7, it is required to explicitly define a path
34+
# where to search for DLLs towards both DPNP backend and DPCTL Sycl interface,
35+
# otherwise DPNP import will be failing. This is because the libraries
36+
# are not installed under any of default paths where Python is searching.
37+
from platform import system
38+
if system() == 'Windows':
39+
if hasattr(os, "add_dll_directory"):
40+
os.add_dll_directory(mypath)
41+
os.add_dll_directory(dpctlpath)
42+
os.environ["PATH"] = os.pathsep.join([os.getenv("PATH", ""), mypath, dpctlpath])
3443

3544

3645
from dpnp.dpnp_array import dpnp_array as ndarray

0 commit comments

Comments
 (0)