[Pythonmac-SIG] Use Setup.py to install to /usr

Christopher Barker Chris.Barker at noaa.gov
Mon Apr 20 21:15:16 CEST 2009


Pascal Schaedeli wrote:
> Here is the temporary solution I've found for my case. Still looking for 
> better suggestions.

my main suggestion is to "don't do that". A few notes:

1) Ned's right -- DO NOT put stuff in /usr/lib -- use /usr/local/lib, if 
at all.

> To recap, my problem is that by default, "python setup.py install" 
> places all files under 
> "/Library/Frameworks/Python.framework/Versions/Current/bin/".

Right, that's the whole point of distutils -- it installs stuff where it 
belongs for the python the setup,oy is run with. If all else fails, you 
could do:

setup.py build

then hand-copy everything where you want it.

> Unfortunately, sys.prefix is 
> "/Library/Frameworks/Python.framework/Versions/2.5", so the necessary 
> imports in "/usr/lib/python2.5/site-packages" are never found (didn't 
> research further, but this is probably a python compile time option).

it's doing the right thing -- you are trying to do something odd, so 
you'll need to add the extra path yourself.

> I did two manual adjustments:
> 
>     * Moved necessary imports from "/usr/lib/python2.5/site-packages" to
>       "/usr/lib/site-python" to remove the python version specificity.

Bad idea -- version specificity is there for a reason -- 2.x and 2.x+n 
are not necessarily fully compatibile -- definitely not if they have any 
compiled extensions

>       Let me know if there is any way to achieve this with setup.py.

I don't think so.

>     * Added "/usr/lib/site-python" to PYTHONPATH environment variable.

I dont like using PYTHONPATH -- it's global to ALL pythons, which can 
cause trouble.

Rather, I'd use a *.pth file, put in /Library/........./site-packages. 
You can look at wxPython for an example, it uses a *.pth file to add 
paths in /usr/local so that the python,org an Apple pythons can share 
the same wxPython install -- note that those are both 2.5, though.


I'm still not sure what problem you are trying to solve. If you install 
in the usual way, and upgrade form 2.5.x to 2.5.x+1, it will just work.

If you upgrade to 2.6.*, it probably will need a new install of your 
package anyway.

>  in order to be able to upgrade or switch to another
>     python version without affecting the availability of duplicity.

You can install a new python, and keep the old one around, so that it 
will still be able to run old code, so this may be a non-issue anyway.

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list