Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
a0ed759f
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,发现更多精彩内容 >>
未验证
提交
a0ed759f
编写于
2月 01, 2020
作者:
S
Stéphane Bidoul
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add direct_url support to InstallRequirement
pass it to install_wheel via install
上级
94b77130
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
4 deletion
+64
-4
src/pip/_internal/req/req_install.py
src/pip/_internal/req/req_install.py
+10
-0
src/pip/_internal/resolution/legacy/resolver.py
src/pip/_internal/resolution/legacy/resolver.py
+6
-4
tests/functional/test_install_direct_url.py
tests/functional/test_install_direct_url.py
+48
-0
未找到文件。
src/pip/_internal/req/req_install.py
浏览文件 @
a0ed759f
...
...
@@ -31,6 +31,7 @@ from pip._internal.operations.install.wheel import install_wheel
from
pip._internal.pyproject
import
load_pyproject_toml
,
make_pyproject_path
from
pip._internal.req.req_uninstall
import
UninstallPathSet
from
pip._internal.utils.deprecation
import
deprecated
from
pip._internal.utils.direct_url_helpers
import
direct_url_from_link
from
pip._internal.utils.hashes
import
Hashes
from
pip._internal.utils.logging
import
indent_log
from
pip._internal.utils.misc
import
(
...
...
@@ -126,6 +127,7 @@ class InstallRequirement(object):
# PEP 508 URL requirement
link
=
Link
(
req
.
url
)
self
.
link
=
self
.
original_link
=
link
self
.
original_link_is_in_wheel_cache
=
False
# Path to any downloaded or already-existing package.
self
.
local_file_path
=
None
# type: Optional[str]
if
self
.
link
and
self
.
link
.
is_file
:
...
...
@@ -785,6 +787,13 @@ class InstallRequirement(object):
if
self
.
is_wheel
:
assert
self
.
local_file_path
direct_url
=
None
if
self
.
original_link
:
direct_url
=
direct_url_from_link
(
self
.
original_link
,
self
.
source_dir
,
self
.
original_link_is_in_wheel_cache
,
)
install_wheel
(
self
.
name
,
self
.
local_file_path
,
...
...
@@ -792,6 +801,7 @@ class InstallRequirement(object):
req_description
=
str
(
self
.
req
),
pycompile
=
pycompile
,
warn_script_location
=
warn_script_location
,
direct_url
=
direct_url
,
)
self
.
install_succeeded
=
True
return
...
...
src/pip/_internal/resolution/legacy/resolver.py
浏览文件 @
a0ed759f
...
...
@@ -280,14 +280,16 @@ class Resolver(BaseResolver):
if
self
.
wheel_cache
is
None
or
self
.
preparer
.
require_hashes
:
return
cache
d_link
=
self
.
wheel_cache
.
get
(
cache
_entry
=
self
.
wheel_cache
.
get_cache_entry
(
link
=
req
.
link
,
package_name
=
req
.
name
,
supported_tags
=
get_supported
(),
)
if
req
.
link
!=
cached_link
:
logger
.
debug
(
'Using cached wheel link: %s'
,
cached_link
)
req
.
link
=
cached_link
if
cache_entry
is
not
None
:
logger
.
debug
(
'Using cached wheel link: %s'
,
cache_entry
.
link
)
if
req
.
link
is
req
.
original_link
and
cache_entry
.
persistent
:
req
.
original_link_is_in_wheel_cache
=
True
req
.
link
=
cache_entry
.
link
def
_get_abstract_dist_for
(
self
,
req
):
# type: (InstallRequirement) -> AbstractDistribution
...
...
tests/functional/test_install_direct_url.py
0 → 100644
浏览文件 @
a0ed759f
import
re
from
pip._internal.models.direct_url
import
DIRECT_URL_METADATA_NAME
,
DirectUrl
from
tests.lib
import
_create_test_package
,
path_to_url
def
_get_created_direct_url
(
result
,
pkg
):
direct_url_metadata_re
=
re
.
compile
(
pkg
+
r
"-[\d\.]+\.dist-info."
+
DIRECT_URL_METADATA_NAME
+
r
"$"
)
for
filename
in
result
.
files_created
:
if
direct_url_metadata_re
.
search
(
filename
):
direct_url_path
=
result
.
test_env
.
base_path
/
filename
with
open
(
direct_url_path
)
as
f
:
return
DirectUrl
.
from_json
(
f
.
read
())
return
None
def
test_install_find_links_no_direct_url
(
script
,
with_wheel
):
result
=
script
.
pip_install_local
(
"simple"
)
assert
not
_get_created_direct_url
(
result
,
"simple"
)
def
test_install_vcs_editable_no_direct_url
(
script
,
with_wheel
):
pkg_path
=
_create_test_package
(
script
,
name
=
"testpkg"
)
args
=
[
"install"
,
"-e"
,
"git+%s#egg=testpkg"
%
path_to_url
(
pkg_path
)]
result
=
script
.
pip
(
*
args
)
# legacy editable installs do not generate .dist-info,
# hence no direct_url.json
assert
not
_get_created_direct_url
(
result
,
"testpkg"
)
def
test_install_vcs_non_editable_direct_url
(
script
,
with_wheel
):
pkg_path
=
_create_test_package
(
script
,
name
=
"testpkg"
)
url
=
path_to_url
(
pkg_path
)
args
=
[
"install"
,
"git+{}#egg=testpkg"
.
format
(
url
)]
result
=
script
.
pip
(
*
args
)
direct_url
=
_get_created_direct_url
(
result
,
"testpkg"
)
assert
direct_url
assert
direct_url
.
url
==
url
assert
direct_url
.
info
.
vcs
==
"git"
def
test_install_archive_direct_url
(
script
,
data
,
with_wheel
):
req
=
"simple @ "
+
path_to_url
(
data
.
packages
/
"simple-2.0.tar.gz"
)
assert
req
.
startswith
(
"simple @ file://"
)
result
=
script
.
pip
(
"install"
,
req
)
assert
_get_created_direct_url
(
result
,
"simple"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录