mirror of https://github.com/pypa/pip
Merge 560478fd72
into a15dd75d98
This commit is contained in:
commit
9159512bf5
|
@ -0,0 +1 @@
|
|||
Improve performance ~17% when installing many wheels offline
|
|
@ -2,6 +2,7 @@ import os
|
|||
import string
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from functools import lru_cache
|
||||
from typing import Optional
|
||||
|
||||
from .compat import WINDOWS
|
||||
|
@ -13,13 +14,22 @@ def get_url_scheme(url: str) -> Optional[str]:
|
|||
return url.split(":", 1)[0].lower()
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def _normalized_abs_path_to_url(abs_path: str) -> str:
|
||||
"""
|
||||
Convert a normalized absolute path to a file: URL.
|
||||
"""
|
||||
url = urllib.parse.urljoin("file:", urllib.request.pathname2url(abs_path))
|
||||
return url
|
||||
|
||||
|
||||
def path_to_url(path: str) -> str:
|
||||
"""
|
||||
Convert a path to a file: URL. The path will be made absolute and have
|
||||
quoted path parts.
|
||||
"""
|
||||
path = os.path.normpath(os.path.abspath(path))
|
||||
url = urllib.parse.urljoin("file:", urllib.request.pathname2url(path))
|
||||
url = _normalized_abs_path_to_url(path)
|
||||
return url
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue