12
12
from urllib import request as urllib_request
13
13
from urllib .parse import quote , urlparse
14
14
15
- from pipenv .patched .pip ._vendor .requests import Session
15
+ from pipenv .patched .pip ._internal .locations import USER_CACHE_DIR
16
+ from pipenv .patched .pip ._internal .network .download import PipSession
16
17
from pipenv .utils import err
17
18
18
19
@@ -114,12 +115,12 @@ def path_to_url(path):
114
115
115
116
116
117
@contextmanager
117
- def open_file (link , session : Optional [Session ] = None , stream : bool = True ):
118
+ def open_file (link , session : Optional [PipSession ] = None , stream : bool = False ):
118
119
"""Open local or remote file for reading.
119
120
120
121
:param pipenv.patched.pip._internal.index.Link link: A link object from resolving dependencies with
121
122
pip, or else a URL.
122
- :param Optional[Session ] session: A :class:`~requests.Session ` instance
123
+ :param Optional[PipSession ] session: A :class:`~PipSession ` instance
123
124
:param bool stream: Whether to stream the content if remote, default True
124
125
:raises ValueError: If link points to a local directory.
125
126
:return: a context manager to the opened file-like object
@@ -145,7 +146,7 @@ def open_file(link, session: Optional[Session] = None, stream: bool = True):
145
146
# Remote URL
146
147
headers = {"Accept-Encoding" : "identity" }
147
148
if not session :
148
- session = Session ( )
149
+ session = PipSession ( cache = USER_CACHE_DIR )
149
150
resp = session .get (link , headers = headers , stream = stream )
150
151
if resp .status_code != 200 :
151
152
err .print (f"HTTP error { resp .status_code } while getting { link } " )
0 commit comments