Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.utils.direct_url_helpers Namespace Reference

Functions

str direct_url_as_pep440_direct_reference (DirectUrl direct_url, str name)
 
DirectUrl direct_url_for_editable (str source_dir)
 
DirectUrl direct_url_from_link (Link link, Optional[str] source_dir=None, bool link_is_in_wheel_cache=False)
 

Function Documentation

◆ direct_url_as_pep440_direct_reference()

str direct_url_as_pep440_direct_reference ( DirectUrl  direct_url,
str  name 
)
Convert a DirectUrl to a pip requirement string.

Definition at line 9 of file direct_url_helpers.py.

9def direct_url_as_pep440_direct_reference(direct_url: DirectUrl, name: str) -> str:
10 """Convert a DirectUrl to a pip requirement string."""
11 direct_url.validate() # if invalid, this is a pip bug
12 requirement = name + " @ "
13 fragments = []
14 if isinstance(direct_url.info, VcsInfo):
15 requirement += "{}+{}@{}".format(
17 )
18 elif isinstance(direct_url.info, ArchiveInfo):
19 requirement += direct_url.url
22 else:
23 assert isinstance(direct_url.info, DirInfo)
24 requirement += direct_url.url
27 if fragments:
28 requirement += "#" + "&".join(fragments)
29 return requirement
30
31
for i

References i.

◆ direct_url_for_editable()

DirectUrl direct_url_for_editable ( str  source_dir)

Definition at line 32 of file direct_url_helpers.py.

32def direct_url_for_editable(source_dir: str) -> DirectUrl:
33 return DirectUrl(
34 url=path_to_url(source_dir),
35 info=DirInfo(editable=True),
36 )
37
38

◆ direct_url_from_link()

DirectUrl direct_url_from_link ( Link  link,
Optional[str]   source_dir = None,
bool   link_is_in_wheel_cache = False 
)

Definition at line 39 of file direct_url_helpers.py.

41) -> DirectUrl:
42 if link.is_vcs:
44 assert vcs_backend
45 url, requested_revision, _ = vcs_backend.get_url_rev_and_auth(
47 )
48 # For VCS links, we need to find out and add commit_id.
49 if link_is_in_wheel_cache:
50 # If the requested VCS link corresponds to a cached
51 # wheel, it means the requested revision was an
52 # immutable commit hash, otherwise it would not have
53 # been cached. In that case we don't have a source_dir
54 # with the VCS checkout.
55 assert requested_revision
56 commit_id = requested_revision
57 else:
58 # If the wheel was not in cache, it means we have
59 # had to checkout from VCS to build and we have a source_dir
60 # which we can inspect to find out the commit id.
61 assert source_dir
62 commit_id = vcs_backend.get_revision(source_dir)
63 return DirectUrl(
64 url=url,
65 info=VcsInfo(
67 commit_id=commit_id,
68 requested_revision=requested_revision,
69 ),
70 subdirectory=link.subdirectory_fragment,
71 )
73 return DirectUrl(
75 info=DirInfo(),
76 subdirectory=link.subdirectory_fragment,
77 )
78 else:
79 hash = None
80 hash_name = link.hash_name
81 if hash_name:
82 hash = f"{hash_name}={link.hash}"
83 return DirectUrl(
85 info=ArchiveInfo(hash=hash),
86 subdirectory=link.subdirectory_fragment,
87 )

References i.