10
10
from pip ._internal .metadata import BaseDistribution
11
11
from pip ._internal .metadata .pkg_resources import Distribution as _PkgResourcesDist
12
12
from pip ._internal .models .direct_url import DirectUrl
13
+ from pip ._internal .models .link import Link
13
14
from pip ._internal .network .session import PipSession
14
15
from pip ._internal .req import InstallRequirement
15
16
from pip ._internal .req import parse_requirements as _parse_requirements
@@ -63,6 +64,14 @@ def _from_importlib(cls, dist: _ImportLibDist) -> Distribution:
63
64
return cls (dist ._dist .name , dist ._dist .version , requires , dist .direct_url )
64
65
65
66
67
+ class FileLink (Link ):
68
+
69
+ @property
70
+ def file_path (self ) -> str :
71
+ # overriding the actual property to bypass some validation
72
+ return self ._url
73
+
74
+
66
75
def parse_requirements (
67
76
filename : str ,
68
77
session : PipSession ,
@@ -74,7 +83,14 @@ def parse_requirements(
74
83
for parsed_req in _parse_requirements (
75
84
filename , session , finder = finder , options = options , constraint = constraint
76
85
):
77
- yield install_req_from_parsed_requirement (parsed_req , isolated = isolated )
86
+ install_req = install_req_from_parsed_requirement (parsed_req , isolated = isolated )
87
+ if install_req .editable and not parsed_req .requirement .startswith ("file://" ):
88
+ # ``Link.url`` is what is saved to the output file
89
+ # we set the url directly to undo the transformation in pip's Link class
90
+ file_link = FileLink (install_req .link .url )
91
+ file_link ._url = parsed_req .requirement
92
+ install_req .link = file_link
93
+ yield install_req
78
94
79
95
80
96
def create_wheel_cache (cache_dir : str , format_control : str | None = None ) -> WheelCache :
0 commit comments