[issue2972] arguments and default path not set in site.py and sitecustomize.py
Hari Krishna Dara
report at bugs.python.org
Wed May 13 03:36:45 CEST 2009
Hari Krishna Dara <haridara at gmail.com> added the comment:
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.
----------
nosy: +haridsv
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2972>
_______________________________________
More information about the Python-bugs-list
mailing list