Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
d5c88a1b
P
Pdm
项目概览
后端镜像
/
Pdm
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Pdm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d5c88a1b
编写于
8月 04, 2022
作者:
F
Frost Ming
提交者:
GitHub
8月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: prefer compatible packages (#1302)
* fix: prefer compatible packages * add news
上级
c1aa0f79
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
9 deletion
+23
-9
news/1302.bugfix.md
news/1302.bugfix.md
+1
-0
pdm/models/candidates.py
pdm/models/candidates.py
+22
-9
未找到文件。
news/1302.bugfix.md
0 → 100644
浏览文件 @
d5c88a1b
Prefer compatible packages when fetching metadata.
pdm/models/candidates.py
浏览文件 @
d5c88a1b
...
...
@@ -72,21 +72,33 @@ def _filter_none(data: dict[str, Any]) -> dict[str, Any]:
def
_find_best_match_link
(
finder
:
PackageFinder
,
req
:
Requirement
,
hashes
:
dict
[
Link
,
str
]
|
None
finder
:
PackageFinder
,
req
:
Requirement
,
hashes
:
dict
[
Link
,
str
]
|
None
,
ignore_compatibility
:
bool
=
False
,
)
->
Link
|
None
:
"""Get the best matching link for a requirement"""
# This function is called when a lock file candidate is given or incompatible wheel
# In this case, the requirement must be pinned, so no need to pass allow_prereleases
# If hashes are not empty, find the best match from the links, otherwise find from
# the package sources.
if
hashes
is
None
:
best
=
finder
.
find_best_match
(
req
.
as_line
()).
best
def
attempt_to_find
()
->
Link
|
None
:
if
hashes
is
None
:
best
=
finder
.
find_best_match
(
req
.
as_line
()).
best
return
best
.
link
if
best
is
not
None
else
None
# We don't evaluate against the hashes, they will be validated later.
evaluator
=
finder
.
build_evaluator
(
req
.
name
)
packages
:
Iterable
[
Package
]
=
filter
(
None
,
map
(
evaluator
.
evaluate_link
,
hashes
))
best
=
max
(
packages
,
key
=
finder
.
_sort_key
,
default
=
None
)
return
best
.
link
if
best
is
not
None
else
None
# We don't evaluate against the hashes, they will be validated later in downloading.
evaluator
=
finder
.
build_evaluator
(
req
.
name
)
packages
:
Iterable
[
Package
]
=
filter
(
None
,
map
(
evaluator
.
evaluate_link
,
hashes
))
best
=
max
(
packages
,
key
=
finder
.
_sort_key
,
default
=
None
)
return
best
.
link
if
best
is
not
None
else
None
original_ignore
=
finder
.
ignore_compatibility
link
=
attempt_to_find
()
if
link
is
None
and
ignore_compatibility
and
not
original_ignore
:
finder
.
ignore_compatibility
=
ignore_compatibility
link
=
attempt_to_find
()
finder
.
ignore_compatibility
=
original_ignore
return
link
class
Candidate
:
...
...
@@ -367,7 +379,7 @@ class PreparedCandidate:
hash_options
=
None
if
not
allow_all
and
self
.
candidate
.
hashes
:
hash_options
=
convert_hashes
(
self
.
candidate
.
hashes
)
with
self
.
environment
.
get_finder
(
ignore_compatibility
=
allow_all
)
as
finder
:
with
self
.
environment
.
get_finder
()
as
finder
:
if
(
not
self
.
link
or
self
.
link
.
is_wheel
...
...
@@ -383,6 +395,7 @@ class PreparedCandidate:
finder
,
self
.
req
.
as_pinned_version
(
self
.
candidate
.
version
),
self
.
candidate
.
hashes
,
ignore_compatibility
=
allow_all
,
)
if
not
self
.
link
:
raise
CandidateNotFound
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录