tox: make install_sibling_packages pip import optional

This enable using the tox role without pip module installed on the host

Change-Id: Ic2c9e75ed967faf93267b6b9c58fdf3b02837ea9
This commit is contained in:
Tristan Cacqueray 2017-12-05 09:13:01 +00:00
parent ea5c3d08da
commit 62015d9e15

View File

@ -52,8 +52,12 @@ try:
except ImportError:
import ConfigParser as configparser
try:
import pip
except ImportError:
pip = None
import os
import pip
import subprocess
import tempfile
@ -80,6 +84,8 @@ def get_sibling_python_packages(projects):
def get_installed_packages(tox_python):
if pip is None:
raise RuntimeError("pip python module is required")
with tempfile.NamedTemporaryFile(delete=False) as tmp_requirements:
tmp_requirements.write(subprocess.check_output(
[tox_python, '-m', 'pip', 'freeze']))