Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Pdm
提交
35f12d5b
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,发现更多精彩内容 >>
未验证
提交
35f12d5b
编写于
7月 24, 2022
作者:
F
Frost Ming
提交者:
GitHub
7月 24, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Remove dependency of pip (#1268)
上级
e2a24dca
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
205 addition
and
217 deletion
+205
-217
news/1268.dep.md
news/1268.dep.md
+1
-0
pdm.lock
pdm.lock
+191
-201
pdm/cli/commands/plugin.py
pdm/cli/commands/plugin.py
+7
-11
pyproject.toml
pyproject.toml
+0
-1
tests/cli/test_plugin.py
tests/cli/test_plugin.py
+6
-4
未找到文件。
news/1268.dep.md
0 → 100644
浏览文件 @
35f12d5b
Remove the dependency of
`pip`
.
pdm.lock
浏览文件 @
35f12d5b
此差异已折叠。
点击以展开。
pdm/cli/commands/plugin.py
浏览文件 @
35f12d5b
from
__future__
import
annotations
import
argparse
import
os
import
shlex
import
subprocess
import
sys
from
pip
import
__file__
as
pip_location
from
pdm
import
termui
from
pdm.cli.commands.base
import
BaseCommand
from
pdm.cli.options
import
verbose_option
from
pdm.cli.utils
import
Package
,
build_dependency_graph
from
pdm.compat
import
importlib_metadata
from
pdm.models.environment
import
WorkingSet
from
pdm.models.environment
import
BareEnvironment
,
WorkingSet
from
pdm.project
import
Project
from
pdm.utils
import
normalize_name
...
...
@@ -26,11 +23,10 @@ def _all_plugins() -> list[str]:
return
sorted
(
result
)
def
run_pip
(
args
:
list
[
str
])
->
bytes
:
return
subprocess
.
check_output
(
[
sys
.
executable
,
"-I"
,
os
.
path
.
dirname
(
pip_location
)]
+
args
,
stderr
=
subprocess
.
STDOUT
,
)
def
run_pip
(
project
:
Project
,
args
:
list
[
str
])
->
bytes
:
env
=
BareEnvironment
(
project
)
project
.
environment
=
env
return
subprocess
.
check_output
(
env
.
pip_command
+
args
,
stderr
=
subprocess
.
STDOUT
)
class
Command
(
BaseCommand
):
...
...
@@ -101,7 +97,7 @@ class AddCommand(BaseCommand):
with
project
.
core
.
ui
.
open_spinner
(
f
"Installing plugins:
{
options
.
packages
}
"
):
run_pip
(
pip_args
)
run_pip
(
p
roject
,
p
ip_args
)
except
subprocess
.
CalledProcessError
as
e
:
project
.
core
.
ui
.
echo
(
"Installation failed:
\n
"
+
e
.
output
.
decode
(
"utf8"
),
err
=
True
...
...
@@ -182,7 +178,7 @@ class RemoveCommand(BaseCommand):
with
project
.
core
.
ui
.
open_spinner
(
f
"Uninstalling plugins:
{
valid_packages
}
"
):
run_pip
(
pip_args
)
run_pip
(
p
roject
,
p
ip_args
)
except
subprocess
.
CalledProcessError
as
e
:
project
.
core
.
ui
.
echo
(
"Uninstallation failed:
\n
"
+
e
.
output
.
decode
(
"utf8"
),
err
=
True
...
...
pyproject.toml
浏览文件 @
35f12d5b
...
...
@@ -9,7 +9,6 @@ requires-python = ">=3.7"
license
=
{
text
=
"MIT"
}
dependencies
=
[
"blinker"
,
"pip>=20"
,
"packaging"
,
"platformdirs"
,
"rich>=12.3.0"
,
...
...
tests/cli/test_plugin.py
浏览文件 @
35f12d5b
from
unittest.mock
import
Mock
from
unittest.mock
import
ANY
,
Mock
import
pytest
...
...
@@ -34,13 +34,15 @@ def test_plugin_list(invoke):
def
test_plugin_add
(
invoke
,
mock_pip
):
result
=
invoke
([
"plugin"
,
"add"
,
"foo"
])
assert
result
.
exit_code
==
0
,
result
.
stderr
mock_pip
.
assert_called_with
([
"install"
,
"foo"
])
mock_pip
.
assert_called_with
(
ANY
,
[
"install"
,
"foo"
])
result
=
invoke
(
[
"plugin"
,
"add"
,
"--pip-args"
,
"--force-reinstall --upgrade"
,
"foo"
]
)
assert
result
.
exit_code
==
0
,
result
.
stderr
mock_pip
.
assert_called_with
([
"install"
,
"--force-reinstall"
,
"--upgrade"
,
"foo"
])
mock_pip
.
assert_called_with
(
ANY
,
[
"install"
,
"--force-reinstall"
,
"--upgrade"
,
"foo"
]
)
@
pytest
.
mark
.
usefixtures
(
"mock_all_plugins"
)
...
...
@@ -59,4 +61,4 @@ def test_plugin_remove(invoke, mock_pip, monkeypatch):
result
=
invoke
([
"plugin"
,
"remove"
,
"-y"
,
"demo"
])
assert
result
.
exit_code
==
0
,
result
.
stderr
mock_pip
.
assert_called_with
([
"uninstall"
,
"-y"
,
"demo"
,
"pytz"
])
mock_pip
.
assert_called_with
(
ANY
,
[
"uninstall"
,
"-y"
,
"demo"
,
"pytz"
])
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录