On Aug 9, 2014, at 1:41 PM, Paul Moore
wrote: On 9 August 2014 17:02, Donald Stufft
wrote: To be clear, the direct reference is mostly for use in the install_requires. On the CLI pip can still just take a path to a file or whatever. This feature is intended to replace dependency_links in a way that people can use them for private packages but that they won't be allowed on PyPI or the like.
Understood. I'd still like an explicit pointer to the canonical URL details tools should (or must?) use. See http://en.wikipedia.org/wiki/File_URI_scheme (specifically the "Windows" sections) for why I'm bothered - specifically the quote "Here are *some* examples which *may* be accepted by some applications" (emphasis mine).
I'd be more than happy if the spec was just "tools will use XXX from the Python standard library. But note (the first 4 are the supposedly acceptable URLs from that Wikipedia article):
py Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
from urllib.request import url2pathname url2pathname("file://localhost/c|/WINDOWS/clock.avi") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Apps\Python34\lib\nturl2path.py", line 26, in url2pathname raise OSError(error) OSError: Bad URL: file|//localhost/c|/WINDOWS/clock.avi url2pathname("file:///c|/WINDOWS/clock.avi") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Apps\Python34\lib\nturl2path.py", line 26, in url2pathname raise OSError(error) OSError: Bad URL: file|///c|/WINDOWS/clock.avi url2pathname("file://localhost/c:/WINDOWS/clock.avi") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Apps\Python34\lib\nturl2path.py", line 26, in url2pathname raise OSError(error) OSError: Bad URL: file|//localhost/c|/WINDOWS/clock.avi url2pathname("file:///c:/WINDOWS/clock.avi") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Apps\Python34\lib\nturl2path.py", line 26, in url2pathname raise OSError(error) OSError: Bad URL: file|///c|/WINDOWS/clock.avi url2pathname("file:////WINDOWS/clock.avi") 'E:\\WINDOWS\\clock.avi' url2pathname("file:///WINDOWS/clock.avi") 'E:\\WINDOWS\\clock.avi' url2pathname("file://WINDOWS/clock.avi") 'E:\\WINDOWS\\clock.avi' url2pathname("file:/WINDOWS/clock.avi") 'E:\\WINDOWS\\clock.avi'
I have no idea where Python got that E drive from - my current drive is C:.
At this point in time, I have no idea how to correctly write a file URL for the file C:\Windows\clock.avi on my PC. While it's very definitely a corner case in the PEP, and it's clearly not the PEP's responsibility to explain the file URL spec, I do think it's relevant to the usability of the PEP.
Paul
Does: file:///c:/WINDOWS/clock.avi work? That’s pointed out in the wikipage you linked as to what IE has done since IE4 and seems to be the most reasonable candidate. It also uses file://remotehost/sharename/dir/file.txt for UNC paths apparently. I misunderstood the problem though, I thought you were worried about needing to type out the file:// and the slash order on the CLI, not referencing files at all. We can absolutely add more details to the PEP. --- Donald Stufft PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA