本文整理汇总了Python中pip._internal.index.Link方法的典型用法代码示例。如果您正苦于以下问题:Python index.Link方法的具体用法?Python index.Link怎么用?Python index.Link使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._internal.index
的用法示例。
在下文中一共展示了index.Link方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_editable
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def from_editable(cls, editable_req, comes_from=None, isolated=False,
options=None, wheel_cache=None, constraint=False):
from pip._internal.index import Link
name, url, extras_override = parse_editable(editable_req)
if url.startswith('file:'):
source_dir = url_to_path(url)
else:
source_dir = None
if name is not None:
try:
req = Requirement(name)
except InvalidRequirement:
raise InstallationError("Invalid requirement: '%s'" % name)
else:
req = None
return cls(
req, comes_from, source_dir=source_dir,
editable=True,
link=Link(url),
constraint=constraint,
isolated=isolated,
options=options if options else {},
wheel_cache=wheel_cache,
extras=extras_override or (),
)
示例2: get_location
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def get_location(self, dist, dependency_links):
for url in dependency_links:
egg_fragment = Link(url).egg_fragment
if not egg_fragment:
continue
if '-' in egg_fragment:
# FIXME: will this work when a package has - in the name?
key = '-'.join(egg_fragment.split('-')[:-1]).lower()
else:
key = egg_fragment
if key == dist.key:
return url.split('#', 1)[0]
return None
示例3: _link_for_candidate
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def _link_for_candidate(self, link, candidate):
root = self.get_path_for_link(link)
path = os.path.join(root, candidate)
return index.Link(path_to_url(path))
示例4: download_url
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def download_url(url, download_dir, sha256=None):
"""Download and optionally verify a file.
Returns the downloaded file path.
If sha256 is not specified (default), the file is not verified.
Raises HashMismatch if the file hash does not match the specified
sha256 hash.
If the file was already downloaded, returns its path after
verifying it. If the file cannot be verified, raises HashMismatch
without attempting download again. If the hash is valid but the
download is not, the download must be deleted before trying
again. This behavior is designed to preserve downloads at the cost
of requiring that invalid files be explicitly deleted.
"""
from pip._internal.index import Link
link = Link(url)
downloaded_path = _check_download_path(link, download_dir, sha256)
if not downloaded_path:
orig_path = _pip_download(link, download_dir)
downloaded_path = _ensure_expected_download_path(orig_path, link)
if sha256:
_verify_and_cache_hash(downloaded_path, sha256)
return downloaded_path
示例5: optimistic_wheel_search
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def optimistic_wheel_search(req, index_urls):
name = req.name.replace('-', '_').lower()
for index_url in index_urls:
expected_location = os.path.join(
CACHE.wheelhouse, index_url, ignorecase_glob(name) + '-*.whl',
)
for link in glob.glob(expected_location):
link = Link('file:' + link)
wheel = Wheel(link.filename)
if req.specifier.contains(wheel.version) and wheel.supported():
return link
示例6: __init__
# 需要导入模块: from pip._internal import index [as 别名]
# 或者: from pip._internal.index import Link [as 别名]
def __init__(self, req, comes_from, source_dir=None, editable=False,
link=None, update=True, markers=None,
isolated=False, options=None, wheel_cache=None,
constraint=False, extras=()):
assert req is None or isinstance(req, Requirement), req
self.req = req
self.comes_from = comes_from
self.constraint = constraint
if source_dir is not None:
self.source_dir = os.path.normpath(os.path.abspath(source_dir))
else:
self.source_dir = None
self.editable = editable
self._wheel_cache = wheel_cache
if link is not None:
self.link = self.original_link = link
else:
from pip._internal.index import Link
self.link = self.original_link = req and req.url and Link(req.url)
if extras:
self.extras = extras
elif req:
self.extras = {
pkg_resources.safe_extra(extra) for extra in req.extras
}
else:
self.extras = set()
if markers is not None:
self.markers = markers
else:
self.markers = req and req.marker
self._egg_info_path = None
# This holds the pkg_resources.Distribution object if this requirement
# is already available:
self.satisfied_by = None
# This hold the pkg_resources.Distribution object if this requirement
# conflicts with another installed distribution:
self.conflicts_with = None
# Temporary build location
self._temp_build_dir = TempDirectory(kind="req-build")
# Used to store the global directory where the _temp_build_dir should
# have been created. Cf _correct_build_location method.
self._ideal_build_dir = None
# True if the editable should be updated:
self.update = update
# Set to True after successful installation
self.install_succeeded = None
# UninstallPathSet of uninstalled distribution (for possible rollback)
self.uninstalled_pathset = None
self.options = options if options else {}
# Set to True after successful preparation of this requirement
self.prepared = False
self.is_direct = False
self.isolated = isolated
self.build_env = BuildEnvironment(no_clean=True)