[Top][All Lists]

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

Re: Setting python interpreter in scripts

From: Eric Blake
Subject: Re: Setting python interpreter in scripts
Date: Wed, 31 Jul 2013 15:39:49 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/31/2013 03:23 PM, Adam Mercer wrote:
> Hi
> In one of our projects we have several python scripts that we need to
> ensure that the python interpreter is set to the one found by
> configure. At the moment we are doing this by having the interpreter
> set to @PYTHONPROG@ and then using the following rule:
> python_config.sed:
>   @-rm -f python_config.sed
>   @echo "address@hidden@address@hidden@+g" >> python_config.sed

This is an unsafe sed script, if configure found a version of PYTHON
that includes a '+' in its (possibly absolute) name.  Better would be
using something that has to be quoted for use in the shell, as that is
less likely to be the name of any PYTHON directory the user desires to
use, as in 's|@PYTHONPROG@|@PYTHON@|'.

> script: $(srcdir)/ python_config.sed
>   $(AM_V_GEN)sed -f python_config.sed $(srcdir)/ > script
>   @chmod +x script
> This has always seemed like an ugly hack to me, especially as the
> script is in the VCS as instead of the actual name.
> Can anyone offer any more sane ways of accomplishing this?

Why not add this to your

AC_CONFIG_FILES([script], [chmod +x script])

prior to the AC_OUTPUT, so that running config.status (as part of the
configure script itself) will automatically replace @PYTHON@ from the template into the output script without you repeating the work
in your makefile.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]