Repository: MonetDBSolutions/MonetDBe-Python (language: python)

Issue:
EXPLAIN output is not provided
Consider the following snippet from the Python console:
>>> import monetdbe
>>> conn = monetdbe.connect(‘test’)
>>> cur = conn.cursor()
>>> res = cur.execute(‘explain select 1’)
>>> tbl = res.fetchall()
>>> print(tbl)
[]

Either an exception or the table is expected.

For the case ‘trace select 1’  I miss the header and end of function, but that is less of a problem




Discussion / hints:
I can't do much about this now, the current monetdbe Jul2021 engine returns an error:
```
'ParseException:SQLparser:42000!syntax error, unexpected SQL_EXPLAIN in: "prepare explain"
```

Fix patch:
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 2fbb34f..935a97c 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -12,7 +12,7 @@ jobs:
     runs-on: ubuntu-20.04
     strategy:
       matrix:
-        branch: [Oct2020, Jul2021]
+        branch: [Oct2020, Jul2021, default]
     container: monetdb/dev-builds:${{ matrix.branch }}
     steps:
       -
@@ -33,7 +33,7 @@ jobs:
     strategy:
       matrix:
         python-version: [3.6, 3.7, 3.8, 3.9]
-        branch: [Oct2020, Jul2021]
+        branch: [Oct2020, Jul2021, default]
     container: monetdb/dev-builds:${{ matrix.branch}}_manylinux
 
     steps:
diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml
index d62f2b9..56d5475 100644
--- a/.github/workflows/mypy.yml
+++ b/.github/workflows/mypy.yml
@@ -9,15 +9,15 @@ on:
 
 jobs:
   mypy:
-    runs-on: ubuntu-18.04
-    container: monetdb/dev-builds:Oct2020
+    runs-on: ubuntu-20.04
+    container: monetdb/dev-builds:Jul2021
     steps:
       -
         name: Checkout
         uses: actions/checkout@v2
       -
         name: Install MonetDBe in developer mode
-        run: MONETDB_BRANCH=Oct2020 python3 -m pip install -e .[test]
+        run: MONETDB_BRANCH=Jul2021 python3 -m pip install -e .[test]
       -
         name: Run mypy static code checks
         run: mypy monetdbe tests
\ No newline at end of file
diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml
index f35f5b6..8015502 100644
--- a/.github/workflows/osx.yml
+++ b/.github/workflows/osx.yml
@@ -56,7 +56,7 @@ jobs:
           path: /usr/local/Cellar/monetdb
 
   osx-wheel:
-    continue-on-error: true
+#    continue-on-error: true
     runs-on: macos-10.15
     strategy:
       matrix:
@@ -90,13 +90,13 @@ jobs:
         run: python3 -m venv venv
       -
         name: Install Python dependencies
-        run: venv/bin/pip install --upgrade pip wheel delocate pytest
+        run: venv/bin/pip install --upgrade pip wheel delocate==0.8.2 pytest build
       -
         name: Compile and install MonetDBe-python
         run: MONETDB_BRANCH=${{ matrix.branch }} CFLAGS="-I/usr/local/include -L/usr/local/lib" venv/bin/pip install -e ".[test]"
       -
         name: make binary wheel
