[jhbuild/sysdeps-python2: 3/3] sysdeps: correctly detect python2 sysdeps when running under Python 3



commit b94da28d719b7b53ba69dea1c827a67c8cf62353
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Sep 24 19:27:54 2019 +0200

    sysdeps: correctly detect python2 sysdeps when running under Python 3
    
    We can't just check modules in the same process anymore with Python 3.
    Use a separate interpereter process like we did with python 2 sysdeps before.
    
    Fixes #36

 jhbuild/utils/systeminstall.py | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 3af2ce63..24ace1be 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -24,7 +24,6 @@ import sys
 import logging
 import shlex
 import subprocess
-import imp
 import textwrap
 import time
 import re
@@ -180,14 +179,9 @@ def systemdependencies_met(module_name, sysdeps, config):
             if not found:
                 dep_met = False
 
-        elif dep_type == 'python2':
-            try:
-                imp.find_module(value)
-            except Exception:
-                dep_met = False
-
-        elif dep_type == 'python3':
-            python3_script = textwrap.dedent('''
+        elif dep_type in ('python2', 'python3'):
+            command = dep_type
+            python_script = textwrap.dedent('''
                 import imp
                 import sys
                 try:
@@ -196,7 +190,7 @@ def systemdependencies_met(module_name, sysdeps, config):
                     exit(1)
                 ''').strip('\n')
             try:
-                subprocess.check_call(['python3', '-c', python3_script, value])
+                subprocess.check_call([command, '-c', python_script, value])
             except (subprocess.CalledProcessError, OSError):
                 dep_met = False
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]