[jhbuild/wip/lantw/support-python3-sysdeps-and-fix-gtk-doc-deps: 5/6] systeminstall: Support 'python3' sysdeps



commit cb7827df938676ff9df7f9080bd634c0ef73fa0a
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Tue Jul 2 20:11:29 2019 +0800

    systeminstall: Support 'python3' sysdeps
    
    Using code similar to 'python2' sysdeps, we add 'python3' sysdeps in
    order to allow a module to depend on a system-installed Python 3 module.
    Since JHBuild itself is written in Python 2, we cannot test Python 3
    modules directly in the JHBuild process. Therefore, tests for Python 3
    modules have to be done in a new process, and it is expected for python3
    tests to be slower than python2 tests.

 jhbuild/utils/systeminstall.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 50e92d3c..edff0794 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -24,6 +24,7 @@ import shlex
 import subprocess
 import pipes
 import imp
+import textwrap
 import time
 from StringIO import StringIO
 
@@ -180,6 +181,20 @@ def systemdependencies_met(module_name, sysdeps, config):
             except:
                 dep_met = False
 
+        elif dep_type == 'python3':
+            python3_script = textwrap.dedent('''
+                import imp
+                import sys
+                try:
+                    imp.find_module(sys.argv[1])
+                except:
+                    exit(1)
+                ''').strip('\n')
+            try:
+                subprocess.check_call(['python3', '-c', python3_script, value])
+            except (subprocess.CalledProcessError, OSError):
+                dep_met = False
+
         elif dep_type == 'xml':
             xml_catalog = '/etc/xml/catalog'
 


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