-        run: venv/bin/python setup.py bdist_wheel
+        run: venv/bin/pyproject-build
       -
         name: Delocate binary wheel
         run: DYLD_LIBRARY_PATH=/usr/local/lib venv/bin/delocate-wheel -v dist/*.whl
diff --git a/.github/workflows/pycodestyle.yml b/.github/workflows/pycodestyle.yml
index f412be5..387ce5f 100644
--- a/.github/workflows/pycodestyle.yml
+++ b/.github/workflows/pycodestyle.yml
@@ -9,15 +9,15 @@ on:
 
 jobs:
   linux-pycodestyle:
-    runs-on: ubuntu-18.04
-    container: monetdb/dev-builds:Oct2020
+    runs-on: ubuntu-20.04
+    container: monetdb/dev-builds:Jul2021
     steps:
       -
         name: Checkout
         uses: actions/checkout@v2
       -
         name: Install MonetDBe in developer mode
-        run: MONETDB_BRANCH=Oct2020 python3 -m pip install -e .[test]
+        run: MONETDB_BRANCH=Jul2021 python3 -m pip install -e .[test]
       -
         name: Check the python coding style
         run: pycodestyle monetdbe tests
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 6ccfa38..94ecf46 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -17,11 +17,11 @@ jobs:
         MONETDB_BRANCH: [ Oct2020, Jul2021 ]
         include:
           - MONETDB_BRANCH: Oct2020
-            MONETDB_WIN_PREFIX: 82158
-            MONETDB_WIN_VERSION: 94eccb312131
+            MONETDB_WIN_PREFIX: 82411
+            MONETDB_WIN_VERSION: c51ff55bd174
           - MONETDB_BRANCH: Jul2021
-            MONETDB_WIN_PREFIX: 82181
-            MONETDB_WIN_VERSION: 079fc84e56bc
+            MONETDB_WIN_PREFIX: 82431
+            MONETDB_WIN_VERSION: f61cd4ed3473
     env:
       MSI: MonetDB5-SQL-Installer-x86_64-${{ matrix.MONETDB_WIN_VERSION }}.msi
     steps:
@@ -94,7 +94,7 @@ jobs:
           ls monetdbe
       -
         name: Upgrade pip and wheel for all pythons
-        run: python3 -m pip install --upgrade pip wheel dll-diagnostics
+        run: python3 -m pip install --upgrade pip wheel dll-diagnostics build
       -
         name: Build binary python extension
         run: python3 setup.py build_ext --include-dirs='C:\Program Files\MonetDB\MonetDB5\include' --library-dirs='C:\Program Files\MonetDB\MonetDB5\lib'
@@ -109,7 +109,7 @@ jobs:
           dlldiag.exe deps .\monetdbe\_lowlevel.pyd  
       -
         name: Make wheel
-        run: python setup.py bdist_wheel
+        run: python3 setup.py sdist bdist_wheel
       -
         uses: actions/upload-artifact@v2
         name: Publish Windows binary wheels
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..3ddb6c2
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,1 @@
+include monetdbe/_cffi/embed.h.j2
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 610ddd9..12a0c21 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ all: test
 
 venv/:
 	python3 -m venv venv
-	venv/bin/pip install --upgrade pip wheel
+	venv/bin/pip install --upgrade pip wheel build
 
 venv/installed: venv/
 	venv/bin/pip install -e ".[test]"
@@ -18,6 +18,7 @@ venv/installed: venv/
 
 setup: venv/installed
 build: venv/installed
+	venv/bin/pyproject-build
 
 test: setup
 	venv/bin/pytest
@@ -84,7 +85,7 @@ venv/bin/twine: venv/
 	touch venv/bin/twine
 
 twine: venv/bin/twine
-	venv/bin/twine upload dist/*.whl
+	venv/bin/twine upload dist/*.whl dist/*.tar.gz
 
 info: setup
 	venv/bin/python -c "from monetdbe._cffi.util import print_info; print_info()"
diff --git a/doc/developer.rst b/doc/developer.rst
index 6d4db87..23a0209 100644
--- a/doc/developer.rst
+++ b/doc/developer.rst
@@ -41,61 +41,8 @@ After setting up te testing environment, run from the source folder:
     LD_LIBRARY_PATH=<monetdb_prefix>/lib pytest
 
 
-Making binary wheel for Linux
-=============================
+Making binary wheels
+====================
 
-requirements:
- * Docker
- * make
-
-Then run
-
-.. code-block::
-
-    $ make docker-wheels
-    $ venv/bin/pip install twine
-    $ venv/bin/twine upload dist/*.whl dist/*.tar.gz
-
-
-
-Making binary wheel for OSX
-===========================
-
-1. get a High Sierra machine (10.13)
-
-
-2. install homebrew
-
-.. code-block::
-
-    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
-
-4. Run the OSX wheel script
-
-.. code-block::
-
-   scripts/osx_wheel.sh
-
-
-10 upload the wheels
-
-.. code-block::
-
-    pip install twine
-    twine upload dist/*.whl
-
-
-Making binary wheel for Windows
-===============================
-
-
-Compile MonetDB on Windows
---------------------------
-
-1. install microsoft visual studio community edition:
-
-https://visualstudio.microsoft.com/vs/community/
-
-
-2. Refer to the Github Actions Windows build script `.github/workflows/windows.yml` for further actions.
+This is fully automated on Github Actions, the build scripts are located in `.github/workflows/`.
 
diff --git a/monetdbe/_cffi/builder.py b/monetdbe/_cffi/builder.py
index 8ef0dbf..49a68fb 100644
--- a/monetdbe/_cffi/builder.py
+++ b/monetdbe/_cffi/builder.py
@@ -32,7 +32,7 @@
 # the ffibuilder object needs to exist and be configured in the module namespace so setup.py can reach it
 ffibuilder = FFI()
 ffibuilder.set_source("monetdbe._lowlevel", source, libraries=['monetdbe'])
-embed_path = str(Path(__file__).parent / 'embed.h.j2')
+embed_path = str(Path(__file__).resolve().parent / 'embed.h.j2')
 
 
 with open(embed_path, 'r') as f:
diff --git a/scripts/make_wheel.sh b/scripts/make_wheel.sh
index 3c5ae09..950f22b 100755
--- a/scripts/make_wheel.sh
+++ b/scripts/make_wheel.sh
@@ -32,6 +32,8 @@ esac
 
 TARGET=cp${VERSION}-cp${VERSION}${PLATFORM}
 
-/opt/python/${TARGET}/bin/python ./setup.py bdist_wheel -d ${WORKDIR}
+/opt/python/${TARGET}/bin/pip install --upgrade pip wheel build
+
+/opt/python/${TARGET}/bin/pyproject-build -o ${WORKDIR}
 
 auditwheel repair --plat manylinux2014_x86_64 -w ${OUTPUT} ${WORKDIR}/*.whl


Test patch:
diff --git a/tests/test_regression.py b/tests/test_regression.py
index d28ecc1..fe062a7 100644
--- a/tests/test_regression.py
+++ b/tests/test_regression.py
@@ -62,7 +62,7 @@ def tearDown(self):
 
     @unittest.skip("cached_statements not supported (yet)")
     def test_StatementReset(self):
-        # pymonetdbe 2.1.0 to 2.2.0 have the problem that not all statements are
+        # sqlite 2.1.0 to 2.2.0 have the problem that not all statements are
         # reset before a rollback, but only those that are still in the
         # statement cache. The others are not accessible from the connection object.
         con = monetdbe.connect(":memory:", cached_statements=5)
@@ -85,7 +85,7 @@ def test_ColumnNameWithSpaces(self):
         self.assertEqual(cur.description[0][0], "foo baz")
 
     def test_StatementFinalizationOnCloseDb(self):
-        # pymonetdbe versions <= 2.3.3 only finalized statements in the statement
+        # sqlite versions <= 2.3.3 only finalized statements in the statement
         # cache when closing the database. statements that were still
         # referenced in cursors weren't closed and could provoke "
         # "OperationalError: Unable to close due to unfinalised statements".
@@ -505,6 +505,14 @@ def test_issue127(self):
         rows = res.fetchall()
         print(rows)
 
+    @unittest.skip("Disabled until issue #118 is solved")
+    def test_issue118_explain(self):
+        conn = monetdbe.connect(':memory:')
+        cur = conn.cursor()
+        res = cur.execute('explain select 1')
+        tbl = res.fetchall()
+        print(tbl)
+
     @unittest.skipIf(OCT2020, "This issue was not fixed on Oct2020")
     def test_issue_136_bigint_result(self):
         con = monetdbe.connect(':memory:')