Skip to content

ONNX Windows build relies on MS Store python, fails with official python launcher #6406

@petewarden

Description

@petewarden

Bug Report

Description

I'm using a Windows Arm-based PC, and the protobuf compilation stage of the pip installation fails with a fatal error. The error indicates that the mypy plugin is failing because the python command isn't found. I believe this is because I'm using the official download from Python dot org that only installs the py executable, which is a launcher for Python. This is listed as the recommended option at docs.python.org/3/using/windows.html, with the Microsoft Store version of python listed as an alternative.

Unfortunately the Store version of Python is still x86-based, so I can't use it on a Windows/Arm PC (technically it can run under emulation but having both installed causes other problems). This also seems like a common setup in the Windows world, regardless of architecture, so it would be nice to support it.

System information

  • Windows 11, ARM
  • ONNX version 1.18
  • Python version: 3.11 (Arm)

Reproduction instructions

git clone https://github.com/onnx/onnx
cd onnx
py setup.py install

This also currently happens with plain pip install onnx.

Expected behavior

I expect the wheel to be built and installed.

Actual behavior

The build fails with the following error messages (trimmed to the most relevant):

  Building Custom Rule C:/Users/pete/onnx/CMakeLists.txt
  Running C++ protocol buffer compiler on C:/Users/pete/onnx/.setuptools-cmake-build/onnx/onn
  x-ml.proto
  Python was not found; run without arguments to install from the Microsoft Store, or disable
   this shortcut from Settings > Manage App Execution Aliases.
  --mypy_out: protoc-gen-mypy: Plugin failed with status code 9009.
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.C 
ppCommon.targets(254,5): error MSB8066: Custom build for 'C:\Users\pete\onnx\.setuptools-cmak 
e-build\CMakeFiles\1cc123d7a88b38a07b5d702bea4bbab7\onnx-ml.proto.rule;C:\Users\pete\onnx\.se 
tuptools-cmake-build\CMakeFiles\1cc123d7a88b38a07b5d702bea4bbab7\onnx-ml.pb.cc.rule;C:\Users\ 
pete\onnx\.setuptools-cmake-build\CMakeFiles\2613932fd8912cf9addf99599c963206\gen_onnx_proto. 
rule;C:\Users\pete\onnx\CMakeLists.txt' exited with code 1. [C:\Users\pete\onnx\.setuptools-c 
make-build\gen_onnx_proto.vcxproj]
Traceback (most recent call last):
...
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Program Files\\CMake\\bin\\cmake.EXE', '--build', '.', '--config', 'Release', '--', '/maxcpucount:12']' returned non-zero exit status 1.

Notes

From my debugging, this is caused by the tools/protoc-gen-mypy.bat batch file calling the python command directly. I will be submitting a patch to try both versions of the command, so that:

python -u "%~dp0\protoc-gen-mypy.py"

becomes

python -u "%~dp0\protoc-gen-mypy.py" || py -u "%~dp0\protoc-gen-mypy.py"

I will submit this as a PR linking back to this issue shortly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions