15
15
# limitations under the License.
16
16
17
17
import argparse
18
+ import importlib
18
19
import os
19
20
import os .path
20
21
import platform
21
22
import sys
22
23
import warnings
23
24
24
- import dpctl
25
-
26
25
27
26
def _dpctl_dir () -> str :
28
- abs_path = os . path . abspath ( dpctl . __file__ )
29
- dpctl_dir = os .path .dirname ( abs_path )
30
- return dpctl_dir
27
+ dpctl_dir = importlib . util . find_spec ( " dpctl" ). submodule_search_locations [ 0 ]
28
+ abs_dpctl_dir = os .path .abspath ( dpctl_dir )
29
+ return abs_dpctl_dir
31
30
32
31
33
- def print_includes () -> None :
32
+ def get_include_dir () -> str :
34
33
"Prints include flags for dpctl and SyclInterface library"
35
- print ( "-I " + dpctl . get_include () )
34
+ return os . path . join ( _dpctl_dir (), "include" )
36
35
37
36
38
- def print_tensor_includes () -> None :
37
+ def print_include_flags () -> None :
39
38
"Prints include flags for dpctl and SyclInterface library"
39
+ print ("-I " + get_include_dir ())
40
+
41
+
42
+ def get_tensor_include_dir () -> str :
40
43
dpctl_dir = _dpctl_dir ()
41
44
libtensor_dir = os .path .join (dpctl_dir , "tensor" , "libtensor" , "include" )
45
+ return libtensor_dir
46
+
47
+
48
+ def print_tensor_include_flags () -> None :
49
+ "Prints include flags for dpctl and SyclInterface library"
50
+ libtensor_dir = get_tensor_include_dir ()
42
51
print ("-I " + libtensor_dir )
43
52
44
53
45
54
def print_cmake_dir () -> None :
46
55
"Prints directory with FindDpctl.cmake"
47
56
dpctl_dir = _dpctl_dir ()
48
- print (os .path .join (dpctl_dir , "resources" , "cmake" ))
57
+ cmake_dir = os .path .join (dpctl_dir , "resources" , "cmake" )
58
+ print (cmake_dir )
59
+
60
+
61
+ def get_library_dir () -> str :
62
+ dpctl_dir = _dpctl_dir ()
63
+ return dpctl_dir
49
64
50
65
51
66
def print_library () -> None :
52
67
"Prints linker flags for SyclInterface library"
53
- dpctl_dir = _dpctl_dir ()
68
+ dpctl_dir = get_library_dir ()
54
69
plt = platform .platform ()
55
70
ld_flags = "-L " + dpctl_dir
56
71
if plt != "Windows" :
@@ -73,6 +88,8 @@ def _warn_if_any_set(args, li) -> None:
73
88
74
89
75
90
def print_lsplatform (verbosity : int ) -> None :
91
+ import dpctl
92
+
76
93
dpctl .lsplatform (verbosity = verbosity )
77
94
78
95
@@ -84,11 +101,21 @@ def main() -> None:
84
101
action = "store_true" ,
85
102
help = "Include flags for dpctl headers." ,
86
103
)
104
+ parser .add_argument (
105
+ "--include-dir" ,
106
+ action = "store_true" ,
107
+ help = "Path to dpctl include directory." ,
108
+ )
87
109
parser .add_argument (
88
110
"--tensor-includes" ,
89
111
action = "store_true" ,
90
112
help = "Include flags for dpctl libtensor headers." ,
91
113
)
114
+ parser .add_argument (
115
+ "--tensor-include-dir" ,
116
+ action = "store_true" ,
117
+ help = "Path to dpctl libtensor include directory." ,
118
+ )
92
119
parser .add_argument (
93
120
"--cmakedir" ,
94
121
action = "store_true" ,
@@ -99,6 +126,11 @@ def main() -> None:
99
126
action = "store_true" ,
100
127
help = "Linker flags for SyclInterface library." ,
101
128
)
129
+ parser .add_argument (
130
+ "--library-dir" ,
131
+ action = "store_true" ,
132
+ help = "Path to directory containing DPCTLSyclInterface library" ,
133
+ )
102
134
parser .add_argument (
103
135
"-f" ,
104
136
"--full-list" ,
@@ -139,13 +171,19 @@ def main() -> None:
139
171
print_lsplatform (0 )
140
172
return
141
173
if args .includes :
142
- print_includes ()
174
+ print_include_flags ()
175
+ if args .include_dir :
176
+ print (get_include_dir ())
143
177
if args .tensor_includes :
144
- print_tensor_includes ()
178
+ print_tensor_include_flags ()
179
+ if args .tensor_include_dir :
180
+ print (get_tensor_include_dir ())
145
181
if args .cmakedir :
146
182
print_cmake_dir ()
147
183
if args .library :
148
184
print_library ()
185
+ if args .library_dir :
186
+ print (get_library_dir ())
149
187
150
188
151
189
if __name__ == "__main__" :
0 commit comments