Skip to content

Commit 37a3fe7

Browse files
Fixed test_cython_api
1 parent 1389a32 commit 37a3fe7

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

dpctl/tests/setup_cython_api.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,36 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import Cython.Build
17+
import shutil
18+
1819
import setuptools
20+
from Cython.Build import build_ext
1921

2022
import dpctl
2123

24+
25+
class custom_build_ext(build_ext):
26+
def build_extensions(self):
27+
cmplr_name = shutil.which("icpx")
28+
if cmplr_name is None:
29+
cmplr_name = shutil.which("clang++")
30+
if cmplr_name is None:
31+
raise RuntimeError("DPC++ compiler is required")
32+
self.compiler.set_executable(
33+
"compiler_so", cmplr_name + " -fsycl -fPIC"
34+
)
35+
self.compiler.set_executable(
36+
"compiler_cxx", cmplr_name + " -fsycl -fPIC"
37+
)
38+
self.compiler.set_executable(
39+
"linker_so",
40+
cmplr_name
41+
+ " -fsycl -shared -fpic "
42+
+ "-fsycl-device-code-split=per_kernel",
43+
)
44+
build_ext.build_extensions(self)
45+
46+
2247
ext = setuptools.Extension(
2348
"_cython_api",
2449
["_cython_api.pyx"],
@@ -27,8 +52,8 @@
2752
)
2853

2954
setuptools.setup(
30-
name="_cython_api",
55+
name="test_cython_api",
3156
version="0.0.0",
3257
ext_modules=[ext],
33-
cmdclass={"build_ext": Cython.Build.build_ext},
58+
cmdclass={"build_ext": custom_build_ext},
3459
)

0 commit comments

Comments
 (0)