Setting PYTHONPATH from Makefile

François Pinard pinard at iro.umontreal.ca
Fri Dec 2 19:01:18 CET 2005


[pinkfloydhomer at gmail.com]
> I have a Makefile target that uses a python script, like:

> %.abc: %.def
>         python myscript.py

> If this was a tcsh script, I would just do:

>        setenv PYTHONPATH /path/to/stuff
>        python myscript.py

> but this cannot be done from a Makefile.

Use:

%.abc: %.def
        PYTHONPATH=/path/to/stuff python myscript.py

In fact, within Make or outside Make, for any shell command, you may 
write:

    VAR1=VALUE1 VAR2=VALUE2 ... COMMAND ARGUMENTS

so temporarily setting VAR1, VAR2... in the environment for the duration 
of COMMAND only.  This is a useful feature of the shell.

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the Python-list mailing list