[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    MonetDB: Aug2018 - Get embedded Python testing working on Windows.
From:       Sjoerd Mullender <commits+sjoerd=acm.org () monetdb ! org>
Date:       2019-01-28 11:50:06
Message-ID: hg.4fab8ab054bd.1548676206.6315528441665844383 () monetdb-vm0 ! spin-off ! cwi ! nl
[Download RAW message or body]

Changeset: 4fab8ab054bd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4fab8ab054bd
Modified Files:
	testing/Mtest.py.in
Branch: Aug2018
Log Message:

Get embedded Python testing working on Windows.


diffs (60 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -32,6 +32,14 @@ import struct
 import signal
 import fnmatch
 import glob
+try:
+    import winreg               # Python 3 on Windows
+except ImportError:
+    try:
+        import _winreg as winreg # Python 2 on Windows
+    except ImportError:
+        winreg = None           # not on Windows
+
 
 procdebug = False
 verbose = False
@@ -2985,11 +2993,32 @@ def DoIt(env, SERVER, CALL, TST, EXT, PR
             if (not all_tests or (COND != None and "HAVE_LIBR" in COND)) and \
CONDITIONALS['HAVE_LIBR'] and CONDITIONALS['NOT_WIN32']:  Srvr.extend(['--set', \
'embedded_r=yes'])  
+            savepath = None
             if (COND != None and "HAVE_LIBPY3" in COND) and \
CONDITIONALS['HAVE_LIBPY3']:  # enable Python 3 integration in server
+                if winreg is not None:
+                    try:
+                        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, \
r'SOFTWARE\Python\PythonCore\3.7\InstallPath') as key: +                            \
instpath = winreg.QueryValue(key, None) +                            \
os.environ['PYTHONHOME'] = instpath +                            \
os.environ['PYTHONPATH'] = instpath + 'Lib' +                            savepath = \
os.environ['PATH'] +                            os.environ['PATH'] = \
instpath.rstrip('\\') + os.pathsep + savepath +                    except \
WindowsError: +                        pass
                 Srvr.extend(['--set', 'embedded_py=3'])
             elif (not all_tests or (COND != None and "HAVE_LIBPY" in COND)) and \
CONDITIONALS['HAVE_LIBPY']:  # enable Python integration in server
+                if winreg is not None:
+                    try:
+                        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, \
r'SOFTWARE\Python\PythonCore\2.7\InstallPath') as key: +                            \
instpath = winreg.QueryValue(key, None) +                            \
os.environ['PYTHONHOME'] = instpath +                            \
os.environ['PYTHONPATH'] = instpath + 'Lib' +                            savepath = \
os.environ['PATH'] +                            os.environ['PATH'] = \
instpath.rstrip('\\') + os.pathsep + savepath +                    except \
WindowsError: +                        pass
                 Srvr.extend(['--set', 'embedded_py=true'])
 
             # enable C integration in server
@@ -2997,6 +3026,8 @@ def DoIt(env, SERVER, CALL, TST, EXT, PR
 
 
             pSrvr, pSrvrTimer = LaunchIt(Srvr, '\nio.printf("\\nReady.\\n");\n', \
SrvrOut, SrvrErr, TIMEOUT) +            if savepath is not None:
+                os.environ['PATH'] = savepath
             ln="dummy"
             while 0 < len(ln) and not ln.startswith('Ready.'):
                 ln=pSrvr.stdout.readline()
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic