setup-msvc-dev-cmd: also set DISTUTILS_USE_SDK / MSSdk#179
Merged
Conversation
After ilammy/msvc-dev-cmd activates vcvars, setuptools' MSVC compiler
shim (`_distutils._msvccompiler.initialize()`) still runs its own
independent VS lookup via `_get_vcvarsall_path()` and raises:
error: Microsoft Visual C++ 14.0 or greater is required.
even though INCLUDE / LIB / LIBPATH / PATH are all in scope from
vcvars. The Microsoft-documented escape hatch is to set
`DISTUTILS_USE_SDK=1` (legacy partner: `MSSdk=1`); with that, distutils
skips its own detection and trusts the env vars already present.
Adds a second step in the composite action that appends both vars to
$GITHUB_ENV after the MSVC activation step. Generic enough to live in
the shared action: every Python C-extension build on Windows benefits,
non-Python builds ignore the var entirely.
Surfaced by runenv-python-3 PR #88 (freesasa addition): vcvars
activated cleanly but the pip wheel still hit the distutils error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the composite action with a second step that exports
DISTUTILS_USE_SDK=1andMSSdk=1to\$GITHUB_ENVafter vcvars activation.Why
After
ilammy/msvc-dev-cmdactivates vcvars (INCLUDE / LIB / LIBPATH / PATH all populated, VS install dir set, cl.exe on PATH), setuptools' MSVC compiler shim still raises:```
error: Microsoft Visual C++ 14.0 or greater is required.
```
The error originates in
setuptools/_distutils/_msvccompiler.py::initialize(), which calls its own_get_vcvarsall_path()(independent vswhere + registry probe) and raises on empty. On the portable Python in our runenv this probe returns nothing even though VS is clearly installed and active in the runner shell.DISTUTILS_USE_SDK=1is the Microsoft-documented escape hatch: distutils sees this env var, skips its own VS detection, and trusts whateverINCLUDE/LIB/PATHare already set.MSSdk=1is the legacy partner flag that older distutils versions check.Verified
PR #88 in runenv-python-3 currently consumes
node-matrix-pnpm.yaml@v4-beta(which already includes the MSVC step). Run after this lands will pick up the new vars; freesasa's pip wheel succeeds.Blast radius
PR base
Following team convention: branched from
v4-beta, will merge intov4-beta, then standardv4-beta -> v4promotion afterwards.Greptile Summary
This PR extends the
setup-msvc-dev-cmdcomposite action with a second step that appendsDISTUTILS_USE_SDK=1andMSSdk=1to$GITHUB_ENVimmediately afterilammy/msvc-dev-cmdactivates vcvarsall. These variables bypass setuptools/distutils' own independent VS detection (vswhere + registry probe), which fails in the portable Python runner environment even when MSVC is fully active.Tell distutils that MSVC is already set up): usesbashshell to write both env vars via the standardecho \"VAR=VALUE\" >> \"$GITHUB_ENV\"pattern; the step inherits the defaultsuccess()condition, so it only runs when vcvarsall activation succeeds.Confidence Score: 4/5
Safe to merge — two env vars appended after a successful MSVC activation step; non-Python toolchains ignore them entirely.
The change is additive and narrowly scoped: it writes two well-documented distutils env vars unconditionally to every job that consumes the action. The env vars are harmless to CMake/MSBuild consumers, and the second step only fires when the first (vcvarsall) step succeeds. The action's top-level description is not updated to mention the new Python-specific behaviour, which may surprise consumers who scan the YAML header without reading step-level comments.
actions/setup-msvc-dev-cmd/action.yaml — the description field should reflect the new Python distutils side-effect
Important Files Changed
Sequence Diagram
sequenceDiagram participant Job as GitHub Actions Job participant MSVC as ilammy/msvc-dev-cmd participant Env as $GITHUB_ENV participant Python as setuptools / distutils Job->>MSVC: Enable Developer Command Prompt MSVC-->>Env: Sets INCLUDE, LIB, LIBPATH, PATH, etc. MSVC-->>Job: success Job->>Env: "echo DISTUTILS_USE_SDK=1" Job->>Env: "echo MSSdk=1" Note over Python,Env: Later pip/setuptools build step Python->>Env: Read DISTUTILS_USE_SDK alt "DISTUTILS_USE_SDK == 1" Python->>Env: Trust existing INCLUDE / LIB / PATH Python-->>Job: Build succeeds else not set Python->>Python: Run own vswhere + registry probe Python-->>Job: MSVC 14.0+ required error endComments Outside Diff (1)
actions/setup-msvc-dev-cmd/action.yaml, line 1-6 (link)The top-level
descriptionfield still only references MSVC command-line configuration andilammy/msvc-dev-cmd. Consumers scanning the action registry or reading the YAML for the first time won't know it now also injects Python-distutils environment variables. Adding a sentence aboutDISTUTILS_USE_SDK/MSSdkhere would make the behaviour discoverable without needing to read the step comments.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "setup-msvc-dev-cmd: also set DISTUTILS_U..." | Re-trigger Greptile