This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author haridsv
Recipients brett.cannon, haridsv, hvendelbo
Date 2009-05-13.01:36:42
SpamBayes Score 1.8865727e-08
Marked as misclassified No
Message-id <1242178605.49.0.565796062158.issue2972@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-05-13 01:36:45haridsvsetrecipients: + haridsv, brett.cannon, hvendelbo
2009-05-13 01:36:45haridsvsetmessageid: <1242178605.49.0.565796062158.issue2972@psf.upfronthosting.co.za>
2009-05-13 01:36:44haridsvlinkissue2972 messages
2009-05-13 01:36:43haridsvcreate