From 8c8bd08e41338a6502402097475d2757de797294 Mon Sep 17 00:00:00 2001
From: Ellis Percival <flyte@failcode.co.uk>
Date: Thu, 16 Aug 2018 22:33:00 +0100
Subject: [PATCH] Fix requirements installation broken since pip 10. #33

---
 pi_mqtt_gpio/server.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/pi_mqtt_gpio/server.py b/pi_mqtt_gpio/server.py
index 59d5b86..d194b4b 100644
--- a/pi_mqtt_gpio/server.py
+++ b/pi_mqtt_gpio/server.py
@@ -212,14 +212,15 @@ def install_missing_requirements(module):
         if pkgs_installed.find(pkg_resources.Requirement.parse(req)) is None:
             pkgs_required.append(req)
     if pkgs_required:
-        from pip.commands.install import InstallCommand
-        from pip.status_codes import SUCCESS
-        cmd = InstallCommand()
-        result = cmd.main(pkgs_required)
-        if result != SUCCESS:
+        from subprocess import check_call, CalledProcessError
+        try:
+            check_call(['/usr/bin/env', 'pip', 'install'] + pkgs_required)
+        except CalledProcessError as err:
             raise CannotInstallModuleRequirements(
-                "Unable to install packages for module %r (%s)..." % (
-                    module, pkgs_required))
+                "Unable to install packages for module %r (%s): %s" % (
+                    module, pkgs_required, err
+                )
+            )
 
 
 def output_name_from_topic(topic, topic_prefix, suffix):
-- 
GitLab