diff options
author | Thomas Bechtold <tbechtold@suse.com> | 2017-08-31 07:06:39 +0200 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-09-05 15:54:07 +0900 |
commit | 0673a8868e4447e7b2ec551c720aeb929993727d (patch) | |
tree | f4ac8bb1c00aa784452beb9f5ea475f66e8b02ac | |
parent | 1782f54f3cebf6b32b513f725d94cbfbf1c19ee3 (diff) |
Only import pip if needed
In some systems pip is not installed and the parse_requirements() function
is not needed. So only import pip if needed. Otherwise this fails with:
from ryu.base import app_manager
File "/usr/lib/python2.7/site-packages/ryu/base/app_manager.py", line 34, in <module>
from ryu import utils
File "/usr/lib/python2.7/site-packages/ryu/utils.py", line 23, in <module>
from pip import req as pip_req
ImportError: No module named pip
Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ryu/utils.py b/ryu/utils.py index d8bbc53b..8bfdf7da 100644 --- a/ryu/utils.py +++ b/ryu/utils.py @@ -20,8 +20,6 @@ import os import sys import six -from pip import req as pip_req -from pip.download import PipSession LOG = logging.getLogger('ryu.utils') @@ -142,6 +140,9 @@ def parse_requirements(requirements_files=None): is ['requirements.txt', 'tools/pip-requires']. :return: List of requirements. """ + from pip import req as pip_req + from pip.download import PipSession + requirements_files = requirements_files or [ 'requirements.txt', 'tools/pip-requires', |