Compare commits

...

12 Commits

Author SHA1 Message Date
Oliver Freund 65b8a48a42
Merge 000903cc79 into a15dd75d98 2023-12-06 13:57:40 +01:00
Tzu-ping Chung a15dd75d98
Merge pull request #12417 from xqm32/fix-outdated-pip-install 2023-11-28 16:08:29 +09:00
Tzu-ping Chung d8ab6dc6c1 Clarify news fragment 2023-11-28 15:06:25 +08:00
Qiming Xu fe10d368f6
Add end line 2023-11-28 14:25:56 +08:00
Qiming Xu 28250baffb
Fix line wrap length and add news entry 2023-11-28 14:17:51 +08:00
Qiming Xu 88ac529219
Fix outdated pip install argument description 2023-11-28 13:15:31 +08:00
Oliver Freund 000903cc79
Merge branch 'main' into 11577-improve-error-message-non-local-URI 2022-11-10 21:43:49 -06:00
Oliver Freund 4d00f7d30d storing suggested url in a separate variable 2022-11-10 14:46:59 -06:00
Oliver Freund 97e693dbb7 added new line for re.sub statement 2022-11-09 15:38:15 -06:00
Oliver Freund 49568ab2d5 Fixes for Lint-Issues 2022-11-05 15:12:30 -06:00
Oliver Freund 5b0b9b063c Do not show traceback for error message when using non local file URIs 2022-11-05 14:19:20 -06:00
Oliver Freund 4cb9d69562 changed error message for non local file URIs 2022-11-05 14:10:13 -06:00
4 changed files with 14 additions and 3 deletions

View File

@ -45,8 +45,8 @@ When looking at the items to be installed, pip checks what type of item
each is, in the following order:
1. Project or archive URL.
2. Local directory (which must contain a ``setup.py``, or pip will report
an error).
2. Local directory (which must contain a ``pyproject.toml`` or ``setup.py``,
otherwise pip will report an error).
3. Local file (a sdist or wheel format archive, following the naming
conventions for those formats).
4. A requirement, as specified in :pep:`440`.

1
news/11577.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Improve error message when using non-local file URIs

1
news/12417.doc.rst Normal file
View File

@ -0,0 +1 @@
Fix outdated pip install argument description in documentation.

View File

@ -1,5 +1,7 @@
import os
import re
import string
import sys
import urllib.parse
import urllib.request
from typing import Optional
@ -40,8 +42,15 @@ def url_to_path(url: str) -> str:
# If we have a UNC path, prepend UNC share notation.
netloc = "\\\\" + netloc
else:
# do not include traceback as the error message should be self-explaining
sys.tracebacklimit = 0
# suggest using 'file:/' to the user:
suggestion = re.sub("(^file:)(/)+", "file:/", url)
raise ValueError(
f"non-local file URIs are not supported on this platform: {url!r}"
f"{url!r} points to the domain '{netloc}'. "
f"Non-local file URIs are not supported on this platform. "
f"Did you mean to use '{suggestion}'?"
)
path = urllib.request.url2pathname(netloc + path)