Changeset: 0ee62220502e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0ee62220502e
Added Files:
        sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat
        sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat
Removed Files:
        sql/backends/monet5/UDF/pyapi/pyapi_locatepython.bat
Modified Files:
        NT/mksqlwxs.py
        monetdb5/NT/M5server.bat
        sql/backends/monet5/UDF/pyapi/Makefile.ag
        sql/backends/monet5/UDF/pyapi3/Makefile.ag
Branch: Apr2019
Log Message:

Install Embedded Python 2 and 3 as options on Windows.


diffs (200 lines):

diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -51,6 +51,8 @@ def main():
     extend = []
     debug = []
     geom = []
+    pyapi2 = []
+    pyapi3 = []
     print(r'<?xml version="1.0"?>')
     print(r'<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>')
     print(r'  <Product Id="*" Language="1033" Manufacturer="MonetDB" 
Name="MonetDB5" UpgradeCode="%s" Version="%s">' % (upgradecode[arch], 
sys.argv[1]))
@@ -83,6 +85,19 @@ def main():
     print(r'        <FileSearch Id="CheckFile3" Name="geom.mal"/>')
     print(r'      </DirectorySearch>')
     print(r'    </Property>')
+    print(r'    <Property Id="PYAPI2EXISTS">')
+    print(r'      <DirectorySearch Id="CheckFileDir4" Path="[INSTALLDIR]" 
Depth="0">')
+    print(r'        <FileSearch Id="CheckFile4" 
Name="pyapi_locatepython.bat"/>')
+    print(r'      </DirectorySearch>')
+    print(r'      <DirectorySearch Id="CheckFileDir42" Path="[INSTALLDIR]" 
Depth="0">')
+    print(r'        <FileSearch Id="CheckFile42" 
Name="pyapi_locatepython2.bat"/>')
+    print(r'      </DirectorySearch>')
+    print(r'    </Property>')
+    print(r'    <Property Id="PYAPI3EXISTS">')
+    print(r'      <DirectorySearch Id="CheckFileDir5" Path="[INSTALLDIR]" 
Depth="0">')
+    print(r'        <FileSearch Id="CheckFile5" 
Name="pyapi_locatepython3.bat"/>')
+    print(r'      </DirectorySearch>')
+    print(r'    </Property>')
     # up to and including 11.29.3, the geom module can not be
     # uninstalled if MonetDB/SQL is not installed; this somehow also
     # precludes the upgrade to this version, therefore we disallow
@@ -164,9 +179,13 @@ def main():
     print(r'              <Directory Id="monetdb5" Name="monetdb5">')
     print(r'                <Directory Id="autoload" Name="autoload">')
     id = comp(features, id, 18,
-              [r'lib\monetdb5\autoload\%s' % x for x in sorted(filter(lambda 
x: x.endswith('.mal') and ('geom' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5', 'autoload'))))])
+              [r'lib\monetdb5\autoload\%s' % x for x in sorted(filter(lambda 
x: x.endswith('.mal') and ('geom' not in x) and ('pyapi' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5', 'autoload'))))])
     id = comp(geom, id, 18,
               [r'lib\monetdb5\autoload\%s' % x for x in sorted(filter(lambda 
x: x.endswith('.mal') and ('geom' in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5', 'autoload'))))])
+    id = comp(pyapi2, id, 18,
+              [r'lib\monetdb5\autoload\%s' % x for x in sorted(filter(lambda 
x: x.endswith('_pyapi.mal'), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5', 'autoload'))))])
+    id = comp(pyapi3, id, 18,
+              [r'lib\monetdb5\autoload\%s' % x for x in sorted(filter(lambda 
x: x.endswith('_pyapi3.mal'), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5', 'autoload'))))])
     print(r'                </Directory>')
     print(r'                <Directory Id="createdb" Name="createdb">')
     id = comp(features, id, 18,
@@ -175,15 +194,21 @@ def main():
               [r'lib\monetdb5\createdb\%s' % x for x in sorted(filter(lambda 
x: x.endswith('.sql') and ('geom' in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5', 'createdb'))))])
     print(r'                </Directory>')
     id = comp(features, id, 16,
-              [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.endswith('.mal') and ('geom' not in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5'))))])
+              [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.endswith('.mal') and ('geom' not in x) and ('pyapi' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'))))])
     id = comp(features, id, 16,
-              [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.startswith('lib_') and x.endswith('.dll') and ('geom' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'))))])
+              [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.startswith('lib_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' 
not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'))))])
     id = comp(debug, id, 16,
               [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.startswith('lib_') and x.endswith('.pdb') and ('geom' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'))))])
     id = comp(geom, id, 16,
               [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.endswith('.mal') and ('geom' in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5'))))])
     id = comp(geom, id, 16,
               [r'lib\monetdb5\%s' % x for x in sorted(filter(lambda x: 
x.startswith('lib_') and (x.endswith('.dll') or x.endswith('.pdb')) and ('geom' 
in x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'))))])
+    id = comp(pyapi2, id, 16,
+              [r'lib\monetdb5\pyapi.mal',
+               r'lib\monetdb5\lib_pyapi.dll'])
+    id = comp(pyapi3, id, 16,
+              [r'lib\monetdb5\pyapi3.mal',
+               r'lib\monetdb5\lib_pyapi3.dll'])
     print(r'              </Directory>')
     id = comp(extend, id, 14,
               [r'lib\libbat.lib',
@@ -215,8 +240,11 @@ def main():
               [r'license.rtf',
                r'M5server.bat',
                r'msqldump.bat',
-               r'pyapi_locatepython.bat',
                r'stethoscope.bat'])
+    id = comp(pyapi2, id, 12,
+              [r'pyapi_locatepython2.bat'])
+    id = comp(pyapi3, id, 12,
+              [r'pyapi_locatepython3.bat'])
     id = comp(features, id, 12,
               [r'mclient.bat'],
               name = 'MonetDB SQL Client',
@@ -245,6 +273,16 @@ def main():
         print(r'        <ComponentRef Id="%s"/>' % f)
     print(r'        <MergeRef Id="VCRedist"/>')
     print(r'      </Feature>')
+    print(r'      <Feature Id="PyAPI2" Level="1000" AllowAdvertise="no" 
Absent="allow" Title="Include embedded Python 2" Description="Files required 
for using embedded Python 2.">')
+    for f in pyapi2:
+        print(r'        <ComponentRef Id="%s"/>' % f)
+    print(r'        <Condition Level="1">PYAPI2EXISTS</Condition>')
+    print(r'      </Feature>')
+    print(r'      <Feature Id="PyAPI3" Level="1000" AllowAdvertise="no" 
Absent="allow" Title="Include embedded Python 3" Description="Files required 
for using embedded Python 3.">')
+    for f in pyapi3:
+        print(r'        <ComponentRef Id="%s"/>' % f)
+    print(r'        <Condition Level="1">PYAPI3EXISTS</Condition>')
+    print(r'      </Feature>')
     print(r'      <Feature Id="Extend" Level="1000" AllowAdvertise="no" 
Absent="allow" Title="Extend MonetDB/SQL" Description="Files required for 
extending MonetDB (include files and .lib files).">')
     for f in extend:
         print(r'        <ComponentRef Id="%s"/>' % f)
diff --git a/monetdb5/NT/M5server.bat b/monetdb5/NT/M5server.bat
--- a/monetdb5/NT/M5server.bat
+++ b/monetdb5/NT/M5server.bat
@@ -41,9 +41,13 @@ rmdir "%MONETDBDIR%\sql_logs"
 
 set MONETDBPYTHONUDF="embedded_py=false"
 
-if not exist "%MONETDB%\pyapi_locatepython.bat" goto skippython
-call "%MONETDB%\pyapi_locatepython.bat"
-:skippython
+if not exist "%MONETDB%\pyapi_locatepython2.bat" goto skippython2
+call "%MONETDB%\pyapi_locatepython2.bat"
+goto skippython3
+:skippython2
+if not exist "%MONETDB%\pyapi_locatepython3.bat" goto skippython3
+call "%MONETDB%\pyapi_locatepython3.bat"
+:skippython3
 
 rem start the real server
 "%MONETDB%\bin\mserver5.exe" --set "prefix=%MONETDB%" --set %MONETDBPYTHONUDF% 
--set "exec_prefix=%MONETDB%" %MONETDBFARM% %*
diff --git a/sql/backends/monet5/UDF/pyapi/Makefile.ag 
b/sql/backends/monet5/UDF/pyapi/Makefile.ag
--- a/sql/backends/monet5/UDF/pyapi/Makefile.ag
+++ b/sql/backends/monet5/UDF/pyapi/Makefile.ag
@@ -47,7 +47,7 @@ scripts_bat = {
        COND = NATIVE_WIN32
        EXT = bat
        DIR = prefix
-       SOURCES = pyapi_locatepython.bat
+       SOURCES = pyapi_locatepython2.bat
 }
 
 EXTRA_DIST_DIR = Tests
diff --git a/sql/backends/monet5/UDF/pyapi/pyapi_locatepython.bat 
b/sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat
rename from sql/backends/monet5/UDF/pyapi/pyapi_locatepython.bat
rename to sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat
--- a/sql/backends/monet5/UDF/pyapi/pyapi_locatepython.bat
+++ b/sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat
@@ -24,7 +24,7 @@ IF defined LOCALPYTHONHOME (
     endlocal & (
         set PYTHONHOME=%LOCALPYTHONHOME%
         set PYTHONPATH=%LOCALPYTHONPATH%
-        set MONETDBPYTHONUDF=embedded_py=true
+        set MONETDBPYTHONUDF=embedded_py=2
         set "PATH=%LOCALPYTHONHOME%;%PATH%"
     )
 ) ELSE (
diff --git a/sql/backends/monet5/UDF/pyapi3/Makefile.ag 
b/sql/backends/monet5/UDF/pyapi3/Makefile.ag
--- a/sql/backends/monet5/UDF/pyapi3/Makefile.ag
+++ b/sql/backends/monet5/UDF/pyapi3/Makefile.ag
@@ -46,4 +46,11 @@ headers_autoload = {
        SOURCES = 50_pyapi3.mal
 }
 
+scripts_bat = {
+       COND = NATIVE_WIN32
+       EXT = bat
+       DIR = prefix
+       SOURCES = pyapi_locatepython3.bat
+}
+
 EXTRA_DIST_DIR = Tests
diff --git a/sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat 
b/sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat
@@ -0,0 +1,33 @@
+@REM This Source Code Form is subject to the terms of the Mozilla Public
+@REM License, v. 2.0.  If a copy of the MPL was not distributed with this
+@REM file, You can obtain one at http://mozilla.org/MPL/2.0/.
+@REM
+@REM Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+
+@echo off
+ 
+setlocal ENABLEEXTENSIONS
+set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.7\InstallPath"
+set VALUE_NAME=""
+ 
+FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v 
%VALUE_NAME% 2^>nul`) DO (
+    set ValueName=%%A
+    set ValueType=%%B
+    set ValueValue=%%C
+)
+IF defined ValueName (
+    set LOCALPYTHONHOME=%ValueValue%
+    set LOCALPYTHONPATH=%ValueValue%Lib
+)
+
+IF defined LOCALPYTHONHOME (
+    endlocal & (
+        set PYTHONHOME=%LOCALPYTHONHOME%
+        set PYTHONPATH=%LOCALPYTHONPATH%
+        set MONETDBPYTHONUDF=embedded_py=3
+        set "PATH=%LOCALPYTHONHOME%;%PATH%"
+    )
+) ELSE (
+    @echo MonetDB/Python Disabled: Python 3.7 installation not found.
+    endlocal
+)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to