Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
6b57c1f5
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,发现更多精彩内容 >>
提交
6b57c1f5
编写于
9月 29, 2019
作者:
J
John Paton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move outdated outside utils and rename (pypa/pip#6532)
上级
af6f719a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
35 addition
and
28 deletion
+35
-28
docs/html/development/architecture/package-finding.rst
docs/html/development/architecture/package-finding.rst
+1
-1
src/pip/_internal/cli/req_command.py
src/pip/_internal/cli/req_command.py
+5
-2
src/pip/_internal/commands/list.py
src/pip/_internal/commands/list.py
+1
-1
src/pip/_internal/self_outdated_check.py
src/pip/_internal/self_outdated_check.py
+1
-1
src/pip/_vendor/README.rst
src/pip/_vendor/README.rst
+1
-1
tests/unit/test_commands.py
tests/unit/test_commands.py
+5
-4
tests/unit/test_unit_self_outdated_check.py
tests/unit/test_unit_self_outdated_check.py
+21
-18
未找到文件。
docs/html/development/architecture/package-finding.rst
浏览文件 @
6b57c1f5
...
...
@@ -86,7 +86,7 @@ difference may simply be historical and may not actually be necessary.)
Each of these commands also uses the ``PackageFinder`` class for pip's
"self-check," (i.e. to check whether a pip upgrade is available). In this
case, the ``PackageFinder`` instance is created by the ``outdated.py``
module's ``pip_version_check()`` function.
module's ``pip_
self_
version_check()`` function.
The ``PackageFinder`` class is responsible for doing all of the things listed
in the :ref:`Overview <index-py-overview>` section like fetching and parsing
...
...
src/pip/_internal/cli/req_command.py
浏览文件 @
6b57c1f5
...
...
@@ -25,8 +25,11 @@ from pip._internal.req.constructors import (
install_req_from_req_string
,
)
from
pip._internal.req.req_file
import
parse_requirements
from
pip._internal.self_outdated_check
import
(
make_link_collector
,
pip_self_version_check
,
)
from
pip._internal.utils.misc
import
normalize_path
from
pip._internal.utils.outdated
import
make_link_collector
,
pip_version_check
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
if
MYPY_CHECK_RUNNING
:
...
...
@@ -136,7 +139,7 @@ class IndexGroupCommand(Command, SessionCommandMixin):
timeout
=
min
(
5
,
options
.
timeout
)
)
with
session
:
pip_version_check
(
session
,
options
)
pip_
self_
version_check
(
session
,
options
)
class
RequirementCommand
(
IndexGroupCommand
):
...
...
src/pip/_internal/commands/list.py
浏览文件 @
6b57c1f5
...
...
@@ -14,12 +14,12 @@ from pip._internal.cli.req_command import IndexGroupCommand
from
pip._internal.exceptions
import
CommandError
from
pip._internal.index
import
PackageFinder
from
pip._internal.models.selection_prefs
import
SelectionPreferences
from
pip._internal.self_outdated_check
import
make_link_collector
from
pip._internal.utils.misc
import
(
dist_is_editable
,
get_installed_distributions
,
write_output
,
)
from
pip._internal.utils.outdated
import
make_link_collector
from
pip._internal.utils.packaging
import
get_installer
logger
=
logging
.
getLogger
(
__name__
)
...
...
src/pip/_internal/
utils/outdated
.py
→
src/pip/_internal/
self_outdated_check
.py
浏览文件 @
6b57c1f5
...
...
@@ -157,7 +157,7 @@ def was_installed_by_pip(pkg):
return
False
def
pip_version_check
(
session
,
options
):
def
pip_
self_
version_check
(
session
,
options
):
# type: (PipSession, optparse.Values) -> None
"""Check for an update for pip.
...
...
src/pip/_vendor/README.rst
浏览文件 @
6b57c1f5
...
...
@@ -144,7 +144,7 @@ extra work on your end in order to solve the problems described above.
``pip/_vendor/``, then modify ``pip/_vendor/__init__.py`` so that the
``WHEEL_DIR`` variable points to the location you've placed them.
6. *(optional)* Update the ``pip_version_check`` logic to use the
6. *(optional)* Update the ``pip_
self_
version_check`` logic to use the
appropriate logic for determining the latest available version of pip and
prompt the user with the correct upgrade message.
...
...
tests/unit/test_commands.py
浏览文件 @
6b57c1f5
...
...
@@ -73,7 +73,7 @@ def test_index_group_commands():
@
pytest
.
mark
.
parametrize
(
'disable_pip_version_check, no_index, expected_called'
,
[
# pip_version_check() is only called when both
# pip_
self_
version_check() is only called when both
# disable_pip_version_check and no_index are False.
(
False
,
False
,
True
),
(
False
,
True
,
False
),
...
...
@@ -81,14 +81,15 @@ def test_index_group_commands():
(
True
,
True
,
False
),
],
)
@
patch
(
'pip._internal.cli.req_command.pip_version_check'
)
@
patch
(
'pip._internal.cli.req_command.pip_
self_
version_check'
)
def
test_index_group_handle_pip_version_check
(
mock_version_check
,
command_name
,
disable_pip_version_check
,
no_index
,
expected_called
,
):
"""
Test whether pip_version_check() is called when handle_pip_version_check()
is called, for each of the IndexGroupCommand classes.
Test whether pip_self_version_check() is called when
handle_pip_version_check() is called, for each of the
IndexGroupCommand classes.
"""
command
=
create_command
(
command_name
)
options
=
command
.
parser
.
get_default_values
()
...
...
tests/unit/test_unit_
outdated
.py
→
tests/unit/test_unit_
self_outdated_check
.py
浏览文件 @
6b57c1f5
...
...
@@ -9,14 +9,14 @@ import pytest
from
mock
import
patch
from
pip._vendor
import
pkg_resources
from
pip._internal
import
self_outdated_check
from
pip._internal.index
import
InstallationCandidate
from
pip._internal.network.session
import
PipSession
from
pip._internal.utils
import
outdated
from
pip._internal.utils.outdated
import
(
from
pip._internal.self_outdated_check
import
(
SelfCheckState
,
logger
,
make_link_collector
,
pip_version_check
,
pip_
self_
version_check
,
)
from
tests.lib.path
import
Path
...
...
@@ -133,7 +133,8 @@ class MockDistribution(object):
def
_options
():
''' Some default options that we pass to outdated.pip_version_check '''
''' Some default options that we pass to
self_outdated_check.pip_self_version_check '''
return
pretend
.
stub
(
find_links
=
[],
index_url
=
'default_url'
,
extra_index_urls
=
[],
no_index
=
False
,
pre
=
False
,
cache_dir
=
''
,
...
...
@@ -160,12 +161,13 @@ def _options():
(
'1970-01-9T10:00:00Z'
,
'6.9.0'
,
'6.9.0'
,
'pip'
,
False
,
False
),
]
)
def
test_pip_
version_check
(
monkeypatch
,
stored_time
,
installed_ver
,
new
_ver
,
installer
,
check_if_upgrade_required
,
check_warn_logs
):
monkeypatch
.
setattr
(
outdated
,
'get_installed_version'
,
def
test_pip_
self_version_check
(
monkeypatch
,
stored_time
,
installed
_ver
,
new_ver
,
installer
,
check_if_upgrade_required
,
check_warn_logs
):
monkeypatch
.
setattr
(
self_outdated_check
,
'get_installed_version'
,
lambda
name
:
installed_ver
)
monkeypatch
.
setattr
(
outdated
,
'PackageFinder'
,
MockPackageFinder
)
monkeypatch
.
setattr
(
self_outdated_check
,
'PackageFinder'
,
MockPackageFinder
)
monkeypatch
.
setattr
(
logger
,
'warning'
,
pretend
.
call_recorder
(
lambda
*
a
,
**
kw
:
None
))
monkeypatch
.
setattr
(
logger
,
'debug'
,
...
...
@@ -178,7 +180,7 @@ def test_pip_version_check(monkeypatch, stored_time, installed_ver, new_ver,
save
=
pretend
.
call_recorder
(
lambda
v
,
t
:
None
),
)
monkeypatch
.
setattr
(
outdated
,
'SelfCheckState'
,
lambda
**
kw
:
fake_state
self_outdated_check
,
'SelfCheckState'
,
lambda
**
kw
:
fake_state
)
with
freezegun
.
freeze_time
(
...
...
@@ -189,7 +191,7 @@ def test_pip_version_check(monkeypatch, stored_time, installed_ver, new_ver,
"pip._vendor.requests.packages.urllib3.packages.six.moves"
,
]
):
latest_pypi_version
=
pip_version_check
(
None
,
_options
())
latest_pypi_version
=
pip_
self_
version_check
(
None
,
_options
())
# See we return None if not installed_version
if
not
installed_ver
:
...
...
@@ -226,12 +228,12 @@ statefile_name_case_2 = (
(
"C:
\\
Users
\\
User
\\
Desktop
\\
venv"
,
statefile_name_case_2
),
])
def
test_get_statefile_name_known_values
(
key
,
expected
):
assert
expected
==
outdated
.
_get_statefile_name
(
key
)
assert
expected
==
self_outdated_check
.
_get_statefile_name
(
key
)
def
_get_statefile_path
(
cache_dir
,
key
):
return
os
.
path
.
join
(
cache_dir
,
"selfcheck"
,
outdated
.
_get_statefile_name
(
key
)
cache_dir
,
"selfcheck"
,
self_outdated_check
.
_get_statefile_name
(
key
)
)
...
...
@@ -245,7 +247,7 @@ def test_self_check_state_key_uses_sys_prefix(monkeypatch):
key
=
"helloworld"
monkeypatch
.
setattr
(
sys
,
"prefix"
,
key
)
state
=
outdated
.
SelfCheckState
(
""
)
state
=
self_outdated_check
.
SelfCheckState
(
""
)
assert
state
.
key
==
key
...
...
@@ -270,7 +272,7 @@ def test_self_check_state_reads_expected_statefile(monkeypatch, tmpdir):
json
.
dump
(
content
,
f
)
monkeypatch
.
setattr
(
sys
,
"prefix"
,
key
)
state
=
outdated
.
SelfCheckState
(
str
(
cache_dir
))
state
=
self_outdated_check
.
SelfCheckState
(
str
(
cache_dir
))
assert
state
.
state
[
"last_check"
]
==
last_check
assert
state
.
state
[
"pypi_version"
]
==
pypi_version
...
...
@@ -283,12 +285,12 @@ def test_self_check_state_writes_expected_statefile(monkeypatch, tmpdir):
statefile_path
=
_get_statefile_path
(
str
(
cache_dir
),
key
)
last_check
=
datetime
.
datetime
.
strptime
(
"1970-01-02T11:00:00Z"
,
outdated
.
SELFCHECK_DATE_FMT
"1970-01-02T11:00:00Z"
,
self_outdated_check
.
SELFCHECK_DATE_FMT
)
pypi_version
=
"1.0"
monkeypatch
.
setattr
(
sys
,
"prefix"
,
key
)
state
=
outdated
.
SelfCheckState
(
str
(
cache_dir
))
state
=
self_outdated_check
.
SelfCheckState
(
str
(
cache_dir
))
state
.
save
(
pypi_version
,
last_check
)
with
open
(
statefile_path
)
as
f
:
...
...
@@ -296,7 +298,8 @@ def test_self_check_state_writes_expected_statefile(monkeypatch, tmpdir):
expected
=
{
"key"
:
key
,
"last_check"
:
last_check
.
strftime
(
outdated
.
SELFCHECK_DATE_FMT
),
"last_check"
:
last_check
.
strftime
(
self_outdated_check
.
SELFCHECK_DATE_FMT
),
"pypi_version"
:
pypi_version
,
}
assert
expected
==
saved
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录