-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[mlir] Inconsistency when searching for Python3 and Python #126162
Comments
@llvm/issue-subscribers-mlir Author: Dmitry Babokin (dbabokin)
I've just stepped into a trap caused by these lines of CMake code:
https://github.com/llvm/llvm-project/blob/b7279ed5b3ae3e7b0fd61e0f08c86fb1958f0b6f/mlir/cmake/modules/MLIRDetectPythonEnv.cmake#L25-L28
I was building torch-mlir on my Macbook and I was following the official build guidelines. On my system I have Python3.13 and Python3.11, but I was running in VirtualEnv with Python3.11 enabled. And CMake behaved really weirdly. It looked for Python three times, every time it was looking for Then if I was rerunning
Running Debugging the problem I found out that the root cause was that I passed So that resolved my problem and in this sense it was a user error. But I think it really makes sense to check that Tagging @makslevental who is the last one who touched |
This thing is a constant source of frustration (which is why that CMake section is already hairy enough). I don't think anyone has any urge to try to root cause it so personally I think layering more bandaids on it is absolutely fine (i.e., I'll take that PR if you send it). |
See #126329 |
I've just stepped into a trap caused by these lines of CMake code:
llvm-project/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
Lines 25 to 28 in b7279ed
I was building torch-mlir on my Macbook and I was following the official build guidelines. On my system I have Python3.13 and Python3.11, but I was running in VirtualEnv with Python3.11 enabled. And CMake behaved really weirdly. It looked for Python three times, every time it was looking for
Python3
twice and once forPython
(that's expected). While it consistently foundPython3
with version3.11
, thePython
was found as3.11
at first, but then as3.13
(really unexpected).Then if I was rerunning
cmake
with exactly the same command line (which succeeded on the first pass), it crashed with the following message:Running
cmake
again was successful, one more time - failing.Debugging the problem I found out that the root cause was that I passed
-DPython3_FIND_VIRTUALENV=ONLY
to CMake, but not-DPython_FIND_VIRTUALENV=ONLY
!!!So that resolved my problem and in this sense it was a user error. But I think it really makes sense to check that
Python3_FIND_VIRTUALENV
andPython_FIND_VIRTUALENV
are defined (or not defined) in the same way and warn user otherwise.Tagging @makslevental who is the last one who touched
find_package(Python ...)
code.The text was updated successfully, but these errors were encountered: