Setting PYTHONPATH from Makefile

Mike Meyer mwm at mired.org
Fri Dec 2 19:33:20 EST 2005


"pinkfloydhomer at gmail.com" <pinkfloydhomer at gmail.com> writes:
> I have a Makefile target that uses a python script, like:
>
> %.abc: %.def
>         python myscript.py
>
> The problem is that myscript.py and some modules that myscript.py
> imports are not in the current directory, but in another place in the
> filesystem, say, /path/to/stuff. If this was a tcsh script, I would
> just do:
>
>        setenv PYTHONPATH /path/to/stuff
>        python myscript.py

And that still wouldn't work, because you said that myscript.py wasn't
in the current directory either.

> but this cannot be done from a Makefile. So what do I do? Is there
> another way to set the PYTHONPATH? Like giving an option to "python"
> itself? Or?

No, you can't. You have to tweak the makefile. Try:

%.abc: %.def
       (cd /path/to/myscripts/dir; python myscript.py)


N.B. - this probably depends on both the system and the make you're
using.

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list