Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
0eb566fa
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,发现更多精彩内容 >>
未验证
提交
0eb566fa
编写于
6月 19, 2018
作者:
P
Pradyun Gedam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rework PEP 518 requirement logic
上级
a25cb53d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
49 deletion
+49
-49
src/pip/_internal/operations/prepare.py
src/pip/_internal/operations/prepare.py
+22
-20
src/pip/_internal/req/req_install.py
src/pip/_internal/req/req_install.py
+27
-29
未找到文件。
src/pip/_internal/operations/prepare.py
浏览文件 @
0eb566fa
...
...
@@ -95,31 +95,33 @@ class IsSDist(DistAbstraction):
def
prep_for_dist
(
self
,
finder
,
build_isolation
):
# Before calling "setup.py egg_info", we need to set-up the build
# environment.
build_requirements
,
isolate
=
self
.
req
.
get_pep_518_info
()
should_isolate
=
build_isolation
and
isolate
minimum_requirements
=
(
'setuptools'
,
'wheel'
)
missing_requirements
=
set
(
minimum_requirements
)
-
set
(
pkg_resources
.
Requirement
(
r
).
key
for
r
in
build_requirements
)
if
missing_requirements
:
def
format_reqs
(
rs
):
return
' and '
.
join
(
map
(
repr
,
sorted
(
rs
)))
logger
.
warning
(
"Missing build time requirements in pyproject.toml for %s: "
"%s."
,
self
.
req
,
format_reqs
(
missing_requirements
)
)
logger
.
warning
(
"This version of pip does not implement PEP 517 so it cannot "
"build a wheel without %s."
,
format_reqs
(
minimum_requirements
)
)
build_requirements
=
self
.
req
.
get_pep_518_info
()
should_isolate
=
build_isolation
and
build_requirements
is
not
None
if
should_isolate
:
# Haven't implemented PEP 517 yet, so spew a warning about it if
# build-requirements don't include setuptools and wheel.
missing_requirements
=
{
'setuptools'
,
'wheel'
}
-
{
pkg_resources
.
Requirement
(
r
).
key
for
r
in
build_requirements
}
if
missing_requirements
:
logger
.
warning
(
"Missing build requirements in pyproject.toml for %s."
,
self
.
req
,
)
logger
.
warning
(
"This version of pip does not implement PEP 517 so it "
"cannot build a wheel without %s."
,
" and "
.
join
(
map
(
repr
,
sorted
(
missing_requirements
)))
)
# Isolate in a BuildEnvironment and install the build-time
# requirements.
self
.
req
.
build_env
=
BuildEnvironment
()
self
.
req
.
build_env
.
install_requirements
(
finder
,
build_requirements
,
"Installing build dependencies"
)
"Installing build dependencies"
)
self
.
req
.
run_egg_info
()
self
.
req
.
assert_source_matches_version
()
...
...
src/pip/_internal/req/req_install.py
浏览文件 @
0eb566fa
...
...
@@ -560,42 +560,40 @@ class InstallRequirement(object):
return
pp_toml
def
get_pep_518_info
(
self
):
"""Get a list of the packages required to build the project, if any,
and a flag indicating whether pyproject.toml is present, indicating
that the build should be isolated.
"""Get PEP 518 build-time requirements.
Build requirements can be specified in a pyproject.toml, as described
in PEP 518. If this file exists but doesn't specify build
requirements, pip will default to installing setuptools and wheel
.
Returns the list of the packages required to build the project,
specified as per PEP 518 within the package. If `pyproject.toml` is not
present, returns None to signify not using the same
.
"""
if
os
.
path
.
isfile
(
self
.
pyproject_toml
):
with
io
.
open
(
self
.
pyproject_toml
,
encoding
=
"utf-8"
)
as
f
:
pp_toml
=
pytoml
.
load
(
f
)
if
not
os
.
path
.
isfile
(
self
.
pyproject_toml
):
return
None
build_system
=
pp_toml
.
get
(
'build-system'
,
{})
if
"requires"
not
in
build_system
:
raise
InstallationError
(
"{} does not comply with PEP 518 as it since it's "
"pyproject.toml file does not have a '[build-system]' "
"table with a 'requires' key."
.
format
(
self
)
)
with
io
.
open
(
self
.
pyproject_toml
,
encoding
=
"utf-8"
)
as
f
:
pp_toml
=
pytoml
.
load
(
f
)
requires
=
build_system
[
"requires"
]
# Extract the build requirements
requires
=
pp_toml
.
get
(
"build-system"
,
{}).
get
(
"requires"
,
None
)
# Error out if it's not valid
error_reason
=
None
if
requires
is
None
:
error_reason
=
"is missing."
else
:
is_list_of_str
=
isinstance
(
requires
,
list
)
and
all
(
isinstance
(
req
,
s
tr
)
for
req
in
requires
isinstance
(
req
,
s
ix
.
string_types
)
for
req
in
requires
)
if
not
is_list_of_str
:
raise
InstallationError
(
"{} does not comply with PEP 518 as it since it's "
"pyproject.toml file contains [build-system].requires "
"which is not a list of strings.
"
.
format
(
self
)
)
return
requires
,
True
return
([
'setuptools'
,
'wheel'
],
False
)
error_reason
=
"not a list of strings."
if
error_reason
is
not
None
:
msg
=
(
"{} does not comply with PEP 518 since pyproject.toml does
"
"not contain a valid '[build-system].requires' key: {}"
).
format
(
self
,
error_reason
)
raise
InstallationError
(
msg
)
# If control flow reaches here, we're good to go.
return
requires
def
run_egg_info
(
self
):
assert
self
.
source_dir
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录