Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
f76014ef
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,发现更多精彩内容 >>
提交
f76014ef
编写于
7月 28, 2019
作者:
P
Prabakaran Kumaresshan
提交者:
Chris Jerdonek
7月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add global options and no user config args to make_setuptools_shim_args (#6706)
上级
2cd26a22
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
31 deletion
+82
-31
src/pip/_internal/req/req_install.py
src/pip/_internal/req/req_install.py
+17
-17
src/pip/_internal/utils/setuptools_build.py
src/pip/_internal/utils/setuptools_build.py
+14
-3
src/pip/_internal/wheel.py
src/pip/_internal/wheel.py
+5
-3
tests/unit/test_utils.py
tests/unit/test_utils.py
+46
-8
未找到文件。
src/pip/_internal/req/req_install.py
浏览文件 @
f76014ef
...
...
@@ -616,9 +616,10 @@ class InstallRequirement(object):
'Running setup.py (path:%s) egg_info for package from %s'
,
self
.
setup_py_path
,
self
.
link
,
)
base_cmd
=
make_setuptools_shim_args
(
self
.
setup_py_path
)
if
self
.
isolated
:
base_cmd
+=
[
"--no-user-cfg"
]
base_cmd
=
make_setuptools_shim_args
(
self
.
setup_py_path
,
no_user_config
=
self
.
isolated
)
egg_info_cmd
=
base_cmd
+
[
'egg_info'
]
# We can't put the .egg-info files at the root, because then the
# source code will be mistaken for an installed egg, causing
...
...
@@ -763,19 +764,19 @@ class InstallRequirement(object):
# type: (...) -> None
logger
.
info
(
'Running setup.py develop for %s'
,
self
.
name
)
if
self
.
isolated
:
global_options
=
list
(
global_options
)
+
[
"--no-user-cfg"
]
if
prefix
:
prefix_param
=
[
'--prefix={}'
.
format
(
prefix
)]
install_options
=
list
(
install_options
)
+
prefix_param
base_cmd
=
make_setuptools_shim_args
(
self
.
setup_py_path
,
global_options
=
global_options
,
no_user_config
=
self
.
isolated
)
with
indent_log
():
# FIXME: should we do --install-headers here too?
with
self
.
build_env
:
call_subprocess
(
make_setuptools_shim_args
(
self
.
setup_py_path
)
+
list
(
global_options
)
+
base_cmd
+
[
'develop'
,
'--no-deps'
]
+
list
(
install_options
),
...
...
@@ -948,10 +949,6 @@ class InstallRequirement(object):
install_options
=
list
(
install_options
)
+
\
self
.
options
.
get
(
'install_options'
,
[])
if
self
.
isolated
:
# https://github.com/python/mypy/issues/1174
global_options
=
global_options
+
[
"--no-user-cfg"
]
# type: ignore
with
TempDirectory
(
kind
=
"record"
)
as
temp_dir
:
record_filename
=
os
.
path
.
join
(
temp_dir
.
path
,
'install-record.txt'
)
install_args
=
self
.
get_install_args
(
...
...
@@ -1018,10 +1015,13 @@ class InstallRequirement(object):
pycompile
# type: bool
):
# type: (...) -> List[str]
install_args
=
make_setuptools_shim_args
(
self
.
setup_py_path
,
unbuffered_output
=
True
)
install_args
+=
list
(
global_options
)
+
\
[
'install'
,
'--record'
,
record_filename
]
install_args
=
make_setuptools_shim_args
(
self
.
setup_py_path
,
global_options
=
global_options
,
no_user_config
=
self
.
isolated
,
unbuffered_output
=
True
)
install_args
+=
[
'install'
,
'--record'
,
record_filename
]
install_args
+=
[
'--single-version-externally-managed'
]
if
root
is
not
None
:
...
...
src/pip/_internal/utils/setuptools_build.py
浏览文件 @
f76014ef
...
...
@@ -3,7 +3,7 @@ import sys
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
if
MYPY_CHECK_RUNNING
:
from
typing
import
List
from
typing
import
List
,
Sequence
# Shim to wrap setup.py invocation with setuptools
#
...
...
@@ -20,12 +20,19 @@ _SETUPTOOLS_SHIM = (
)
def
make_setuptools_shim_args
(
setup_py_path
,
unbuffered_output
=
False
):
# type: (str, bool) -> List[str]
def
make_setuptools_shim_args
(
setup_py_path
,
# type: str
global_options
=
None
,
# type: Sequence[str]
no_user_config
=
False
,
# type: bool
unbuffered_output
=
False
# type: bool
):
# type: (...) -> List[str]
"""
Get setuptools command arguments with shim wrapped setup file invocation.
:param setup_py_path: The path to setup.py to be wrapped.
:param global_options: Additional global options.
:param no_user_config: If True, disables personal user configuration.
:param unbuffered_output: If True, adds the unbuffered switch to the
argument list.
"""
...
...
@@ -33,4 +40,8 @@ def make_setuptools_shim_args(setup_py_path, unbuffered_output=False):
if
unbuffered_output
:
args
.
append
(
'-u'
)
args
.
extend
([
'-c'
,
_SETUPTOOLS_SHIM
.
format
(
setup_py_path
)])
if
global_options
:
args
.
extend
(
global_options
)
if
no_user_config
:
args
.
append
(
'--no-user-cfg'
)
return
args
src/pip/_internal/wheel.py
浏览文件 @
f76014ef
...
...
@@ -934,9 +934,11 @@ class WheelBuilder(object):
# isolating. Currently, it breaks Python in virtualenvs, because it
# relies on site.py to find parts of the standard library outside the
# virtualenv.
base_cmd
=
make_setuptools_shim_args
(
req
.
setup_py_path
,
unbuffered_output
=
True
)
return
base_cmd
+
list
(
self
.
global_options
)
return
make_setuptools_shim_args
(
req
.
setup_py_path
,
global_options
=
self
.
global_options
,
unbuffered_output
=
True
)
def
_build_one_pep517
(
self
,
req
,
tempd
,
python_tag
=
None
):
"""Build one InstallRequirement using the PEP 517 build process.
...
...
tests/unit/test_utils.py
浏览文件 @
f76014ef
...
...
@@ -1405,16 +1405,54 @@ def test_deprecated_message_reads_well():
)
@
pytest
.
mark
.
parametrize
(
"unbuffered_output"
,
[
False
,
True
])
def
test_make_setuptools_shim_args
(
unbuffered_output
):
def
test_make_setuptools_shim_args
():
# Test all arguments at once, including the overall ordering.
args
=
make_setuptools_shim_args
(
"/dir/path/setup.py"
,
unbuffered_output
=
unbuffered_output
'/dir/path/setup.py'
,
global_options
=
[
'--some'
,
'--option'
],
no_user_config
=
True
,
unbuffered_output
=
True
,
)
assert
args
[
1
:
3
]
==
[
'-u'
,
'-c'
]
# Spot-check key aspects of the command string.
assert
"sys.argv[0] = '/dir/path/setup.py'"
in
args
[
3
]
assert
"__file__='/dir/path/setup.py'"
in
args
[
3
]
assert
args
[
4
:]
==
[
'--some'
,
'--option'
,
'--no-user-cfg'
]
@
pytest
.
mark
.
parametrize
(
'global_options'
,
[
None
,
[],
[
'--some'
,
'--option'
]
])
def
test_make_setuptools_shim_args__global_options
(
global_options
):
args
=
make_setuptools_shim_args
(
'/dir/path/setup.py'
,
global_options
=
global_options
,
)
assert
(
"-u"
in
args
)
==
unbuffered_output
if
global_options
:
assert
len
(
args
)
==
5
for
option
in
global_options
:
assert
option
in
args
else
:
assert
len
(
args
)
==
3
assert
args
[
-
2
]
==
"-c"
assert
"sys.argv[0] = '/dir/path/setup.py'"
in
args
[
-
1
]
assert
"__file__='/dir/path/setup.py'"
in
args
[
-
1
]
@
pytest
.
mark
.
parametrize
(
'no_user_config'
,
[
False
,
True
])
def
test_make_setuptools_shim_args__no_user_config
(
no_user_config
):
args
=
make_setuptools_shim_args
(
'/dir/path/setup.py'
,
no_user_config
=
no_user_config
,
)
assert
(
'--no-user-cfg'
in
args
)
==
no_user_config
@
pytest
.
mark
.
parametrize
(
'unbuffered_output'
,
[
False
,
True
])
def
test_make_setuptools_shim_args__unbuffered_output
(
unbuffered_output
):
args
=
make_setuptools_shim_args
(
'/dir/path/setup.py'
,
unbuffered_output
=
unbuffered_output
)
assert
(
'-u'
in
args
)
==
unbuffered_output
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录