Skip to content

Commit 7cc1b31

Browse files
committed
More ways to find MSVC and Python
1 parent 59df0c7 commit 7cc1b31

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ docs/sg_execution_times.rst
7373
.tmp
7474
/main.*
7575
/*.mlir
76+
/wheelhouse

python/triton/runtime/build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
4343
# try to avoid setuptools if possible
4444
cc = os.environ.get("CC")
4545
if cc is None:
46+
# Users may not know how to add cl to PATH. Let's do it for them
47+
if os.name == "nt":
48+
msvc_winsdk_inc_dirs, _ = find_msvc_winsdk()
49+
if msvc_winsdk_inc_dirs:
50+
cl_path = msvc_winsdk_inc_dirs[0].replace(r"\include", r"\bin\Hostx64\x64")
51+
os.environ["PATH"] = cl_path + os.pathsep + os.environ["PATH"]
4652
# TODO: support more things here.
4753
cl = shutil.which("cl")
4854
gcc = shutil.which("gcc")
@@ -63,6 +69,9 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
6369
include_dirs = include_dirs + [srcdir, py_include_dir]
6470
if os.name == "nt":
6571
library_dirs += [os.path.join(sysconfig.get_paths()["data"], "libs")]
72+
library_dirs += [os.path.join(os.path.dirname(sys.executable), "libs")]
73+
python_version = sysconfig.get_python_version().replace(".", "")
74+
library_dirs += [fr"C:\Python{python_version}\libs"]
6675
msvc_winsdk_inc_dirs, msvc_winsdk_lib_dirs = find_msvc_winsdk()
6776
include_dirs += msvc_winsdk_inc_dirs
6877
library_dirs += msvc_winsdk_lib_dirs

python/triton/runtime/windows.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def find_msvc_base_vswhere():
3333
"*",
3434
"-requires",
3535
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
36+
"-requires",
37+
"Microsoft.VisualStudio.Component.Windows10SDK",
3638
"-latest",
3739
"-property",
3840
"installationPath",
@@ -49,7 +51,7 @@ def find_msvc_base_vswhere():
4951

5052

5153
def find_msvc_base_envpath():
52-
paths = os.environ.get("PATH", "").split(";")
54+
paths = os.environ.get("PATH", "").split(os.pathsep)
5355
for path in paths:
5456
path = path.replace("/", "\\")
5557
match = re.compile(r".*\\VC\\Tools\\MSVC\\").match(path)

0 commit comments

Comments
 (0)