Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuptools' discovery of MSVC fails in tox environment #1673

Closed
StefanD986 opened this issue Sep 8, 2020 · 3 comments
Closed

setuptools' discovery of MSVC fails in tox environment #1673

StefanD986 opened this issue Sep 8, 2020 · 3 comments
Labels
bug:normal affects many people or has quite an impact

Comments

@StefanD986
Copy link

Description

I stumbled upon a hard to debug issue when using tox to kick of builds that produce native artifacts using setuptools and Microsoft Visual Studio.

setuptools relies on the presence of some environment variables to locate vswhere.exe which is used to find the path to the msvc toolchain. setuptools.msvc uses the following environment variables to build the path to vswhere.exe

  • ProgramFiles
  • ProgramFiles(x86)

vswhere.exe in turn itself relies on some environment variables to locate the msvc toolchain. I tried and it looks like it only requires the ProgramData environment variable

TLDR

Without the presence of these three environment variables

  • ProgramFiles
  • ProgramFiles(x86)
  • ProgramData

the discovery of the msvc toolchain fails. It is hard to debug because setuptools doesn't give much diagnostic output.

Steps to reproduce

  1. Create a tox.ini with the following content:

    [tox]
    
    [testenv]
    skip_install=True
    commands =
        python -c "import setuptools;print(setuptools.msvc.msvc14_get_vc_env('amd64'))"
  2. Run tox

  3. Observe output

Expected behaviour

I expect the tox run to complete sucessfully

Actual behaviour

Run fails with

python run-test: commands[0] | python -c 'import setuptools;print(setuptools.msvc.msvc14_get_vc_env('"'"'amd64'"'"'))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\stefan\PycharmProjects\tox_msvc_bug\.tox\python\lib\site-packages\setuptools\msvc.py", line 314, in msvc14_get_vc_env
    return _msvc14_get_vc_env(plat_spec)
  File "C:\Users\stefan\PycharmProjects\tox_msvc_bug\.tox\python\lib\site-packages\setuptools\msvc.py", line 269, in _msvc14_get_vc_env
    "Unable to find vcvarsall.bat"
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
ERROR: InvocationError for command 'C:\Users\stefan\PycharmProjects\tox_msvc_bug\.tox\python\Scripts\python.EXE' -c 'import setuptools;print(setuptools.msvc.msvc14_get_vc_env('"'"'amd64'"'"'))

Potential Resolution

There are already a couple of environment variables that are passed through by default. I leave it up to discussion whether this usecase warrants adding the mentioned three variables to the default passthrough on windows platforms.

At the very least it would be nice to document that these environment variables need to be passed through in the tox docs, so that it can be found if users run into this issue and to mention keywords such as cython, vcvarsall.

What do you think?

Additional info

Output of tox -rvv: log.txt

@StefanD986 StefanD986 added the bug:normal affects many people or has quite an impact label Sep 8, 2020
@gaborbernat
Copy link
Member

Sadly this is specific to setuptools, and not something we need in general (e.g. for people using flit). As such I think the solution is for setuptools should offer better error.

@StefanD986
Copy link
Author

Not only setuptools though. Also vswhere doesn't throw any error message that could help.

@gaborbernat
Copy link
Member

gaborbernat commented Sep 8, 2020

What I meant is that it only affectr people calling vswhere 🤷 So it's a tool specific thing, which we generally don't patch within tox.

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact
Projects
None yet
Development

No branches or pull requests

2 participants