Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
2956a3ef
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,发现更多精彩内容 >>
提交
2956a3ef
编写于
10月 10, 2015
作者:
X
Xavier Fernandez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add --all option to pip freeze
In order to include pip/setuptools/wheel in the freeze output Closes #1610
上级
ceb79a63
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
33 addition
and
10 deletion
+33
-10
CHANGES.txt
CHANGES.txt
+3
-0
pip/commands/freeze.py
pip/commands/freeze.py
+16
-1
pip/operations/freeze.py
pip/operations/freeze.py
+6
-7
tests/functional/test_freeze.py
tests/functional/test_freeze.py
+6
-0
tests/unit/test_utils.py
tests/unit/test_utils.py
+2
-2
未找到文件。
CHANGES.txt
浏览文件 @
2956a3ef
...
@@ -17,6 +17,9 @@
...
@@ -17,6 +17,9 @@
* Fix PipDeprecationWarning so that warnings can be turned off by
* Fix PipDeprecationWarning so that warnings can be turned off by
``-W`` / ``PYTHONWARNINGS`` (:pull:`3455`)
``-W`` / ``PYTHONWARNINGS`` (:pull:`3455`)
* Add a `--all` option to `pip freeze` to include usually skipped package
(like pip, setuptools and wheel) to the freeze output. :issue:`1610`.
**8.0.2 (2016-01-21)**
**8.0.2 (2016-01-21)**
...
...
pip/commands/freeze.py
浏览文件 @
2956a3ef
...
@@ -3,11 +3,15 @@ from __future__ import absolute_import
...
@@ -3,11 +3,15 @@ from __future__ import absolute_import
import
sys
import
sys
import
pip
import
pip
from
pip.compat
import
stdlib_pkgs
from
pip.basecommand
import
Command
from
pip.basecommand
import
Command
from
pip.operations.freeze
import
freeze
from
pip.operations.freeze
import
freeze
from
pip.wheel
import
WheelCache
from
pip.wheel
import
WheelCache
DEV_PKGS
=
(
'pip'
,
'setuptools'
,
'distribute'
,
'wheel'
)
class
FreezeCommand
(
Command
):
class
FreezeCommand
(
Command
):
"""
"""
Output installed packages in requirements format.
Output installed packages in requirements format.
...
@@ -52,12 +56,22 @@ class FreezeCommand(Command):
...
@@ -52,12 +56,22 @@ class FreezeCommand(Command):
action
=
'store_true'
,
action
=
'store_true'
,
default
=
False
,
default
=
False
,
help
=
'Only output packages installed in user-site.'
)
help
=
'Only output packages installed in user-site.'
)
self
.
cmd_opts
.
add_option
(
'--all'
,
dest
=
'freeze_all'
,
action
=
'store_true'
,
help
=
'Do not skip these packages in the output:'
' %s'
%
', '
.
join
(
DEV_PKGS
))
self
.
parser
.
insert_option_group
(
0
,
self
.
cmd_opts
)
self
.
parser
.
insert_option_group
(
0
,
self
.
cmd_opts
)
def
run
(
self
,
options
,
args
):
def
run
(
self
,
options
,
args
):
format_control
=
pip
.
index
.
FormatControl
(
set
(),
set
())
format_control
=
pip
.
index
.
FormatControl
(
set
(),
set
())
wheel_cache
=
WheelCache
(
options
.
cache_dir
,
format_control
)
wheel_cache
=
WheelCache
(
options
.
cache_dir
,
format_control
)
skip
=
set
(
stdlib_pkgs
)
if
not
options
.
freeze_all
:
skip
.
update
(
DEV_PKGS
)
freeze_kwargs
=
dict
(
freeze_kwargs
=
dict
(
requirement
=
options
.
requirement
,
requirement
=
options
.
requirement
,
find_links
=
options
.
find_links
,
find_links
=
options
.
find_links
,
...
@@ -65,7 +79,8 @@ class FreezeCommand(Command):
...
@@ -65,7 +79,8 @@ class FreezeCommand(Command):
user_only
=
options
.
user
,
user_only
=
options
.
user
,
skip_regex
=
options
.
skip_requirements_regex
,
skip_regex
=
options
.
skip_requirements_regex
,
isolated
=
options
.
isolated_mode
,
isolated
=
options
.
isolated_mode
,
wheel_cache
=
wheel_cache
)
wheel_cache
=
wheel_cache
,
skip
=
skip
)
for
line
in
freeze
(
**
freeze_kwargs
):
for
line
in
freeze
(
**
freeze_kwargs
):
sys
.
stdout
.
write
(
line
+
'
\n
'
)
sys
.
stdout
.
write
(
line
+
'
\n
'
)
pip/operations/freeze.py
浏览文件 @
2956a3ef
...
@@ -4,23 +4,21 @@ import logging
...
@@ -4,23 +4,21 @@ import logging
import
re
import
re
import
pip
import
pip
from
pip.compat
import
stdlib_pkgs
from
pip.req
import
InstallRequirement
from
pip.req
import
InstallRequirement
from
pip.utils
import
get_installed_distributions
from
pip.utils
import
canonicalize_name
,
get_installed_distributions
from
pip._vendor
import
pkg_resources
from
pip._vendor
import
pkg_resources
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
freeze_excludes
=
stdlib_pkgs
+
(
'setuptools'
,
'pip'
,
'distribute'
,
'wheel'
)
def
freeze
(
def
freeze
(
requirement
=
None
,
requirement
=
None
,
find_links
=
None
,
local_only
=
None
,
user_only
=
None
,
skip_regex
=
None
,
find_links
=
None
,
local_only
=
None
,
user_only
=
None
,
skip_regex
=
None
,
default_vcs
=
None
,
default_vcs
=
None
,
isolated
=
False
,
isolated
=
False
,
wheel_cache
=
None
):
wheel_cache
=
None
,
skip
=
()):
find_links
=
find_links
or
[]
find_links
=
find_links
or
[]
skip_match
=
None
skip_match
=
None
...
@@ -41,7 +39,7 @@ def freeze(
...
@@ -41,7 +39,7 @@ def freeze(
yield
'-f %s'
%
link
yield
'-f %s'
%
link
installations
=
{}
installations
=
{}
for
dist
in
get_installed_distributions
(
local_only
=
local_only
,
for
dist
in
get_installed_distributions
(
local_only
=
local_only
,
skip
=
freeze_excludes
,
skip
=
()
,
user_only
=
user_only
):
user_only
=
user_only
):
req
=
pip
.
FrozenRequirement
.
from_dist
(
req
=
pip
.
FrozenRequirement
.
from_dist
(
dist
,
dist
,
...
@@ -111,4 +109,5 @@ def freeze(
...
@@ -111,4 +109,5 @@ def freeze(
)
)
for
installation
in
sorted
(
for
installation
in
sorted
(
installations
.
values
(),
key
=
lambda
x
:
x
.
name
.
lower
()):
installations
.
values
(),
key
=
lambda
x
:
x
.
name
.
lower
()):
if
canonicalize_name
(
installation
.
name
)
not
in
skip
:
yield
str
(
installation
).
rstrip
()
yield
str
(
installation
).
rstrip
()
tests/functional/test_freeze.py
浏览文件 @
2956a3ef
...
@@ -63,6 +63,12 @@ def test_freeze_basic(script):
...
@@ -63,6 +63,12 @@ def test_freeze_basic(script):
_check_output
(
result
.
stdout
,
expected
)
_check_output
(
result
.
stdout
,
expected
)
def
test_freeze_with_pip
(
script
):
"""Test pip shows itself"""
result
=
script
.
pip
(
'freeze'
,
'--all'
)
assert
'pip=='
in
result
.
stdout
@
pytest
.
mark
.
svn
@
pytest
.
mark
.
svn
def
test_freeze_svn
(
script
,
tmpdir
):
def
test_freeze_svn
(
script
,
tmpdir
):
"""Test freezing a svn checkout"""
"""Test freezing a svn checkout"""
...
...
tests/unit/test_utils.py
浏览文件 @
2956a3ef
...
@@ -16,7 +16,6 @@ from pip.exceptions import HashMismatch, HashMissing, InstallationError
...
@@ -16,7 +16,6 @@ from pip.exceptions import HashMismatch, HashMissing, InstallationError
from
pip.utils
import
(
egg_link_path
,
get_installed_distributions
,
from
pip.utils
import
(
egg_link_path
,
get_installed_distributions
,
untar_file
,
unzip_file
,
rmtree
,
normalize_path
)
untar_file
,
unzip_file
,
rmtree
,
normalize_path
)
from
pip.utils.hashes
import
Hashes
,
MissingHashes
from
pip.utils.hashes
import
Hashes
,
MissingHashes
from
pip.operations.freeze
import
freeze_excludes
from
pip._vendor.six
import
BytesIO
from
pip._vendor.six
import
BytesIO
...
@@ -261,7 +260,8 @@ class Tests_get_installed_distributions:
...
@@ -261,7 +260,8 @@ class Tests_get_installed_distributions:
mock_dist_is_editable
.
side_effect
=
self
.
dist_is_editable
mock_dist_is_editable
.
side_effect
=
self
.
dist_is_editable
mock_dist_is_local
.
side_effect
=
self
.
dist_is_local
mock_dist_is_local
.
side_effect
=
self
.
dist_is_local
mock_dist_in_usersite
.
side_effect
=
self
.
dist_in_usersite
mock_dist_in_usersite
.
side_effect
=
self
.
dist_in_usersite
dists
=
get_installed_distributions
(
skip
=
freeze_excludes
)
dists
=
get_installed_distributions
(
skip
=
(
'setuptools'
,
'pip'
,
'distribute'
))
assert
len
(
dists
)
==
0
assert
len
(
dists
)
==
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录