<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54906>54906</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir python] Python development auto-detection is unreliable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stellaraccident
</td>
</tr>
</table>
<pre>
I just spent another 20 minutes trying to figure out why Python auto-detection was failing for the standalone example and pin-pointed it to some bad state in a cached build directory. This is a continuation of the trend where the CMake FindPython macros are just broken for complicated projects and I personally don't think that they can be fixed at this point barring a rewrite.
This is unfortunate because what we are using it for us *really* simple and can be accomplished with ~a dozen lines of a really straight-forward Python script that introspects the running interpreter vis `sysconfig`. I know this because this is what I had in the pre-cursor to the MLIR Python API out of tree, but when upstreaming, I thought I was doing the right thing by switching to something more standard. I am quite confident that I could write something robust here that would also be a lot more debuggable and adaptable if not trying to spelunk through the decade of Python2/3/whatever CMake autoconfig tragedy.
In order to not cause more thrash than necessary, I propose adding this under yet another temporary flag for auto-detecting Python. We put a bit of mileage on it, and if it works, we just drop the old escalation of hacks that have accumulated in MLIRDetectPythonEnv.cmake. Seems low risk to try. Any objections?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxVVFlv2zgQ_jXyyyCG4iNeP_gh2zSAgRYougvsMyWOJMYUqeURV_vr9xvKblPAB3Vw5ruGjdfz6UxvOSaKE7tEyvk0cKBNTaNxOXGkFGbjekqeOtPnwORzousw07c5Dd6Rysk_aE7cJoPLq4rUKWNlT-cDoRzFpJxW1jsm_qHGyTIaaZqMe5i8cYk1mSQdoh-ZGqVlR2IyqE6tage80GRjNWkT0MeHeU1_DyYSPnjDuwSwqvT3XWmZAqPDFVy4XH_6qi5Mr8bpG-xRtcFjN54X_k3wF3YFcusB0bRKcE3Bv6FjLIDPNHGI3ilrZ9LeVZsDYA_GXfCrZMkz8DpqG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