Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
91f3dd35
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
91f3dd35
编写于
12月 24, 2020
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the problem that the module's requirments are installed in the wrong order.
上级
64eb312b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
18 deletion
+34
-18
paddlehub/module/manager.py
paddlehub/module/manager.py
+22
-18
paddlehub/utils/pypi.py
paddlehub/utils/pypi.py
+12
-0
未找到文件。
paddlehub/module/manager.py
浏览文件 @
91f3dd35
...
...
@@ -304,10 +304,11 @@ class LocalModuleManager(object):
file
.
write
(
'source: {}
\n
'
.
format
(
source
))
file
.
write
(
'branch: {}'
.
format
(
branch
))
self
.
_local_modules
[
name
]
=
HubModule
.
load
(
installed_path
)
# Install python package requirements, This behavior needs to occur before Module.load,
# otherwise the model will fail to load due to missing dependencies.
self
.
_install_module_requirements
(
installed_path
)
# Install python package requirements
self
.
_install_module_requirements
(
self
.
_local_modules
[
name
])
self
.
_local_modules
[
name
]
=
HubModule
.
load
(
installed_path
)
if
version
:
log
.
logger
.
info
(
'Successfully installed {}-{}'
.
format
(
name
,
version
))
...
...
@@ -337,11 +338,13 @@ class LocalModuleManager(object):
shutil
.
copytree
(
directory
,
self
.
_get_normalized_path
(
module_info
.
name
))
# Install python package requirements, This behavior needs to occur before Module.load,
# otherwise the model will fail to load due to missing dependencies.
self
.
_install_module_requirements
(
directory
)
hub_module_cls
=
HubModule
.
load
(
self
.
_get_normalized_path
(
module_info
.
name
))
self
.
_local_modules
[
module_info
.
name
]
=
hub_module_cls
# Install python package requirements
self
.
_install_module_requirements
(
hub_module_cls
)
log
.
logger
.
info
(
'Successfully installed {}-{}'
.
format
(
hub_module_cls
.
name
,
hub_module_cls
.
version
))
return
hub_module_cls
...
...
@@ -357,19 +360,20 @@ class LocalModuleManager(object):
directory
=
os
.
path
.
join
(
_tdir
,
path
.
split
(
os
.
sep
)[
0
])
return
self
.
_install_from_directory
(
directory
)
def
_install_module_requirements
(
self
,
module
:
HubModule
):
def
_install_module_requirements
(
self
,
directory
:
str
):
rfile
=
os
.
path
.
join
(
directory
,
'requirements.txt'
)
if
not
os
.
path
.
exists
(
rfile
):
return
file
=
utils
.
get_record_file
()
with
open
(
file
,
'a'
)
as
_stream
:
for
py_req
in
module
.
get_py_requirements
():
if
py_req
.
lstrip
().
rstrip
()
==
''
:
continue
with
log
.
logger
.
processing
(
'Installing dependent packages {}'
.
format
(
py_req
)):
result
=
pypi
.
install
(
py_req
,
ostream
=
_stream
,
estream
=
_stream
)
if
result
:
log
.
logger
.
info
(
'Successfully installed dependent packages {}'
.
format
(
py_req
))
else
:
log
.
logger
.
warning
(
'Some errors occurred while installing dependent packages {}. Detailed error information can be found in the {}.'
.
format
(
py_req
,
file
))
with
log
.
logger
.
processing
(
'Installing dependent packages from {}'
.
format
(
rfile
)):
result
=
pypi
.
install_from_file
(
rfile
,
ostream
=
_stream
,
estream
=
_stream
)
if
result
:
log
.
logger
.
info
(
'Successfully installed dependent packages.'
)
else
:
log
.
logger
.
warning
(
'Some errors occurred while installing dependent packages. Detailed error information can be found in the {}.'
.
format
(
file
))
paddlehub/utils/pypi.py
浏览文件 @
91f3dd35
...
...
@@ -59,6 +59,18 @@ def install(package: str, version: str = '', upgrade: bool = False, ostream: IO
return
result
==
0
def
install_from_file
(
file
:
str
,
ostream
:
IO
=
None
,
estream
:
IO
=
None
)
->
bool
:
'''Install the python package.'''
cmd
=
'pip install -r {}'
.
format
(
file
)
result
,
content
=
subprocess
.
getstatusoutput
(
cmd
)
if
result
:
estream
.
write
(
content
)
else
:
ostream
.
write
(
content
)
return
result
==
0
def
uninstall
(
package
:
str
,
ostream
:
IO
=
None
,
estream
:
IO
=
None
)
->
bool
:
'''Uninstall the python package.'''
with
typein
(
'y'
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录