Add a check to ensure pip is installed

This commit is contained in:
Paulus Schoutsen 2015-07-19 19:00:48 -07:00
parent a3906242e9
commit e277decd4c

View File

@ -21,6 +21,16 @@ def validate_python():
sys.exit() sys.exit()
def ensure_pip():
""" Validate pip is installed so we can install packages on demand. """
if importlib.find_loader('pip') is None:
print("Your Python installation did not bundle 'pip'")
print("Home Assistant requires 'pip' to be installed.")
print("Please install pip: "
"https://pip.pypa.io/en/latest/installing.html")
sys.exit()
# Copy of homeassistant.util.package because we can't import yet # Copy of homeassistant.util.package because we can't import yet
def install_package(package): def install_package(package):
"""Install a package on PyPi. Accepts pip compatible package strings. """Install a package on PyPi. Accepts pip compatible package strings.
@ -36,6 +46,8 @@ def install_package(package):
def validate_dependencies(): def validate_dependencies():
""" Validate all dependencies that HA uses. """ """ Validate all dependencies that HA uses. """
ensure_pip()
print("Validating dependencies...") print("Validating dependencies...")
import_fail = False import_fail = False