Nick Coghlan wrote:
The details of the sys.path manipulation at program startup are
documented here:
http://docs.python.org/using/cmdline.html#command-line
The directory prepended to sys.path is based on the code executed by the
command line.
It's more subtle than that though...
The OP in http://bugs.python.org/issue1734860 is being bitten by the
same expectation that I am: sitecustomize.py should be found somewhere
on the sys.path present at the start of the script/module/command/etc
being executed. (The bug referenced in that report makes things worse,
because this used to work, at least on Windows ;-) )
The problem is that site.py (and therefore sitecustomize.py) is imported
early in main.c on line 516 as part of Py_Initialize(), but the path of
the current script only gets added later on in RunMainFromImporter
called on line 569.
Strictly speaking, the docs at http://docs.python.org/library/site.html
aren't lying, but it takes an understanding of when site.py is imported
that isn't available to anyone who doesn't read C to know why a path
that is present on sys.path when the user's script starts isn't being
searched for sitecustomize.py
What do people feel about this?
At the very least, I'd like to add a warning box in site.html to explain
why sitecustomize might not be found where people expect.
I'd *like* to have the paths be the same for site.py as they are for the
subsequent code that's executed, but would that make too much of a mess
of main.c and runpython.c?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com