[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] autoconf: fix handling absolute $PYTHON path



Marek Marczykowski-Górecki writes ("Re: [PATCH] autoconf: fix handling absolute 
$PYTHON path"):
> On Tue, Jul 27, 2021 at 02:56:01PM +0100, Ian Jackson wrote:
> > I'm not sure this logic is right.  I haven't looked at this area in
> > detail but it seems confusing to me.  I don't quite understand why the
> > preexisting code calls AC_CHECK_PROG followed by AC_PATH_PROG.
> 
> I think it tires to get absolute path into $PYTHON, also in case it was
> autodetected (the AC_CHECK_PROGS call). Which I think it another place
> that is too magic (see below). I'll try to simplify it further.
> 
> > I also don't understand why we ever need an absolute path for
> > $PYTHON-config.  Why don't we just rely on PATH lookups when in invoke
> > it ?
> 
> This is a good question. I tried to preserve AC_PATH_PROG to keep
> existence check there, but that's rather misused.

The existence check is probably helpful to avoid a late failure.

> > > --- a/tools/configure.ac
> > > +++ b/tools/configure.ac
> > > @@ -368,7 +368,6 @@ AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], 
> > > [python3 python python2], e
> > >  AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter 
> > > found])])
> > >  AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], 
> > > [$PYTHON])])
> > >  PYTHONPATH=$PYTHON
> > > -PYTHON=`basename $PYTHONPATH`
> > 
> > I'm not sure this is right.  I think we sometimes try to look at
> > PTYHON to see if we should be doing python-3-like things or
> > python-2-like things, and maybe that logic depends on PYTHON just
> > being the basename.

I remembered what I was thinking of and it isn't in xen.git, it's in a
personal project.  I grepped xen.git for PYTHON and python2 and
python3 and didn't find anything that behaves like I was suggesting.

> If that's the case, those should be fixed too. PYTHON variable can
> accept way more possibilities than just "python" and "python3". And
> furthermore "python", depending on distribution, may point at python2 or
> python3.
> That said, few test builds work with this change, so it's unlikely
> something important relies on PYTHON being just the basename.

I think we do, however, need to rely on it being suitable for having
`-config` appended, to find the dev build runes etc.

The last change to this area was by me in
  9caed751db9110c785fd6b1def89d808baa1d907
  tools/configure: Allow specifying python to be found from path

My previous self doesn't seem to have left any notes about why I felt
it necessary to still split the thing back into a "directory and
executable name".  Also that text is wrong since the directory does
not seem to be extracted at all.  I surmise that I just did that
because the existing code did it, and assumed that womething somewhere
else wanted it.

Perhaps this was some support for build arrangements which predate
python-config ?  Those are surely doomed by now.

> Actually, the only place that needs full path to python, is filling
> shebang. Everything else can rely on $PATH and use whatever is given in
> $PYTHON (either absolute or just the basename). Especially, there is no
> place that needs absolute python-config path, if $PYTHON points just at
> the base name.

Right.

Ian.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.