Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
7d523f32
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7d523f32
编写于
9月 30, 2019
作者:
P
Pradyun Gedam
提交者:
GitHub
9月 30, 2019
浏览文件
操作
浏览文件
下载
差异文件
Use pep517's new subprocess_runner API (#7111)
上级
b0ea6059
1ad0495f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
69 addition
and
47 deletion
+69
-47
src/pip/_internal/distributions/source/legacy.py
src/pip/_internal/distributions/source/legacy.py
+8
-3
src/pip/_internal/req/req_install.py
src/pip/_internal/req/req_install.py
+19
-36
src/pip/_internal/utils/logging.py
src/pip/_internal/utils/logging.py
+2
-2
src/pip/_internal/utils/subprocess.py
src/pip/_internal/utils/subprocess.py
+30
-2
src/pip/_internal/wheel.py
src/pip/_internal/wheel.py
+10
-4
未找到文件。
src/pip/_internal/distributions/source/legacy.py
浏览文件 @
7d523f32
...
...
@@ -6,6 +6,7 @@ import logging
from
pip._internal.build_env
import
BuildEnvironment
from
pip._internal.distributions.base
import
AbstractDistribution
from
pip._internal.exceptions
import
InstallationError
from
pip._internal.utils.subprocess
import
runner_with_spinner_message
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -81,9 +82,13 @@ class SourceDistribution(AbstractDistribution):
# This must be done in a second pass, as the pyproject.toml
# dependencies must be installed before we can call the backend.
with
self
.
req
.
build_env
:
# We need to have the env active when calling the hook.
self
.
req
.
spin_message
=
"Getting requirements to build wheel"
reqs
=
self
.
req
.
pep517_backend
.
get_requires_for_build_wheel
()
runner
=
runner_with_spinner_message
(
"Getting requirements to build wheel"
)
backend
=
self
.
req
.
pep517_backend
with
backend
.
subprocess_runner
(
runner
):
reqs
=
backend
.
get_requires_for_build_wheel
()
conflicting
,
missing
=
self
.
req
.
build_env
.
check_requirements
(
reqs
)
if
conflicting
:
_raise_conflicts
(
"the backend dependencies"
,
conflicting
)
...
...
src/pip/_internal/req/req_install.py
浏览文件 @
7d523f32
...
...
@@ -49,16 +49,18 @@ from pip._internal.utils.misc import (
)
from
pip._internal.utils.packaging
import
get_metadata
from
pip._internal.utils.setuptools_build
import
make_setuptools_shim_args
from
pip._internal.utils.subprocess
import
call_subprocess
from
pip._internal.utils.subprocess
import
(
call_subprocess
,
runner_with_spinner_message
,
)
from
pip._internal.utils.temp_dir
import
TempDirectory
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
pip._internal.utils.ui
import
open_spinner
from
pip._internal.utils.virtualenv
import
running_under_virtualenv
from
pip._internal.vcs
import
vcs
if
MYPY_CHECK_RUNNING
:
from
typing
import
(
Any
,
Dict
,
Iterable
,
List
,
Mapping
,
Optional
,
Sequence
,
Union
,
Any
,
Dict
,
Iterable
,
List
,
Optional
,
Sequence
,
Union
,
)
from
pip._internal.build_env
import
BuildEnvironment
from
pip._internal.cache
import
WheelCache
...
...
@@ -547,26 +549,6 @@ class InstallRequirement(object):
self
.
unpacked_source_directory
,
backend
)
# Use a custom function to call subprocesses
self
.
spin_message
=
""
def
runner
(
cmd
,
# type: List[str]
cwd
=
None
,
# type: Optional[str]
extra_environ
=
None
# type: Optional[Mapping[str, Any]]
):
# type: (...) -> None
with
open_spinner
(
self
.
spin_message
)
as
spinner
:
call_subprocess
(
cmd
,
cwd
=
cwd
,
extra_environ
=
extra_environ
,
spinner
=
spinner
)
self
.
spin_message
=
""
self
.
pep517_backend
.
_subprocess_runner
=
runner
def
prepare_metadata
(
self
):
# type: () -> None
"""Ensure that project metadata is available.
...
...
@@ -622,11 +604,12 @@ class InstallRequirement(object):
# Note that Pep517HookCaller implements a fallback for
# prepare_metadata_for_build_wheel, so we don't have to
# consider the possibility that this hook doesn't exist.
runner
=
runner_with_spinner_message
(
"Preparing wheel metadata"
)
backend
=
self
.
pep517_backend
self
.
spin_message
=
"Preparing wheel metadata"
distinfo_dir
=
backend
.
prepare_metadata_for_build_wheel
(
metadata_dir
)
with
backend
.
subprocess_runner
(
runner
):
distinfo_dir
=
backend
.
prepare_metadata_for_build_wheel
(
metadata_dir
)
return
os
.
path
.
join
(
metadata_dir
,
distinfo_dir
)
...
...
@@ -951,15 +934,15 @@ class InstallRequirement(object):
install_args
=
self
.
get_install_args
(
global_options
,
record_filename
,
root
,
prefix
,
pycompile
,
)
msg
=
'Running setup.py install for %s'
%
(
self
.
name
,)
with
open_spinner
(
msg
)
as
spinner
:
with
indent_log
():
with
self
.
build_env
:
call_subprocess
(
install_args
+
install_options
,
cwd
=
self
.
unpacked_source_directory
,
spinner
=
spinner
,
)
runner
=
runner_with_spinner_message
(
"Running setup.py install for {}"
.
format
(
self
.
name
)
)
with
indent_log
(),
self
.
build_env
:
runner
(
cmd
=
install_args
+
install_options
,
cwd
=
self
.
unpacked_source_directory
,
)
if
not
os
.
path
.
exists
(
record_filename
):
logger
.
debug
(
'Record file %s not found'
,
record_filename
)
...
...
src/pip/_internal/utils/logging.py
浏览文件 @
7d523f32
...
...
@@ -9,14 +9,13 @@ import logging
import
logging.handlers
import
os
import
sys
from
logging
import
Filter
from
logging
import
Filter
,
getLogger
from
pip._vendor.six
import
PY2
from
pip._internal.utils.compat
import
WINDOWS
from
pip._internal.utils.deprecation
import
DEPRECATION_MSG_PREFIX
from
pip._internal.utils.misc
import
ensure_dir
from
pip._internal.utils.subprocess
import
subprocess_logger
try
:
import
threading
...
...
@@ -54,6 +53,7 @@ else:
_log_state
=
threading
.
local
()
_log_state
.
indentation
=
0
subprocess_logger
=
getLogger
(
'pip.subprocessor'
)
class
BrokenStdoutLoggingError
(
Exception
):
...
...
src/pip/_internal/utils/subprocess.py
浏览文件 @
7d523f32
...
...
@@ -11,17 +11,20 @@ from pip._vendor.six.moves import shlex_quote
from
pip._internal.exceptions
import
InstallationError
from
pip._internal.utils.compat
import
console_to_str
,
str_to_display
from
pip._internal.utils.logging
import
subprocess_logger
from
pip._internal.utils.misc
import
HiddenText
,
path_to_display
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
pip._internal.utils.ui
import
open_spinner
if
MYPY_CHECK_RUNNING
:
from
typing
import
Any
,
Iterable
,
List
,
Mapping
,
Optional
,
Text
,
Union
from
typing
import
(
Any
,
Callable
,
Iterable
,
List
,
Mapping
,
Optional
,
Text
,
Union
,
)
from
pip._internal.utils.ui
import
SpinnerInterface
CommandArgs
=
List
[
Union
[
str
,
HiddenText
]]
subprocess_logger
=
logging
.
getLogger
(
'pip.subprocessor'
)
LOG_DIVIDER
=
'----------------------------------------'
...
...
@@ -245,3 +248,28 @@ def call_subprocess(
raise
ValueError
(
'Invalid value: on_returncode=%s'
%
repr
(
on_returncode
))
return
''
.
join
(
all_output
)
def
runner_with_spinner_message
(
message
):
# type: (str) -> Callable
"""Provide a subprocess_runner that shows a spinner message.
Intended for use with for pep517's Pep517HookCaller. Thus, the runner has
an API that matches what's expected by Pep517HookCaller.subprocess_runner.
"""
def
runner
(
cmd
,
# type: List[str]
cwd
=
None
,
# type: Optional[str]
extra_environ
=
None
# type: Optional[Mapping[str, Any]]
):
# type: (...) -> None
with
open_spinner
(
message
)
as
spinner
:
call_subprocess
(
cmd
,
cwd
=
cwd
,
extra_environ
=
extra_environ
,
spinner
=
spinner
,
)
return
runner
src/pip/_internal/wheel.py
浏览文件 @
7d523f32
...
...
@@ -44,6 +44,7 @@ from pip._internal.utils.subprocess import (
LOG_DIVIDER
,
call_subprocess
,
format_command_args
,
runner_with_spinner_message
,
)
from
pip._internal.utils.temp_dir
import
TempDirectory
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
...
...
@@ -979,12 +980,17 @@ class WheelBuilder(object):
'--build-options is present'
%
(
req
.
name
,))
return
None
try
:
req
.
spin_message
=
'Building wheel for %s (PEP 517)'
%
(
req
.
name
,)
logger
.
debug
(
'Destination directory: %s'
,
tempd
)
wheel_name
=
req
.
pep517_backend
.
build_wheel
(
tempd
,
metadata_directory
=
req
.
metadata_directory
runner
=
runner_with_spinner_message
(
'Building wheel for {} (PEP 517)'
.
format
(
req
.
name
)
)
backend
=
req
.
pep517_backend
with
backend
.
subprocess_runner
(
runner
):
wheel_name
=
backend
.
build_wheel
(
tempd
,
metadata_directory
=
req
.
metadata_directory
,
)
if
python_tag
:
# General PEP 517 backends don't necessarily support
# a "--python-tag" option, so we rename the wheel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录