Skip to content

Commit 780ea31

Browse files
committed
wip
1 parent 014ebfb commit 780ea31

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ jobs:
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232

33+
- name: Install project & dependencies
34+
shell: bash
35+
run: pip install .[dev]
36+
3337
- name: Test
3438
shell: bash
35-
run: |
36-
set -uexo pipefail
37-
python -m venv venv
38-
source venv/bin/activate
39-
pip install .[dev]
40-
pytest ./test
39+
run: pytest ./test
4140

4241
test-windows:
4342
name: Test Windows
@@ -57,8 +56,10 @@ jobs:
5756
with:
5857
python-version: ${{ matrix.python-version }}
5958

59+
- name: Install project & dependencies
60+
shell: powershell
61+
run: pip install '.[dev]'
62+
6063
- name: Test
6164
shell: powershell
62-
run: |
63-
pip install '.[dev]'
64-
pytest ./test
65+
run: pytest -s ./test

autopxd/__init__.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import json
21
import os
32
import platform
43
import re
54
import subprocess
65
import sys
6+
import pathlib
77
import tempfile
88
from importlib.metadata import (
99
version as get_version,
@@ -52,24 +52,40 @@ def _find_cl():
5252
"ARM64": "arm64",
5353
}.get(platform.machine(), "x86")
5454
program_files = os.getenv("ProgramFiles(x86)") or os.getenv("ProgramFiles")
55+
5556
cmd = [
5657
os.path.join(program_files, r"Microsoft Visual Studio\Installer\vswhere.exe"),
5758
"-prerelease",
5859
"-latest",
5960
"-products",
6061
"*",
61-
"-format",
62-
"json",
62+
"-requires",
63+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
64+
"-property",
65+
"installationPath",
66+
# "-format",
67+
# "json",
6368
"-utf8",
64-
"-find",
65-
rf"**\bin\Host{host_platform}\{build_platform}\cl.exe",
69+
# "-find",
70+
# rf"VC\Tools\MSVC\*\bin\Host{host_platform}\{build_platform}\cl.exe",
71+
# rf"**\bin\Host{host_platform}\{build_platform}\cl.exe",
6672
]
6773
try:
68-
return json.loads(subprocess.check_output(cmd, encoding="utf-8"))[-1]
69-
except (OSError, subprocess.CalledProcessError, IndexError) as ex:
74+
install_dir = subprocess.check_output(cmd, encoding="utf-8")
75+
except subprocess.CalledProcessError as ex:
7076
raise RuntimeError("No suitable compiler available") from ex
7177

7278

79+
print("in install dir:", list(pathlib.Path(install_dir).iterdir()))
80+
try:
81+
print("in install dir:", list((pathlib.Path(install_dir) / "VC\Auxiliary\Build").iterdir()))
82+
except Exception as exc:
83+
print("in install dir:", repr(exc))
84+
default_version = (pathlib.Path(install_dir) / "VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt").read_text()
85+
print("=========> default version:", default_version)
86+
87+
return rf"{install_dir}\VC\Tools\MSVC\{default_version}\bin\Host{host_platform}\{build_platform}\cl.exe"
88+
7389
def _preprocess_msvc(code, extra_cpp_args, debug):
7490
fd, source_file = tempfile.mkstemp(suffix=".c")
7591
os.close(fd)

0 commit comments

Comments
 (0)