Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
1f0c51f5
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,发现更多精彩内容 >>
未验证
提交
1f0c51f5
编写于
12月 16, 2020
作者:
F
Frost Ming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update lockfile schema
上级
98884349
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
18 deletion
+31
-18
news/132.removal
news/132.removal
+0
-0
news/196.feature
news/196.feature
+1
-0
pdm.lock
pdm.lock
+4
-4
pdm/cli/utils.py
pdm/cli/utils.py
+4
-5
pdm/project/core.py
pdm/project/core.py
+22
-9
未找到文件。
news/132.
bugfix
→
news/132.
removal
浏览文件 @
1f0c51f5
文件已移动
news/196.feature
0 → 100644
浏览文件 @
1f0c51f5
Update
the
lock
file
schema,
move
the
file
hashes
to
`[metadata.files]`
table.
pdm.lock
浏览文件 @
1f0c51f5
...
...
@@ -546,6 +546,10 @@ marker = "python_version < '4.0'"
summary = "Backport of pathlib-compatible object wrapper for zip files"
[metadata]
lock_version = "2"
content_hash = "md5:8e719a97515aca92ae14e3d509118834"
[metadata.files]
"apipkg 1.5" = [
{file = "apipkg-1.5-py2.py3-none-any.whl", hash = "sha256:58587dd4dc3daefad0487f6d9ae32b4542b185e1c36db6993290e7c41ca2b47c"},
{file = "apipkg-1.5.tar.gz", hash = "sha256:37228cda29411948b422fae072f57e31d3396d2ee1c9783775980ee9c9990af6"},
...
...
@@ -958,7 +962,3 @@ summary = "Backport of pathlib-compatible object wrapper for zip files"
{file = "zipp-3.4.0.tar.gz", hash = "sha256:ed5eee1974372595f9e416cc7bbeeb12335201d8081ca8a0743c954d4446e5cb"},
]
[root]
meta_version = "0.0.1"
content_hash = "md5:8e719a97515aca92ae14e3d509118834"
pdm/cli/utils.py
浏览文件 @
1f0c51f5
...
...
@@ -323,7 +323,7 @@ def format_lockfile(mapping, fetched_dependencies, summary_collection):
and a collection of package summaries.
"""
packages
=
tomlkit
.
aot
()
metadata
=
tomlkit
.
table
()
file_hashes
=
tomlkit
.
table
()
for
k
,
v
in
sorted
(
mapping
.
items
()):
base
=
tomlkit
.
table
()
base
.
update
(
v
.
as_lockfile_entry
())
...
...
@@ -349,10 +349,9 @@ def format_lockfile(mapping, fetched_dependencies, summary_collection):
inline
.
update
({
"file"
:
filename
,
"hash"
:
hash_value
})
array
.
append
(
inline
)
if
array
:
metadata
.
add
(
key
,
array
)
doc
=
tomlkit
.
document
()
doc
.
update
({
"package"
:
packages
,
"metadata"
:
metadata
})
return
doc
file_hashes
.
add
(
key
,
array
)
data
=
{
"package"
:
packages
,
"files"
:
file_hashes
}
return
data
def
save_version_specifiers
(
...
...
pdm/project/core.py
浏览文件 @
1f0c51f5
...
...
@@ -43,7 +43,7 @@ class Project:
PYPROJECT_FILENAME
=
"pyproject.toml"
PDM_NAMESPACE
=
"tool.pdm"
DEPENDENCIES_RE
=
re
.
compile
(
r
"(?:(.+?)-)?dependencies"
)
PYPROJECT_VERSION
=
"
0.0.1
"
PYPROJECT_VERSION
=
"
2
"
GLOBAL_PROJECT
=
Path
.
home
()
/
".pdm"
/
"global-project"
@
classmethod
...
...
@@ -281,18 +281,25 @@ class Project:
return
SpinnerReporter
(
spinner
,
requirements
)
def
get_project_metadata
(
self
)
->
Dict
[
str
,
Any
]:
content_hash
=
self
.
get_content_hash
(
"
md5
"
)
content_hash
=
self
.
get_content_hash
(
"
sha256
"
)
data
=
{
"
meta
_version"
:
self
.
PYPROJECT_VERSION
,
"content_hash"
:
f
"
md5
:
{
content_hash
}
"
,
"
lock
_version"
:
self
.
PYPROJECT_VERSION
,
"content_hash"
:
f
"
sha256
:
{
content_hash
}
"
,
}
return
data
def
write_lockfile
(
self
,
toml_data
:
Container
,
show_message
:
bool
=
True
)
->
None
:
toml_data
.
update
({
"root"
:
self
.
get_project_metadata
()})
def
write_lockfile
(
self
,
toml_data
:
Dict
[
str
,
Container
],
show_message
:
bool
=
True
)
->
None
:
doc
=
tomlkit
.
document
()
doc
.
add
(
"package"
,
toml_data
[
"package"
])
metadata
=
tomlkit
.
table
()
metadata
.
update
(
self
.
get_project_metadata
())
metadata
.
add
(
"files"
,
toml_data
[
"files"
])
doc
.
add
(
"metadata"
,
metadata
)
with
atomic_open_for_write
(
self
.
lockfile_file
)
as
fp
:
fp
.
write
(
tomlkit
.
dumps
(
toml_data
))
fp
.
write
(
tomlkit
.
dumps
(
doc
))
if
show_message
:
stream
.
echo
(
f
"Changes are written to
{
stream
.
green
(
'pdm.lock'
)
}
."
)
self
.
_lockfile
=
None
...
...
@@ -323,7 +330,9 @@ class Project:
can
.
marker
=
req
.
marker
can
.
hashes
=
{
item
[
"file"
]:
item
[
"hash"
]
for
item
in
self
.
lockfile
[
"metadata"
].
get
(
f
"
{
req
.
key
}
{
version
}
"
,
[])
for
item
in
self
.
lockfile
[
"metadata"
]
.
get
(
"files"
,
{})
.
get
(
f
"
{
req
.
key
}
{
version
}
"
,
[])
}
or
None
result
[
req
.
identify
()]
=
can
if
section
in
(
"default"
,
"__all__"
)
and
self
.
meta
.
name
and
self
.
meta
.
version
:
...
...
@@ -347,7 +356,11 @@ class Project:
def
is_lockfile_hash_match
(
self
)
->
bool
:
if
not
self
.
lockfile_file
.
exists
():
return
False
hash_in_lockfile
=
str
(
self
.
lockfile
[
"root"
][
"content_hash"
])
hash_in_lockfile
=
str
(
self
.
lockfile
.
get
(
"metadata"
,
{}).
get
(
"content_hash"
,
""
)
)
if
not
hash_in_lockfile
:
return
False
algo
,
hash_value
=
hash_in_lockfile
.
split
(
":"
)
content_hash
=
self
.
get_content_hash
(
algo
)
return
content_hash
==
hash_value
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录