[Distutils] EasyInstall: Issue: wrapper script weirdness

Ryan Tomayko rtomayko at gmail.com
Mon Jun 20 18:35:33 CEST 2005

On Jun 20, 2005, at 11:20 AM, Phillip J. Eby wrote:
> At 11:32 PM 6/19/2005 -0400, Ryan Tomayko wrote:
>> It would probably be best to make py.lib's scripts a little less
>> complex (installing _findpy.py as a script doesn't strike me as an
>> elegant approach).
> I think there's probably a trivial fix - add _findpy to the  
> 'py_modules' list in setup.py, and remove it from 'scripts'.

That does it. I'm not sure there's any down side to this approach so  
I'll propose it to the maintainers.

>> On the other hand, the way setuptools lays out
>> sys.path when wrapper scripts are invoked results in unexpected
>> behavior. If a script is importing a module it believes to be in the
>> same directory, it is definitely not wanting to import the wrapper
>> version. It may be best to remove the wrapper script directory from
>> sys.path entirely or at least push it back behind the PKG-INFO/  
>> scripts directory. I can't think of a single scenario where a wrapped
>> script would want to import another wrapper.
> Well, it does occur to me that the part of EasyInstall that's  
> broken here is the assumption that a wrapper will be run as  
> __main__.  What probably ought to happen is that if you do import  
> something as a wrapper script, is that it ought to either:
> 1. work (by running the script in whatever module it is)
> 2. barf (and tell you what package is broken)
> 3. punt (by trying to replace itself with a module of the same name  
> later on the path)
> Unfortunately I can think of scenarios where each of these is the  
> "right thing" to do.  #1 should work for py.test, but #3 makes more  
> sense if the importee is not from the same package as the importer.
> My general inclination for now is to fix py.test and see if the  
> issue comes up with anything else.  It's easier to get a line on  
> the right fix for something when you have more than one example to  
> generalize from.  :)


Ryan Tomayko
                                  rtomayko at gmail.com

More information about the Distutils-SIG mailing list