<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">And what if someone is running on a (perhaps old) Linux distro that does not have python3 installed by default?</div></div></div></blockquote><br class=""></div><div class="">The idea would be to find both but prefer python3, but that’s infeasible inside configure without a separate pre-configure configure to write “configure.py" or virtual-env.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="overflow-wrap: break-word;"><div class=""><pre class="">for pyimpls in python3 python2 python /usr/bin/python /usr/bin/env python ; do</pre></div></div></blockquote></div></div></blockquote><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="overflow-wrap: break-word;"><div class=""><pre class=""><div class="">command -v > /dev/null $pyimpls && exec $pyimpls $0 "$@“</div></pre></div></div></blockquote></div></div></blockquote><div class=""><br class=""></div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">And there  you have, you are trying to check for '/usr/bin/env python', but the shell code you wrote will not work the way you are expecting.</div></div></div></blockquote><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">Also, unless you are running on a funny environment that does not have /usr/bin/ in $PATH, the trial for 'python' should be enough, and the /usr/bin/python /usr/bin/env python look redundant. Am I missing something?</div></div></div></blockquote><div class=""><br class=""></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">This line checks if pyimpls exists in order, and then runs pyimpls ./configure so if any of the previous pyimpls exist then it doesn’t check the rest. The last “ should be a regular quotation mark. If it finds a working python it runs configure once then exits, instead of continuing through the rest of the list.</span></font></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></span></div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">"Echo" ? Are you really running this on Ubuntu? </div></div></div></blockquote><div class=""><br class=""></div>Auto-correct strikes again :(. It is “echo” in my script.<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">BTW, Are you aware of the behavior of `command -v` with shell aliases?</div></div></div></blockquote><div class=""><br class=""></div>No, this is a good point you bring up. I tried using the option -p from the manpage but that also doesn’t seem to skip aliases. Not sure how this can be addressed, seems like escaping pyimpls using \ or ‘ or “ doesn’t fix this either...</div><div class=""><br class=""></div><div class=""></div><blockquote type="cite" class=""><div class="">-p    use a default value for PATH that is guaranteed to find all of</div><div class="">            the standard utilities<br class=""></div></blockquote><div class=""><div class=""><br class=""></div><div class="">To be clear I’m not saying my script is a change petsc should adopt, hence no MR. It is a hack and a half, and likely doesn’t work on some of the other shells as well as a whole host of portability problems. It's more-so to foster discussion, and see if anyone else has a cleaner automatic form.</div><div class=""><br class=""><div class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391</div></div>

</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Apr 17, 2020, at 4:21 PM, Lisandro Dalcin <<a href="mailto:dalcinl@gmail.com" class="">dalcinl@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 17 Apr 2020 at 20:41, Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">Hello All,<div class=""><br class=""></div><div class="">I use an Ubuntu docker image based on jedbrown/mpich-ccache and ran into the following error (Dockerfile attached as well).</div><div class=""><br class=""></div><div class="">If in a user only has python3 installed and not python2 then /usr/bin/python doesn’t exist.</div></div></blockquote><div class=""><br class=""></div><div class="">And what if someone is running on a (perhaps old) Linux distro that does not have python3 installed by default?</div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""> Given that python2 has gone the way of the dodo perhaps petsc should be looking for python3 over python2. This is a somewhat funky but functioning implementation that replaces the shebang line in configure that I have been using to default to python3. I don’t know how portable it is however, I believe “command" is not universally available in every shell?</div><div class=""><pre class="">#!/bin/sh</pre><pre class=""># “”” is comment in python, and : is noop in shell so this configure can be run as ./configure and python2.7 ./configure<br class="">""":"<br class=""><br class=""></pre></div></div></blockquote><div class="">This kind of trickery may be fragile...</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><pre class=""># Find the right python implementation, check by sending it on over to dave<br class="">for pyimpls in python3 python2 python /usr/bin/python /usr/bin/env python ; do</pre></div></div></blockquote><div class=""><br class=""></div><div class="">And there  you have, you are trying to check for '/usr/bin/env python', but the shell code you wrote will not work the way you are expecting.</div><div class="">Also, unless you are running on a funny environment that does not have /usr/bin/ in $PATH, the trial for 'python' should be enough, and the /usr/bin/python /usr/bin/env python look redundant. Am I missing something?</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><pre class=""><div class="">   command -v > /dev/null $pyimpls && exec $pyimpls $0 "$@“</div></pre></div></div></blockquote><div class=""><br class=""></div><div class="">And the last quote the line above is likely wrong, it is an unicode character.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><pre class="">done</pre><pre class=""># Error code in case things go awry </pre><pre class="">Echo “PYTHON NOT FOUND” >2</pre></div></div></blockquote><div class=""><br class=""></div><div class="">"Echo" ? Are you really running this on Ubuntu? </div><div class="">Or you just hacked in on macOS and assumed that it will work everywhere? </div><div class=""><br class=""></div><div class="">BTW, Are you aware of the behavior of `command -v` with shell aliases?</div><div class=""><br class=""></div><div class="">$ alias python=python3<br class="">$ command -v python<br class="">alias python='python3'<br class=""></div></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class="">Lisandro Dalcin<br class="">============<br class="">Research Scientist<br class="">Extreme Computing Research Center (ECRC)<br class="">King Abdullah University of Science and Technology (KAUST)<br class=""><a href="http://ecrc.kaust.edu.sa/" target="_blank" class="">http://ecrc.kaust.edu.sa/</a><br class=""></div></div></div></div>
</div></blockquote></div><br class=""></div></div></div></div></body></html>