<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=""><blockquote type="cite" class="">command -v $pyimpls > /dev/null && echo Using: $pyimpl && exec $pyimpl "$@"</blockquote><div class=""><br class=""></div>As Lisandro noted below, command -v would have to be swapped out since it also picks up aliases and doesn’t error out.<div class=""><br class=""></div><div class="">Also shouldn’t the final command sequence be “$pyimpl $0 $@“ so that it runs the configure script it was passed?<br class=""><div class=""><br class=""></div><div class=""><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""></div><blockquote type="cite" class=""><blockquote type="cite" class=""><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">BTW, Are you aware of the behavior of `command -v` with shell aliases?</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">$ alias python=python3<br class="">$ command -v python<br class="">alias python='python3'</div></blockquote></blockquote><div class=""><br 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 18, 2020, at 1:53 PM, Satish Balay <<a href="mailto:balay@mcs.anl.gov" class="">balay@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I guess this is an alternate way to implement this logic..<br class=""><br class="">diff --git a/configure b/configure<br class="">index 4538314871..8dddfed05d 100755<br class="">--- a/configure<br class="">+++ b/configure<br class="">@@ -1,4 +1,4 @@<br class="">-#!/usr/bin/env python<br class="">+#!./python-detect<br class=""><br class=""> import sys, os<br class=""><br class="">diff --git a/python-detect b/python-detect<br class="">new file mode 100755<br class="">index 0000000000..1fdfe795c8<br class="">--- /dev/null<br class="">+++ b/python-detect<br class="">@@ -0,0 +1,6 @@<br class="">+#!/bin/sh<br class="">+for pyimpl in python3 python2 python ; do<br class="">+   command -v $pyimpls > /dev/null && echo Using: $pyimpl && exec $pyimpl "$@"<br class="">+done<br class="">+echo “Could not locate python! Please have python3 python2 or python in PATH<br class="">+exit 2<br class=""><br class=""><br class="">Satish<br class=""><br class="">On Fri, 17 Apr 2020, Jacob Faibussowitsch wrote:<br class=""><br class=""><blockquote type="cite" class="">Hello All,<br class=""><br class="">I use an Ubuntu docker image based on jedbrown/mpich-ccache and ran into the following error (Dockerfile attached as well).<br class=""><br class="">If in a user only has python3 installed and not python2 then /usr/bin/python doesn’t exist. 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?<br class=""><br class="">#!/bin/sh<br class=""><br 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=""># 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<br class="">   command -v > /dev/null $pyimpls && exec $pyimpls $0 "$@“<br class="">done<br class=""><br class=""># Error code in case things go awry<br class=""><br class="">Echo “PYTHON NOT FOUND” >2<br class=""><br class="">exit 2<br class=""><br class="">":"""<br class=""><br class="">if sys.version_info < (2,6) or (sys.version_info >= (3,0) and sys.version_info < (3,4)):<br class="">  print('************************************************************************')<br class="">  print('*      Python version 2.6+ or 3.4+ is required to run ./configure      *')<br class="">  print('*         Try: "python2.7 ./configure" or "python3 ./configure"        *')<br class="">  print('************************************************************************')<br class="">  sys.exit(4)<br class=""><br class="">sys.path.insert(0, os.path.abspath('config'))<br class="">import configure<br class="">configure.petsc_configure([])<br class=""><br class=""><br class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""><br class=""><br class=""></blockquote></div></div></blockquote></div><br class=""></div></div></div></body></html>