[Distutils] setuptools acting differently in different shell environments

Chris Maddison c.j.maddison at gmail.com
Wed Aug 6 23:40:47 CEST 2008

Hello Phillip J. Eby,

I am having trouble setting up an installer package on Mac OS 10.5  
that installs setuptools and nose testing for Python 2.5. The  
installer .pkg drops the payload as a temporary file with the  
distributions and runs short postinstall script to do the installation  
of the packages. The scripts I have running are fairly simple:
	cd $2nose_installer_temp
	sh setuptools-0.6c8-py2.5.egg
	easy_install -v nose
	exit 0

When I run the equivalent script as an executable outside of the  
Installer it works great:

postinstall ; exit;
	Corbie:~ chris$ /Users/chris/Documents/PyGraphics/Installer/Nose/ 
resources/postinstall ; exit;
	Processing setuptools-0.6c8-py2.5.egg
	Removing /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
	Copying setuptools-0.6c8-py2.5.egg to /Library/Frameworks/ 
	setuptools 0.6c8 is already the active version in easy-install.pth
	Installing easy_install script to /Library/Frameworks/ 
	Installing easy_install-2.5 script to /Library/Frameworks/ 

	Installed /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
	Processing dependencies for setuptools==0.6c8
	Finished processing dependencies for setuptools==0.6c8
	Searching for nose
	Best match: nose 0.10.3
	Processing nose-0.10.3-py2.5.egg
	nose 0.10.3 is already the active version in easy-install.pth
	Installing nosetests script to /Library/Frameworks/Python.framework/ 
	changing mode of /Library/Frameworks/Python.framework/Versions/2.5/ 
bin/nosetests to 755

	Using /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ 
	Processing dependencies for nose
	Finished processing dependencies for nose

Note that this method has the correct default install location.
/Library/Frameworks/Python.framework/Versions/2.5/bin for scripts and / 
packages for the modules.

When the SAME script is run as part of the installer package I get:

	error: can't create or remove files in install directory
	The following error occurred while trying to add or remove files in the
	installation directory:

	[Errno 2] No such file or directory: '/Library/Python/2.5/site- 

	The installation directory you specified (via --install-dir, -- 
prefix, or
	the distutils default setting) was:


	This directory does not currently exist.  Please create it and try  
again, or
	choose a different installation directory (using the -d or --install- 

It seems like a different default directory is being used and I can't  
figure out why or how to change that. On top of that, when I try  
forcing it in various ways (including .cfg files) suggested in the  
setuptools documentation it says that those directories aren't in the  
python path as my $PYTHONPATH variable is ''. This is strange, because  
sys.path DOES come up with the correct paths.

I tried fooling setuptools by assigning the directory to PYTHONPATH  
and calling the installer then. It manages to get things in the right  
place, but somehow fails to configure itself properly and throws the  
following error:

	Corbie:~ chris$ easy_install nose
	Traceback (most recent call last):
	 File "/Library/Frameworks/Python.framework/Versions/Current/bin/ 
easy_install", line 5, in <module>
	   from pkg_resources import load_entry_point
	 File "/System/Library/Frameworks/Python.framework/Versions/2.5/ 
Extras/lib/python/pkg_resources.py", line 2559, in <module>
	   parse_requirements(__requires__), Environment()
	 File "/System/Library/Frameworks/Python.framework/Versions/2.5/ 
Extras/lib/python/pkg_resources.py", line 518, in resolve
	   raise DistributionNotFound(req)  # XXX put more info here
	pkg_resources.DistributionNotFound: setuptools==0.6c8

I don't understand why Is there some quirk of shells that I don't  
understand, does have it have something to do with different  
environment variables? Is there something in the behaviour of  
setuptools.egg that can explain this? Can you think of a way around it?

Sorry for the massive email! and thanks!
Chris Maddison

More information about the Distutils-SIG mailing list