Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of RootLessInstall


Ignore:
Timestamp:
01/26/06 15:25:15 (13 years ago)
Author:
dholth@…
Comment:

less root access is good

Legend:

Unmodified
Added
Removed
Modified
  • RootLessInstall

    v1 v1  
     1I prefer to install turbogears and friends in a user's directory. Here's how I do it: 
     2 
     31. ~/.pydistutils.cfg tells distutils where to install things. On OS X mine looks like this: 
     4{{{ 
     5[install] 
     6install_lib = ~/Library/Python/$py_version_short/site-packages 
     7install_data = ~/Library/Python/$py_version_short/site-packages 
     8# install_headers = 
     9install_scripts = ~/bin 
     10}}} 
     11   This tells distutils to install in my home directory, in a directory the *Framework* build (not system Python) of Python for Mac OS X will look for it. 
     12 
     13   (If I install an extension like numarray it wil include headers, and I may be able to use install_headers to put them in ~/include/ . I have not needed this yet.) 
     14 
     15  For Linux I use this instead, in a layout that mimics the usual /usr/lib/python?.?/site-packages/ or /usr/local/lib/python?.?/site-packages/: 
     16 
     17{{{ 
     18[install] 
     19install_lib = ~/lib/python$py_version_short/site-packages 
     20install_data = ~/lib/python$py_version_short/site-packages 
     21install_scripts = ~/bin 
     22}}} 
     23 
     242. I really, really like it that Python on OS X automatically looks in my home directory. No more setting PYTHONPATH=$HOME/lib/python2.4/site-packages/ in my ~/.bash_profile , and it works no matter which version of Python I'm using. Besides, PYTHONPATH=... does not tell python to look for eggs or .pth files. So I edit my /usr/lib/python2.4/site.py to do that: 
     25 
     26{{{ 
     27#!python 
     28def addsitepackages(known_paths): 
     29    """Add site-packages (and possibly site-python) to sys.path""" 
     30    prefixes = [os.path.join(sys.prefix, "local"), sys.prefix] 
     31    if sys.exec_prefix != sys.prefix: 
     32        prefixes.append(os.path.join(sys.exec_prefix, "local")) 
     33    for prefix in prefixes: 
     34        if prefix: 
     35            if sys.platform in ('os2emx', 'riscos'): 
     36                sitedirs = [os.path.join(prefix, "Lib", "site-packages")] 
     37            elif os.sep == '/': 
     38                sitedirs = [os.path.join(prefix, 
     39                                         "lib", 
     40                                         "python" + sys.version[:3], 
     41                                         "site-packages"), 
     42                            os.path.join(prefix, "lib", "site-python")] 
     43                try: 
     44                    # sys.getobjects only available in --with-pydebug build 
     45                    sys.getobjects 
     46                    sitedirs.insert(0, os.path.join(sitedirs[0], 'debug')) 
     47                except AttributeError: 
     48                    pass 
     49            else: 
     50                sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")] 
     51            if sys.platform == 'darwin': 
     52                # for framework builds *only* we add the standard Apple 
     53                # locations. Currently only per-user, but /Library and 
     54                # /Network/Library could be added too 
     55                if 'Python.framework' in prefix: 
     56                    home = os.environ.get('HOME') 
     57                    if home: 
     58                        sitedirs.append( 
     59                            os.path.join(home, 
     60                                         'Library', 
     61                                         'Python', 
     62                                         sys.version[:3], 
     63                                         'site-packages')) 
     64# ADDED LINES HERE 
     65            home = os.environ.get('HOME') 
     66            if home: 
     67                if not home in sitedirs: 
     68                    sitedirs.append(os.path.join(home, 
     69                                                'lib', 
     70                                                'python' + sys.version[:3], 
     71                                                'site-packages')) 
     72 
     73# END OF CHANGE 
     74            for sitedir in sitedirs: 
     75                if os.path.isdir(sitedir): 
     76                    addsitedir(sitedir, known_paths) 
     77    return None 
     78}}}