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

Ned Deily nad at acm.org
Mon Apr 20 04:52:20 CEST 2009


In article 
<2aa16a690904191603p141f59aet51c1dcf3410e2fcc at mail.gmail.com>,
 Pascal Schaedeli <pascals_sub at pobox.com> wrote:
> Here is the temporary solution I've found for my case. Still looking for
> better suggestions.
> To recap, my problem is that by default, "python setup.py install" places
> all files under
> "/Library/Frameworks/Python.framework/Versions/Current/bin/". When I added
> "--prefix=/usr" as a setup.py argument, the main executable is correctly
> located under /usr/bin, but many python files to be imported are copied to a
> newly created directory "/usr/lib/python2.5/site-packages". Then, when
> python starts, the site module (http://docs.python.org/library/site.html)
> adds the concatenation of sys.prefix and lib/python2.5/site-packages as well
> as lib/site-python and adds those combinations to the path.
> 
> 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).
> 
> 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. Let me 
>    know
>    if there is any way to achieve this with setup.py.
>    - Added "/usr/lib/site-python" to PYTHONPATH environment variable.

In general, you should not be installing anything into /usr/bin or 
/usr/lib; the contents of those directories are managed by OS X.  
/usr/local/ would be OK, though.

No matter where duplicity gets installed, there will still be a 
dependency on a python interpreter version.  If you are using python.org 
installers, the standard place for site-packages is within the 
framework.  If you need to upgrade that python version, you can easily 
re-install duplicity and its dependencies or you can move them out of 
the way when you perform a python upgrade.  If you use the 10.5 
Apple-supplied python, the site packages are installed in 
/Library/Python/Frameworks/ and shouldn't be disturbed by an Apple 
10.5.x upgrade.  You could also install a Macports python to use as your 
"production" python; macports also includes a duplicity port, though no 
idea how well it is maintained.  Or, in theory, you could use virtualenv 
with any of those python versions to create a "frozen" virtual python 
environment and install duplicity there.

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list