[Distutils] Replacing pip.exe with a Python script
ncoghlan at gmail.com
Mon Jul 15 16:32:49 CEST 2013
On 16 July 2013 00:16, Paul Moore <p.f.moore at gmail.com> wrote:
> On 15 July 2013 14:53, Brett Cannon <brett at python.org> wrote:
>> As long as you make sure that sys.path is actually the script location
>> then it will work (other things like .pth files, PYTHONSTARTUP, etc. could
>> have changed things before your script started execution). But realize that
>> a) in Python 3.3 the scripts location will be ./pip.py, not just pip.py, and
>> b) if I get my way all paths will be absolute for __file__, so you will have
>> to just associate '' with os.getcwd() and then search for the proper
>> directory on sys.path.
> OK, that pretty much tells me that this is a bad idea. It's never going to
> be robust enough to work.
Most of the stuff Brett mentioned there shouldn't be relevant for a
directly executed script - doing
sys.path.remove(os.path.dirname(os.path.abspath(__file__)) should be
pretty robust in any scenario.
> I'm amazed actually that there's no way to say
> "don't add the script location to sys.path", even as a command line option.
> It seems like the sort of thing you'd want to make scripts robust, a bit
> like -S and -E.
You'd think that, but then you'd look at getpath.c and run away (or
write something like PEP 432, as I did) :P
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Distutils-SIG