Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
9357ec02
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 搜索 >>
提交
9357ec02
编写于
6月 27, 2022
作者:
F
Frost Ming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(#1156): only trust parsing result when all are static
上级
0e395551
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
8 deletion
+56
-8
pdm/models/candidates.py
pdm/models/candidates.py
+19
-8
tests/fixtures/projects/test-hatch-static/README.md
tests/fixtures/projects/test-hatch-static/README.md
+0
-0
tests/fixtures/projects/test-hatch-static/pyproject.toml
tests/fixtures/projects/test-hatch-static/pyproject.toml
+16
-0
tests/models/test_candidates.py
tests/models/test_candidates.py
+21
-0
未找到文件。
pdm/models/candidates.py
浏览文件 @
9357ec02
...
...
@@ -412,14 +412,25 @@ class PreparedCandidate:
except
ValueError
:
termui
.
logger
.
warn
(
"Failed to parse pyproject.toml"
)
else
:
setup
=
Setup
(
name
=
metadata
.
name
,
version
=
metadata
.
version
,
install_requires
=
metadata
.
dependencies
or
[],
extras_require
=
metadata
.
optional_dependencies
or
{},
python_requires
=
metadata
.
requires_python
or
None
,
)
return
SetupDistribution
(
setup
)
dynamic_fields
=
metadata
.
dynamic
or
[]
# Use the parse result only when all are static
if
set
(
dynamic_fields
).
isdisjoint
(
{
"name"
,
"version"
,
"dependencies"
,
"optional-dependencies"
,
"requires-python"
,
}
):
setup
=
Setup
(
name
=
metadata
.
name
,
version
=
metadata
.
version
,
install_requires
=
metadata
.
dependencies
or
[],
extras_require
=
metadata
.
optional_dependencies
or
{},
python_requires
=
metadata
.
requires_python
or
None
,
)
return
SetupDistribution
(
setup
)
# If all fail, try building the source to get the metadata
builder
=
EditableBuilder
if
self
.
req
.
editable
else
WheelBuilder
try
:
...
...
tests/fixtures/projects/test-hatch-static/README.md
0 → 100644
浏览文件 @
9357ec02
tests/fixtures/projects/test-hatch-static/pyproject.toml
0 → 100644
浏览文件 @
9357ec02
[build-system]
requires
=
["hatchling>=0.15.0"]
build-backend
=
"hatchling.build"
[project]
name
=
"test-hatch"
version
=
"0.1.0"
description
=
"Test hatch project"
readme
=
"README.md"
license
=
"MIT"
requires-python
=
">=3.7"
authors
=
[
{
name
=
"John"
,
email
=
"john@example.org"
}
]
classifiers
=
[
"License :: OSI Approved :: MIT License"
,
]
dependencies
=
[
"requests"
,
"click"
]
tests/models/test_candidates.py
浏览文件 @
9357ec02
...
...
@@ -334,3 +334,24 @@ def test_find_candidates_from_find_links(project):
]
candidates
=
list
(
repo
.
find_candidates
(
parse_requirement
(
"demo"
)))
assert
len
(
candidates
)
==
2
def
test_parse_metadata_from_pep621
(
project
,
mocker
):
builder
=
mocker
.
patch
(
"pdm.builders.wheel.WheelBuilder.build"
)
req
=
parse_requirement
(
f
"test-hatch @ file://
{
FIXTURES
.
as_posix
()
}
/projects/test-hatch-static"
)
candidate
=
Candidate
(
req
)
metadata
=
candidate
.
prepare
(
project
.
environment
).
metadata
assert
sorted
(
metadata
.
requires
)
==
[
"click"
,
"requests"
]
builder
.
assert_not_called
()
def
test_parse_metadata_with_dynamic_fields
(
project
,
local_finder
):
req
=
parse_requirement
(
f
"demo-package @ file://
{
FIXTURES
.
as_posix
()
}
/projects/demo-src-package"
)
candidate
=
Candidate
(
req
)
metadata
=
candidate
.
prepare
(
project
.
environment
).
metadata
assert
not
metadata
.
requires
assert
metadata
.
version
==
"0.1.0"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录