Message87665
I hit exactly this same problem today trying to customize sys.path. We
conventionally use .pth file under site-packages to add our custom
library paths, but this is not convenient in development while switching
between branches/checkout directories, so I would like something like
this to work:
def updateADPath(dir):
""" Determine the root of the AD code given the specific sub
directory and update sys.path. Returns 0 on success. """
pass
# First try the current directory. If not found, try the main script's
directory.
if updateADPath(os.getcwd()):
# If not absolute path, the script is in the current dir anyway,
which we have already tried.
if len(sys.argv) > 0 and sys.argv[0] != '-c' and
os.path.isabs(sys.argv[0]):
updateADPath(os.path.split(sys.argv[0])[0])
It works quite well as long as I run when the CWD is with in the branch
directory, but if it is outside (such as when running from a windows
shortcut) there is no way to determine the root. Is there an alternative
means to access the raw command-line arguments, it would help me provide
a partial workaround for this problem. |
|
Date |
User |
Action |
Args |
2009-05-13 01:36:45 | haridsv | set | recipients:
+ haridsv, brett.cannon, hvendelbo |
2009-05-13 01:36:45 | haridsv | set | messageid: <1242178605.49.0.565796062158.issue2972@psf.upfronthosting.co.za> |
2009-05-13 01:36:44 | haridsv | link | issue2972 messages |
2009-05-13 01:36:43 | haridsv | create | |
|