Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
9cbe8fbd
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,发现更多精彩内容 >>
未验证
提交
9cbe8fbd
编写于
4月 10, 2020
作者:
P
Pradyun Gedam
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7978 from sbidoul/remove-pip-egg-info-sbi
Generate legacy metadata in temporary directory
上级
81f10548
030578ef
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
69 deletion
+21
-69
src/pip/_internal/operations/build/metadata_legacy.py
src/pip/_internal/operations/build/metadata_legacy.py
+18
-63
src/pip/_internal/req/req_install.py
src/pip/_internal/req/req_install.py
+0
-3
src/pip/_internal/utils/setuptools_build.py
src/pip/_internal/utils/setuptools_build.py
+3
-3
未找到文件。
src/pip/_internal/operations/build/metadata_legacy.py
浏览文件 @
9cbe8fbd
...
...
@@ -5,84 +5,44 @@ import logging
import
os
from
pip._internal.exceptions
import
InstallationError
from
pip._internal.utils.misc
import
ensure_dir
from
pip._internal.utils.setuptools_build
import
make_setuptools_egg_info_args
from
pip._internal.utils.subprocess
import
call_subprocess
from
pip._internal.utils.temp_dir
import
TempDirectory
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
pip._internal.vcs
import
vcs
if
MYPY_CHECK_RUNNING
:
from
typing
import
List
,
Optional
from
pip._internal.build_env
import
BuildEnvironment
logger
=
logging
.
getLogger
(
__name__
)
def
_find_egg_info
(
source_directory
,
is_editable
):
# type: (str
, bool
) -> str
"""Find an .egg-info
in `source_directory`, based on `is_editable
`.
def
_find_egg_info
(
directory
):
# type: (str) -> str
"""Find an .egg-info
subdirectory in `directory
`.
"""
def
looks_like_virtual_env
(
path
):
# type: (str) -> bool
return
(
os
.
path
.
lexists
(
os
.
path
.
join
(
path
,
'bin'
,
'python'
))
or
os
.
path
.
exists
(
os
.
path
.
join
(
path
,
'Scripts'
,
'Python.exe'
))
)
def
locate_editable_egg_info
(
base
):
# type: (str) -> List[str]
candidates
=
[]
# type: List[str]
for
root
,
dirs
,
files
in
os
.
walk
(
base
):
for
dir_
in
vcs
.
dirnames
:
if
dir_
in
dirs
:
dirs
.
remove
(
dir_
)
# Iterate over a copy of ``dirs``, since mutating
# a list while iterating over it can cause trouble.
# (See https://github.com/pypa/pip/pull/462.)
for
dir_
in
list
(
dirs
):
if
looks_like_virtual_env
(
os
.
path
.
join
(
root
,
dir_
)):
dirs
.
remove
(
dir_
)
# Also don't search through tests
elif
dir_
==
'test'
or
dir_
==
'tests'
:
dirs
.
remove
(
dir_
)
candidates
.
extend
(
os
.
path
.
join
(
root
,
dir_
)
for
dir_
in
dirs
)
return
[
f
for
f
in
candidates
if
f
.
endswith
(
'.egg-info'
)]
def
depth_of_directory
(
dir_
):
# type: (str) -> int
return
(
dir_
.
count
(
os
.
path
.
sep
)
+
(
os
.
path
.
altsep
and
dir_
.
count
(
os
.
path
.
altsep
)
or
0
)
)
base
=
source_directory
if
is_editable
:
filenames
=
locate_editable_egg_info
(
base
)
else
:
base
=
os
.
path
.
join
(
base
,
'pip-egg-info'
)
filenames
=
os
.
listdir
(
base
)
filenames
=
[
f
for
f
in
os
.
listdir
(
directory
)
if
f
.
endswith
(
".egg-info"
)
]
if
not
filenames
:
raise
InstallationError
(
"
Files/directories not found in {}"
.
format
(
base
)
"
No .egg-info directory found in {}"
.
format
(
directory
)
)
# If we have more than one match, we pick the toplevel one. This
# can easily be the case if there is a dist folder which contains
# an extracted tarball for testing purposes.
if
len
(
filenames
)
>
1
:
filenames
.
sort
(
key
=
depth_of_directory
)
raise
InstallationError
(
"More than one .egg-info directory found in {}"
.
format
(
directory
)
)
return
os
.
path
.
join
(
base
,
filenames
[
0
])
return
os
.
path
.
join
(
directory
,
filenames
[
0
])
def
generate_metadata
(
build_env
,
# type: BuildEnvironment
setup_py_path
,
# type: str
source_dir
,
# type: str
editable
,
# type: bool
isolated
,
# type: bool
details
,
# type: str
):
...
...
@@ -96,14 +56,9 @@ def generate_metadata(
setup_py_path
,
details
,
)
egg_info_dir
=
None
# type: Optional[str]
# For non-editable installs, don't put the .egg-info files at the root,
# to avoid confusion due to the source code being considered an installed
# egg.
if
not
editable
:
egg_info_dir
=
os
.
path
.
join
(
source_dir
,
'pip-egg-info'
)
# setuptools complains if the target directory does not exist.
ensure_dir
(
egg_info_dir
)
egg_info_dir
=
TempDirectory
(
kind
=
"pip-egg-info"
,
globally_managed
=
True
).
path
args
=
make_setuptools_egg_info_args
(
setup_py_path
,
...
...
@@ -119,4 +74,4 @@ def generate_metadata(
)
# Return the .egg-info directory.
return
_find_egg_info
(
source_dir
,
editable
)
return
_find_egg_info
(
egg_info_dir
)
src/pip/_internal/req/req_install.py
浏览文件 @
9cbe8fbd
...
...
@@ -517,7 +517,6 @@ class InstallRequirement(object):
build_env
=
self
.
build_env
,
setup_py_path
=
self
.
setup_py_path
,
source_dir
=
self
.
unpacked_source_directory
,
editable
=
self
.
editable
,
isolated
=
self
.
isolated
,
details
=
self
.
name
or
"from {}"
.
format
(
self
.
link
)
)
...
...
@@ -730,8 +729,6 @@ class InstallRequirement(object):
os
.
path
.
abspath
(
self
.
unpacked_source_directory
)
)
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
dir
):
if
'pip-egg-info'
in
dirnames
:
dirnames
.
remove
(
'pip-egg-info'
)
for
dirname
in
dirnames
:
dir_arcname
=
self
.
_get_archive_name
(
dirname
,
parentdir
=
dirpath
,
rootdir
=
dir
,
...
...
src/pip/_internal/utils/setuptools_build.py
浏览文件 @
9cbe8fbd
...
...
@@ -121,9 +121,9 @@ def make_setuptools_egg_info_args(
no_user_config
,
# type: bool
):
# type: (...) -> List[str]
args
=
make_setuptools_shim_args
(
setup_py_path
)
if
no_user_config
:
args
+=
[
"--no-user-cfg"
]
args
=
make_setuptools_shim_args
(
setup_py_path
,
no_user_config
=
no_user_config
)
args
+=
[
"egg_info"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录