setuptools acting differently in different shell environments
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: #!/bin/sh 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: /Users/chris/Documents/PyGraphics/Installer/Nose/resources/ 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/ python2.5/site-packages/setuptools-0.6c8-py2.5.egg Copying setuptools-0.6c8-py2.5.egg to /Library/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/site-packages setuptools 0.6c8 is already the active version in easy-install.pth Installing easy_install script to /Library/Frameworks/ Python.framework/Versions/2.5/bin Installing easy_install-2.5 script to /Library/Frameworks/ Python.framework/Versions/2.5/bin Installed /Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/setuptools-0.6c8-py2.5.egg 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/ Versions/2.5/bin 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/ site-packages/nose-0.10.3-py2.5.egg 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 / Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- 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- packages/test-easy-install-4156.write-test' The installation directory you specified (via --install-dir, -- prefix, or the distutils default setting) was: /Library/Python/2.5/site-packages/ This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install- dir option). 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
At 02:40 PM 8/6/2008 -0700, Chris Maddison wrote:
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.
It sounds like you're using different versions of Python in the two environments. That would explain everything, pretty much. It also sounds like a very Mac-specific issue. Probably the simplest workaround would be to replace the "sh setuptools.egg" bit with an inline version of the egg's shell code, that hardcodes the path to the specific version of Python you want to use.
Phillip J. Eby wrote:
At 02:40 PM 8/6/2008 -0700, Chris Maddison wrote:
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.
It sounds like you're using different versions of Python in the two environments. That would explain everything, pretty much. It also sounds like a very Mac-specific issue.
And if you suspect this, check with "python -c 'import sys; print sys.executable'". "which" sometimes lies. -- Ian Bicking : ianb@colorstudy.com : http://blog.ianbicking.org
participants (3)
-
Chris Maddison
-
Ian Bicking
-
Phillip J. Eby