pypa / distutils

distutils as found in cpython
MIT License
45 stars 67 forks source link

`distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat`. #118

Closed jaraco closed 2 years ago

jaraco commented 2 years ago

The error in the CI seems to be unrelated to the change: distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat.

Maybe this error is also related to GitHub's update to windows-2022?

Refs:

Originally posted by @abravalheri in https://github.com/pypa/distutils/issues/116#issuecomment-1048697265

jaraco commented 2 years ago

This issue is also affecting Setuptools build suite.

isuruf commented 2 years ago

Looks like tox is not passing through PROGRAMFILES(x86) env variable and because of that distutils falls back to a vs2015 style registry key lookup and this registry key is not set in windows-2022 image.

isuruf commented 2 years ago

See https://github.com/tox-dev/tox/issues/1673

abravalheri commented 2 years ago

Hi @isuruf, thank you very much for the tip. I tried explicitly passing PROGRAMFILES and PROGRAMFILES(x86) via passenv configuration in tox.ini, but that does not seem to solve the problem: https://github.com/pypa/setuptools/pull/3168/commits/89581b4b23fc74faa721843372c0fc320dcff60d

isuruf commented 2 years ago

Looks like vswhere.exe needs PROGRAMDATA env variable passed through.

jaraco commented 2 years ago

This workaround is great. Thanks for making it. I'm hoping that https://github.com/tox-dev/tox/issues/2382 will help fix the issue at its core (rather than requiring every windows compiled package to patch tox config). If tox doesn't accept a solution, it might be necessary for Setuptools to work around the broken environment by digging into the registry and reconstructing the system environment.