Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
- name: Build Triton
run: |
cd ${{ env.NEW_WORKSPACE }}

cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
if ($_ -match '^(.*?)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
Comment on lines +49 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also work (and simpler).

Suggested change
cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set' | ForEach-Object {
if ($_ -match '^(.*?)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoke-BatchFile is a non-standard extension which is not installed by default. I actually like that Anatoly found a solution that doesn't require installing it, we may want to use it instead. Also save environment variables into GITHUB_ENV for further steps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We install a lot of custom stuff to the runner image, including support for Invoke-BatchFile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rolled back the last changes and am going to merge the version that was approved. Feel free to ask me to finish something, I can do it in a separate pull request.


cd python
pip install -U wheel pybind11 certifi cython cmake setuptools>=65.6.1
python -m certifi
Expand Down
52 changes: 0 additions & 52 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,56 +103,6 @@ def copy_externals():
]


def find_vswhere():
program_files = os.environ.get("ProgramFiles(x86)", "C:\\Program Files (x86)")
vswhere_path = Path(program_files) / "Microsoft Visual Studio" / "Installer" / "vswhere.exe"
if vswhere_path.exists():
return vswhere_path
return None


def find_visual_studio(version_ranges):
vswhere = find_vswhere()
if not vswhere:
raise FileNotFoundError("vswhere.exe not found.")

for version_range in version_ranges:
command = [
str(vswhere), "-version", version_range, "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-products", "*", "-property", "installationPath", "-prerelease"
]

try:
output = subprocess.check_output(command, text=True).strip()
if output:
return output.split("\n")[0]
except subprocess.CalledProcessError:
continue

return None


def set_env_vars(vs_path, arch="x64"):
vcvarsall_path = Path(vs_path) / "VC" / "Auxiliary" / "Build" / "vcvarsall.bat"
if not vcvarsall_path.exists():
raise FileNotFoundError(f"vcvarsall.bat not found in expected path: {vcvarsall_path}")

command = ["call", vcvarsall_path, arch, "&&", "set"]
output = subprocess.check_output(command, shell=True, text=True)

for line in output.splitlines():
if '=' in line:
var, value = line.split('=', 1)
os.environ[var] = value


def initialize_visual_studio_env(version_ranges, arch="x64"):
vs_path = find_visual_studio(version_ranges)
if not vs_path:
raise EnvironmentError("Visual Studio not found in specified version ranges.")
set_env_vars(vs_path, arch)


# Taken from https://github.com/pytorch/pytorch/blob/master/tools/setup_helpers/env.py
def check_env_flag(name: str, default: str = "") -> bool:
return os.getenv(name, default).upper() in ["ON", "1", "YES", "TRUE", "Y"]
Expand Down Expand Up @@ -475,8 +425,6 @@ def get_proton_cmake_args(self):
def build_extension(self, ext):
lit_dir = shutil.which('lit')
ninja_dir = shutil.which('ninja')
if platform.system() == "Windows":
initialize_visual_studio_env(["[17.0,18.0)", "[16.0,17.0)"])
# lit is used by the test suite
thirdparty_cmake_args = get_thirdparty_packages([get_llvm_package_info()])
thirdparty_cmake_args += self.get_pybind11_cmake_args()
Expand Down
55 changes: 0 additions & 55 deletions python/triton/runtime/CLFinder.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/triton/runtime/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import subprocess
import setuptools
import platform
from .CLFinder import initialize_visual_studio_env


def is_xpu():
Expand Down Expand Up @@ -60,7 +59,6 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries, extra_compi
cc = gcc if gcc is not None else clang
if platform.system() == "Windows":
cc = "cl"
initialize_visual_studio_env(["[17.0,18.0)", "[16.0,17.0)"])
if cc is None:
raise RuntimeError("Failed to find C compiler. Please specify via CC environment variable.")
# This function was renamed and made public in Python 3.10
Expand Down