[qmtest] running qmtest on bash in cygwin...

Mark Mitchell mark at codesourcery.com
Sun Aug 24 03:07:50 UTC 2003


On Sat, 2003-08-23 at 19:02, Zack Weinberg wrote:
> Mark Mitchell <mark at codesourcery.com> writes:
> 
> > On Sat, 2003-08-23 at 11:11, Zack Weinberg wrote:
> >> I normally hate the #! /usr/bin/env python trick, but this seems like
> >> exactly the case it was meant to handle - where all that is known is
> >> that the python interpreter is somewhere on the user's path.  The Unix
> >> just-unpack-this-tarball distribution could use that, and the
> >> documentation say that you have to put /path/to/qmtest/bin in your
> >> PATH.
> >
> > We actually should not require that.  Some people don't know how to do
> > that, and some people will forget and get the wrong PATH.
> >
> > Now, if we can fancy up the /usr/bin/env trick to get us the Python next
> > to QMTest (if it exists), that would be fine.  We should also preserve
> > the QM_PYTHON/QM_HOME bits from the current shell script.
> >
> > I bet thiis is possible if we get clever enough, somehow.
> 
> It's not clear to me just how much cleverness we need.  On the Unix
> side of things, there are three cases:
> 
> * a good python is installed in a well-known location.
>   #! /usr/bin/python will work.
> 
> * a good python is installed in a strange location, but it's on the path.
>   #! /usr/bin/env python will work.
> 
> * there is no good python interpreter on the system other than the one
>   that got unpacked from the tarball.
> 
>   A small shell script to invoke the python interpreter is necessary.
> 
> It may be possible to do very clever things so that the shell script
> is embedded in qmtest.py -- like this:
> 
> #! /bin/sh
> """:" # null command to sh, beginning of docstring to python
> case "$0" in
>   */*)
>     pydir=`echo "$0" | sed 's|/[^/]*$|/|'` ;;
>   *)
>     pydir=./
> esac
> exec "$pydir"python "$0" "$@" # shell never sees past this line
> """ # end docstring

Oh my, that is clever. :-)
> 

> but frankly I would rather that the just-unpack-the-tarball distro
> continue to contain separate "qmtest" shell wrapper and "qmtest.py"
> real program.  The above hasn't a prayer of working on Windows, and is
> liable to break in other places too.

I think in Windows we do not need to worry about this issue; for
Windows, there are nice tidy Python installers and people seem to have
no problem installing them.

On UNIX, we need to either something like your cleverness above, or have
a separate shell script.

I suppose we could also have a qmtest.py that just had "#! /usr/bin/env
python" and a "qmtest" shell script with more logic.  You could then run
either one, and for an RPM / Debian package you would make a symlink
from "qmtest" to "qmtest.py", instead of installing the qmtest shell
script.

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com




More information about the qmtest mailing list