Setting PYTHONPATH from Makefile

François Pinard pinard at
Fri Dec 2 19:01:18 CET 2005

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

> %.def
>         python

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

>        setenv PYTHONPATH /path/to/stuff
>        python

> but this cannot be done from a Makefile.

Use: %.def
        PYTHONPATH=/path/to/stuff python

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


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

More information about the Python-list mailing list