[Tutor] Set LD_LIBRARY_PATH and equivalents platform-independently

Albert-Jan Roskam fomcl at yahoo.com
Wed Jan 16 22:06:34 CET 2013


Hello,

Is there a builtin function that can set LD_LIBRARY_PATH or equivalents platform-independently? It would be nice use such a function in a setup script. The code below illustrates what I mean, although it's entirely untested.

import sys
import os
def setPath(loc):
    """Set LD_LIBRARY_PATH and equivalents platform-independently"""
    p = {"win": "PATH",
            "lin": "LD_LIBRARY_PATH",
            "solaris": "LD_LIBRARY_PATH",
            "aix": "LIBPATH",
            "darwin":
 "DYLD_LIBRARY_PATH",
            "hpux": "SHLIB_PATH"}
    pf = sys.platform()
    sep = ";" if pf.startswith("win") else ":"
    try:
        os.environ[p[pf]] += (sep + loc)
    except KeyError:
        print "Platform %s not supported" % pf


 
Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 
fresh water system, and public health, what have the Romans ever done for
 us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130116/0b4c38d0/attachment.html>


More information about the Tutor mailing list