Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
349cf76c
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,发现更多精彩内容 >>
未验证
提交
349cf76c
编写于
2月 08, 2021
作者:
F
Frost Ming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ask if the project is a library
上级
aa1e7234
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
38 addition
and
5 deletion
+38
-5
news/234.bugfix.md
news/234.bugfix.md
+0
-0
news/238.feature.md
news/238.feature.md
+0
-0
news/240.feature.md
news/240.feature.md
+0
-0
news/245.feature.md
news/245.feature.md
+0
-0
news/253.feature.md
news/253.feature.md
+1
-0
pdm/cli/commands/init.py
pdm/cli/commands/init.py
+12
-2
pyproject.toml
pyproject.toml
+1
-1
tests/cli/test_cli.py
tests/cli/test_cli.py
+24
-2
未找到文件。
news/234.bugfix
→
news/234.bugfix
.md
浏览文件 @
349cf76c
文件已移动
news/238.feature
→
news/238.feature
.md
浏览文件 @
349cf76c
文件已移动
news/240.feature
→
news/240.feature
.md
浏览文件 @
349cf76c
文件已移动
news/245.feature
→
news/245.feature
.md
浏览文件 @
349cf76c
文件已移动
news/253.feature.md
0 → 100644
浏览文件 @
349cf76c
When initializing the project, prompt user for whether the project is a library, and give empty
`name`
and
`version`
if not.
pdm/cli/commands/init.py
浏览文件 @
349cf76c
...
...
@@ -31,8 +31,18 @@ class Command(BaseCommand):
"Please enter the Python interpreter to use"
,
default
=
""
,
show_default
=
False
)
actions
.
do_use
(
project
,
python
)
name
=
click
.
prompt
(
"Project name"
,
default
=
project
.
root
.
name
)
version
=
click
.
prompt
(
"Project version"
,
default
=
"0.0.0"
)
is_library
=
(
click
.
prompt
(
"Is the project a library that will be upload to PyPI?(y/n)"
,
default
=
"n"
,
).
lower
()
==
"y"
)
if
is_library
:
name
=
click
.
prompt
(
"Project name"
,
default
=
project
.
root
.
name
)
version
=
click
.
prompt
(
"Project version"
,
default
=
"0.1.0"
)
else
:
name
,
version
=
""
,
""
license
=
click
.
prompt
(
"License(SPDX name)"
,
default
=
"MIT"
)
git_user
,
git_email
=
get_user_email_from_git
()
...
...
pyproject.toml
浏览文件 @
349cf76c
...
...
@@ -40,7 +40,7 @@ description = "Python Development Master"
readme
=
"README.md"
keywords
=
[
"packaging"
,
"dependency"
,
"workflow"
]
classifiers
=
[
"Development Status ::
3 - Alph
a"
,
"Development Status ::
4 - Bet
a"
,
"Topic :: Software Development :: Build Tools"
,
]
...
...
tests/cli/test_cli.py
浏览文件 @
349cf76c
...
...
@@ -137,13 +137,35 @@ def test_install_with_lockfile(project, invoke, working_set, repository):
def
test_init_command
(
project_no_init
,
invoke
,
mocker
):
mocker
.
patch
(
"pdm.cli.commands.init.get_user_email_from_git"
,
return_value
=
(
"Testing"
,
"me@example.org"
),
)
do_init
=
mocker
.
patch
.
object
(
actions
,
"do_init"
)
result
=
invoke
([
"init"
],
input
=
"python
\n\n\n\n\n\n
"
,
obj
=
project_no_init
)
assert
result
.
exit_code
==
0
python_version
,
_
=
get_python_version
(
project_no_init
.
environment
.
python_executable
,
True
,
2
)
do_init
.
assert_called_with
(
project_no_init
,
""
,
""
,
"MIT"
,
"Testing"
,
"me@example.org"
,
f
">=
{
python_version
}
"
,
)
def
test_init_command_library
(
project_no_init
,
invoke
,
mocker
):
mocker
.
patch
(
"pdm.cli.commands.init.get_user_email_from_git"
,
return_value
=
(
"Testing"
,
"me@example.org"
),
)
do_init
=
mocker
.
patch
.
object
(
actions
,
"do_init"
)
result
=
invoke
(
[
"init"
],
input
=
"python
\n
test-project
\n\n\n\n\n\n
"
,
obj
=
project_no_init
[
"init"
],
input
=
"python
\n
y
\n
test-project
\n\n\n\n\n\n
"
,
obj
=
project_no_init
)
assert
result
.
exit_code
==
0
python_version
,
_
=
get_python_version
(
...
...
@@ -152,7 +174,7 @@ def test_init_command(project_no_init, invoke, mocker):
do_init
.
assert_called_with
(
project_no_init
,
"test-project"
,
"0.
0
.0"
,
"0.
1
.0"
,
"MIT"
,
"Testing"
,
"me@example.org"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录