Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
bd0f7fe3
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd0f7fe3
编写于
3月 25, 2020
作者:
P
Paul Moore
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an ExtrasCandidate class
上级
76de49bc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
18 deletion
+59
-18
src/pip/_internal/resolution/resolvelib/candidates.py
src/pip/_internal/resolution/resolvelib/candidates.py
+52
-13
src/pip/_internal/resolution/resolvelib/requirements.py
src/pip/_internal/resolution/resolvelib/requirements.py
+7
-5
未找到文件。
src/pip/_internal/resolution/resolvelib/candidates.py
浏览文件 @
bd0f7fe3
...
...
@@ -4,10 +4,10 @@ from pip._internal.req.constructors import install_req_from_line
from
pip._internal.req.req_install
import
InstallRequirement
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
.base
import
Candidate
from
.base
import
Candidate
,
format_name
if
MYPY_CHECK_RUNNING
:
from
typing
import
Any
,
Dict
,
Optional
,
Sequence
from
typing
import
Any
,
Dict
,
Optional
,
Sequence
,
Set
from
pip._internal.models.link
import
Link
from
pip._internal.operations.prepare
import
RequirementPreparer
...
...
@@ -17,14 +17,15 @@ if MYPY_CHECK_RUNNING:
from
pip._vendor.pkg_resources
import
Distribution
_CANDIDATE_CACHE
=
{}
# type: Dict[Link, Candidate]
_CANDIDATE_CACHE
=
{}
# type: Dict[Link,
Link
Candidate]
def
make_candidate
(
link
,
# type: Link
preparer
,
# type: RequirementPreparer
parent
,
# type: InstallRequirement
make_install_req
# type: InstallRequirementProvider
link
,
# type: Link
preparer
,
# type: RequirementPreparer
parent
,
# type: InstallRequirement
make_install_req
,
# type: InstallRequirementProvider
extras
# type: Set[str]
):
# type: (...) -> Candidate
if
link
not
in
_CANDIDATE_CACHE
:
...
...
@@ -34,7 +35,10 @@ def make_candidate(
parent
=
parent
,
make_install_req
=
make_install_req
)
return
_CANDIDATE_CACHE
[
link
]
base
=
_CANDIDATE_CACHE
[
link
]
if
extras
:
return
ExtrasCandidate
(
base
,
extras
)
return
base
def
make_install_req_from_link
(
link
,
parent
):
...
...
@@ -67,7 +71,7 @@ class LinkCandidate(Candidate):
self
.
link
=
link
self
.
_preparer
=
preparer
self
.
_ireq
=
make_install_req_from_link
(
link
,
parent
)
self
.
_make_install_req
=
make_install_req
self
.
_make_install_req
=
lambda
spec
:
make_install_req
(
spec
,
self
.
_ireq
)
self
.
_name
=
None
# type: Optional[str]
self
.
_version
=
None
# type: Optional[_BaseVersion]
...
...
@@ -120,11 +124,46 @@ class LinkCandidate(Candidate):
def
get_dependencies
(
self
):
# type: () -> Sequence[InstallRequirement]
return
[
self
.
_make_install_req
(
str
(
r
),
self
.
_ireq
)
for
r
in
self
.
dist
.
requires
()
]
return
[
self
.
_make_install_req
(
str
(
r
))
for
r
in
self
.
dist
.
requires
()]
def
get_install_requirement
(
self
):
# type: () -> InstallRequirement
return
self
.
_ireq
class
ExtrasCandidate
(
LinkCandidate
):
def
__init__
(
self
,
base
,
# type: LinkCandidate
extras
,
# type: Set[str]
):
# type: (...) -> None
self
.
base
=
base
self
.
extras
=
extras
self
.
link
=
base
.
link
@
property
def
name
(
self
):
# type: () -> str
"""The normalised name of the project the candidate refers to"""
return
format_name
(
self
.
base
.
name
,
self
.
extras
)
@
property
def
version
(
self
):
# type: () -> _BaseVersion
return
self
.
base
.
version
def
get_dependencies
(
self
):
# type: () -> Sequence[InstallRequirement]
deps
=
[
self
.
base
.
_make_install_req
(
str
(
r
))
for
r
in
self
.
base
.
dist
.
requires
(
self
.
extras
)
]
# Add a dependency on the exact base
spec
=
"{}=={}"
.
format
(
self
.
base
.
name
,
self
.
base
.
version
)
deps
.
append
(
self
.
base
.
_make_install_req
(
spec
))
return
deps
def
get_install_requirement
(
self
):
# type: () -> InstallRequirement
return
self
.
base
.
get_install_requirement
()
src/pip/_internal/resolution/resolvelib/requirements.py
浏览文件 @
bd0f7fe3
...
...
@@ -2,7 +2,7 @@ from pip._vendor.packaging.utils import canonicalize_name
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
.base
import
Requirement
from
.base
import
Requirement
,
format_name
from
.candidates
import
make_candidate
if
MYPY_CHECK_RUNNING
:
...
...
@@ -28,7 +28,8 @@ def make_requirement(
ireq
.
link
,
preparer
,
ireq
,
make_install_req
make_install_req
,
set
()
)
return
ExplicitRequirement
(
candidate
)
else
:
...
...
@@ -70,17 +71,17 @@ class SpecifierRequirement(Requirement):
):
# type: (...) -> None
assert
ireq
.
link
is
None
,
"This is a link, not a specifier"
assert
not
ireq
.
req
.
extras
,
"Extras not yet supported"
self
.
_ireq
=
ireq
self
.
_finder
=
finder
self
.
_preparer
=
preparer
self
.
_make_install_req
=
make_install_req
self
.
extras
=
ireq
.
req
.
extras
@
property
def
name
(
self
):
# type: () -> str
canonical_name
=
canonicalize_name
(
self
.
_ireq
.
req
.
name
)
return
canonical_name
return
format_name
(
canonical_name
,
self
.
extras
)
def
find_matches
(
self
):
# type: () -> Sequence[Candidate]
...
...
@@ -94,7 +95,8 @@ class SpecifierRequirement(Requirement):
ican
.
link
,
self
.
_preparer
,
self
.
_ireq
,
self
.
_make_install_req
self
.
_make_install_req
,
self
.
extras
)
for
ican
in
found
.
iter_applicable
()
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录