Setting PYTHONPATH from Makefile

Inyeol Lee inyeol.lee at siliconimage.com
Fri Dec 2 20:23:02 EST 2005


On Fri, Dec 02, 2005 at 08:10:41PM -0500, Mike Meyer wrote:
> Inyeol Lee <inyeol.lee at siliconimage.com> writes:
> > On Fri, Dec 02, 2005 at 07:33:20PM -0500, Mike Meyer wrote:
> >> > 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
> > How about using python -m?
> > Assuming Make uses Bourne shell,
> >
> > %.abc: %.def
> >     PYTHONPATH=/path/to/stuff:/path/to/another python -m myscript
> 
> That will break __name__ (at least with 2.4.2). Whether or not it
> matters will depend on the script.
> 

$ python -V
Python 2.4.2
$ cat foo/bar.py 
print __name__
$ (cd foo; python bar.py)
__main__
$ PYTHONPATH=$PWD/foo python -m bar
__main__
$ 


Am I missing something? I don't see any issue regarding __name__.

-- Inyeol Lee



More information about the Python-list mailing list