Changeset: 3ba82f6f6915 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ba82f6f6915
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
        NT/rules.msc
        gdk/gdk_utils.c
        monetdb5/NT/M5server.bat
        monetdb5/mal/mal_linker.c
        sql/backends/monet5/UDF/pyapi/Makefile.ag
        sql/backends/monet5/UDF/pyapi/pyheader.h
        sql/backends/monet5/UDF/pyapi/type_conversion.c
        sql/backends/monet5/UDF/pyapi3/Makefile.ag
Branch: default
Log Message:

Merge with Apr2019 branch.


diffs (300 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/NT/rules.msc b/NT/rules.msc
--- a/NT/rules.msc
+++ b/NT/rules.msc
@@ -185,8 +185,13 @@ R.lib: "$(libr_DLL)"
 !ENDIF
 
 !IFDEF HAVE_LIBPY
-libpy_LIBS = $(PYTHON2DIR)\libs\python27.lib
-libpy_CFLAGS = -DHAVE_LIBPY -I$(PYTHON2DIR)\include 
-I$(PYTHON2DIR)\Lib\site-packages\numpy\core\include
+libpy_LIBS = "$(PYTHON2DIR)\libs\python27.lib"
+libpy_CFLAGS = -DHAVE_LIBPY "-I$(PYTHON2DIR)\include" 
"-I$(PYTHON2DIR)\Lib\site-packages\numpy\core\include"
+!ENDIF
+
+!IFDEF HAVE_LIBPY3
+libpy3_LIBS = "$(PYTHON3DIR)\libs\python37.lib"
+libpy3_CFLAGS = -DHAVE_LIBPY3 "-I$(PYTHON3DIR)\include" 
"-I$(PYTHON3DIR)\Lib\site-packages\numpy\core\include"
 !ENDIF
 
 # some programs we use, probably no need to edit
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -105,14 +105,11 @@ GDKgetenv(const char *name)
 }
 
 bool
-GDKgetenv_istext(const char *name, const char* text)
+GDKgetenv_istext(const char *name, const char *text)
 {
-       char *val = GDKgetenv(name);
+       const char *val = GDKgetenv(name);
 
-       if (val && strcasecmp(val, text) == 0) {
-               return 1;
-       }
-       return 0;
+       return val && strcasecmp(val, text) == 0;
 }
 
 bool
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/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -438,17 +438,13 @@ MSP_locate_sqlscript(const char *filenam
 int
 malLibraryEnabled(str name) {
        if (strcmp(name, "pyapi") == 0) {
-               char *val = GDKgetenv("embedded_py");
-               if (val && (strcasecmp(val, "2") == 0 || 
GDKgetenv_istrue("embedded_py") || GDKgetenv_istrue("embedded_py"))) {
-                       return true;
-               }
-               return false;
+               const char *val = GDKgetenv("embedded_py");
+               return val && (strcmp(val, "2") == 0 ||
+                                          strcasecmp(val, "true") == 0 ||
+                                          strcasecmp(val, "yes") == 0);
        } else if (strcmp(name, "pyapi3") == 0) {
-               char *val = GDKgetenv("embedded_py");
-               if (val && strcasecmp(val, "3") == 0) {
-                       return true;
-               }
-               return false;
+               const char *val = GDKgetenv("embedded_py");
+               return val && strcasecmp(val, "3") == 0;
        }
        return true;
 }
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/pyapi/pyheader.h 
b/sql/backends/monet5/UDF/pyapi/pyheader.h
--- a/sql/backends/monet5/UDF/pyapi/pyheader.h
+++ b/sql/backends/monet5/UDF/pyapi/pyheader.h
@@ -57,7 +57,7 @@
 
 // DLL Export Flags
 #ifdef WIN32
-#ifndef LIBPYAPI
+#if !defined(LIBPYAPI) && !defined(LIBPYAPI3)
 #define pyapi_export extern __declspec(dllimport)
 #else
 #define pyapi_export extern __declspec(dllexport)
diff --git a/sql/backends/monet5/UDF/pyapi/type_conversion.c 
b/sql/backends/monet5/UDF/pyapi/type_conversion.c
--- a/sql/backends/monet5/UDF/pyapi/type_conversion.c
+++ b/sql/backends/monet5/UDF/pyapi/type_conversion.c
@@ -272,7 +272,7 @@ str pyobject_to_##type(PyObject **pyobj,
                PyLongObject *p = (PyLongObject*) ptr;                          
\
                inttpe h = 0;                                                   
\
                inttpe prev = 0;                                                
\
-               int i = Py_SIZE(p);                                             
\
+               Py_ssize_t i = Py_SIZE(p);                                      
        \
                int sign = i < 0 ? -1 : 1;                                      
\
                i *= sign;                                                      
\
                while (--i >= 0) {                                              
\
@@ -284,7 +284,7 @@ str pyobject_to_##type(PyObject **pyobj,
                }                                                               
\
                *value = (type)(h * sign);                                      
\
        } else if (PyBool_Check(ptr)) {                                 \
-               *value = ptr == Py_True ? 1 : 0;                                
\
+               *value = ptr == Py_True ? (type) 1 : (type) 0;                  
\
        } else if (PyFloat_CheckExact(ptr)) {                           \
                *value = isnan(((PyFloatObject*)ptr)->ob_fval) ? type##_nil : 
(type) ((PyFloatObject*)ptr)->ob_fval; \
        } else if (PyUnicode_CheckExact(ptr)) {                         \
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