Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
a18686d4
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,发现更多精彩内容 >>
未验证
提交
a18686d4
编写于
5月 17, 2017
作者:
P
Pradyun S. Gedam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move all of --target stuff into a separate function
上级
2dd2375c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
50 deletion
+56
-50
pip/commands/install.py
pip/commands/install.py
+56
-50
未找到文件。
pip/commands/install.py
浏览文件 @
a18686d4
...
...
@@ -332,59 +332,65 @@ class InstallCommand(RequirementCommand):
requirement_set
.
cleanup_files
()
if
options
.
target_dir
:
ensure_dir
(
options
.
target_dir
)
# Checking both purelib and platlib directories for installed
# packages to be moved to target directory
lib_dir_list
=
[]
purelib_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'purelib'
]
platlib_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'platlib'
]
data_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'data'
]
if
os
.
path
.
exists
(
purelib_dir
):
lib_dir_list
.
append
(
purelib_dir
)
if
os
.
path
.
exists
(
platlib_dir
)
and
platlib_dir
!=
purelib_dir
:
lib_dir_list
.
append
(
platlib_dir
)
if
os
.
path
.
exists
(
data_dir
):
lib_dir_list
.
append
(
data_dir
)
for
lib_dir
in
lib_dir_list
:
for
item
in
os
.
listdir
(
lib_dir
):
if
lib_dir
==
data_dir
:
ddir
=
os
.
path
.
join
(
data_dir
,
item
)
if
any
(
s
.
startswith
(
ddir
)
for
s
in
lib_dir_list
[:
-
1
]):
continue
target_item_dir
=
os
.
path
.
join
(
options
.
target_dir
,
item
)
if
os
.
path
.
exists
(
target_item_dir
):
if
not
options
.
upgrade
:
logger
.
warning
(
'Target directory %s already exists. Specify '
'--upgrade to force replacement.'
,
target_item_dir
)
continue
if
os
.
path
.
islink
(
target_item_dir
):
logger
.
warning
(
'Target directory %s already exists and is '
'a link. Pip will not automatically replace '
'links, please remove if replacement is '
'desired.'
,
target_item_dir
)
continue
if
os
.
path
.
isdir
(
target_item_dir
):
shutil
.
rmtree
(
target_item_dir
)
else
:
os
.
remove
(
target_item_dir
)
self
.
_handle_target_dir
(
options
.
target_dir
,
temp_target_dir
,
options
.
upgrade
)
shutil
.
move
(
os
.
path
.
join
(
lib_dir
,
item
),
target_item_dir
)
shutil
.
rmtree
(
temp_target_dir
)
return
requirement_set
def
_handle_target_dir
(
self
,
target_dir
,
temp_target_dir
,
upgrade
):
ensure_dir
(
target_dir
)
# Checking both purelib and platlib directories for installed
# packages to be moved to target directory
lib_dir_list
=
[]
purelib_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'purelib'
]
platlib_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'platlib'
]
data_dir
=
distutils_scheme
(
''
,
home
=
temp_target_dir
)[
'data'
]
if
os
.
path
.
exists
(
purelib_dir
):
lib_dir_list
.
append
(
purelib_dir
)
if
os
.
path
.
exists
(
platlib_dir
)
and
platlib_dir
!=
purelib_dir
:
lib_dir_list
.
append
(
platlib_dir
)
if
os
.
path
.
exists
(
data_dir
):
lib_dir_list
.
append
(
data_dir
)
for
lib_dir
in
lib_dir_list
:
for
item
in
os
.
listdir
(
lib_dir
):
if
lib_dir
==
data_dir
:
ddir
=
os
.
path
.
join
(
data_dir
,
item
)
if
any
(
s
.
startswith
(
ddir
)
for
s
in
lib_dir_list
[:
-
1
]):
continue
target_item_dir
=
os
.
path
.
join
(
target_dir
,
item
)
if
os
.
path
.
exists
(
target_item_dir
):
if
not
upgrade
:
logger
.
warning
(
'Target directory %s already exists. Specify '
'--upgrade to force replacement.'
,
target_item_dir
)
continue
if
os
.
path
.
islink
(
target_item_dir
):
logger
.
warning
(
'Target directory %s already exists and is '
'a link. Pip will not automatically replace '
'links, please remove if replacement is '
'desired.'
,
target_item_dir
)
continue
if
os
.
path
.
isdir
(
target_item_dir
):
shutil
.
rmtree
(
target_item_dir
)
else
:
os
.
remove
(
target_item_dir
)
shutil
.
move
(
os
.
path
.
join
(
lib_dir
,
item
),
target_item_dir
)
shutil
.
rmtree
(
temp_target_dir
)
def
get_lib_location_guesses
(
*
args
,
**
kwargs
):
scheme
=
distutils_scheme
(
''
,
*
args
,
**
kwargs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录