Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
1a23305c
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,发现更多精彩内容 >>
未验证
提交
1a23305c
编写于
2月 02, 2021
作者:
F
Frost Ming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat. Build the wheel to find the name
上级
72c24cc6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
4 deletion
+24
-4
news/245.feature
news/245.feature
+1
-0
pdm/formats/requirements.py
pdm/formats/requirements.py
+12
-2
pdm/models/requirements.py
pdm/models/requirements.py
+0
-2
tests/test_formats.py
tests/test_formats.py
+11
-0
未找到文件。
news/245.feature
0 → 100644
浏览文件 @
1a23305c
When
importing requirments from a `requirments.txt` file, build the package to find the name if not given in the URL.
pdm/formats/requirements.py
浏览文件 @
1a23305c
import
hashlib
import
urllib.parse
from
distlib.wheel
import
Wheel
from
pdm.formats.base
import
make_array
from
pdm.iostream
import
stream
from
pdm.models.markers
import
Marker
from
pdm.models.pip_shims
import
parse_requirements
from
pdm.models.requirements
import
parse_requirement
from
pdm.utils
import
get_finder
...
...
@@ -26,7 +30,7 @@ def _requirement_to_str_lowercase_name(requirement):
return
""
.
join
(
parts
)
def
ireq_as_line
(
ireq
):
def
ireq_as_line
(
ireq
,
environment
):
"""Formats an `InstallRequirement` instance as a
PEP 508 dependency string.
...
...
@@ -40,6 +44,11 @@ def ireq_as_line(ireq):
if
ireq
.
editable
:
line
=
"-e {}"
.
format
(
ireq
.
link
)
else
:
if
not
ireq
.
req
:
ireq
.
req
=
parse_requirement
(
"dummy @"
+
ireq
.
link
.
url
)
wheel
=
Wheel
(
environment
.
build
(
ireq
))
ireq
.
req
.
name
=
wheel
.
name
line
=
_requirement_to_str_lowercase_name
(
ireq
.
req
)
if
str
(
ireq
.
req
.
marker
)
!=
str
(
ireq
.
markers
):
...
...
@@ -85,7 +94,8 @@ def convert_url_to_source(url, name=None):
def
convert
(
project
,
filename
):
ireqs
,
finder
=
parse_requirement_file
(
str
(
filename
))
reqs
=
[
ireq_as_line
(
ireq
)
for
ireq
in
ireqs
]
with
stream
.
logging
(
"build"
):
reqs
=
[
ireq_as_line
(
ireq
,
project
.
environment
)
for
ireq
in
ireqs
]
data
=
{
"dependencies"
:
make_array
(
reqs
,
True
)}
settings
=
{}
...
...
pdm/models/requirements.py
浏览文件 @
1a23305c
...
...
@@ -389,8 +389,6 @@ class VcsRequirement(FileRequirement):
self
.
url
=
add_ssh_scheme_to_git_uri
(
self
.
url
)
if
not
self
.
name
:
self
.
_parse_name_from_url
()
if
not
self
.
name
:
raise
RequirementError
(
"VCS requirement must provide a 'egg=' fragment."
)
repo
=
url_without_fragments
(
self
.
url
)
ref
=
None
parsed
=
urlparse
.
urlparse
(
repo
)
...
...
tests/test_formats.py
浏览文件 @
1a23305c
...
...
@@ -33,6 +33,17 @@ def test_convert_requirements_file(project):
)
def
test_convert_requirements_file_without_name
(
project
,
vcs
):
req_file
=
project
.
root
.
joinpath
(
"reqs.txt"
)
project
.
root
.
joinpath
(
"reqs.txt"
).
write_text
(
"git+https://github.com/test-root/demo.git
\n
"
)
assert
requirements
.
check_fingerprint
(
project
,
str
(
req_file
))
result
,
_
=
requirements
.
convert
(
project
,
str
(
req_file
))
assert
result
[
"dependencies"
]
==
[
"demo@ git+https://github.com/test-root/demo.git"
]
def
test_convert_poetry
(
project
):
golden_file
=
FIXTURES
/
"pyproject-poetry.toml"
assert
poetry
.
check_fingerprint
(
project
,
golden_file
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录