From 83dc0f6b065639262eab0bec5f9e8ed33823218d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Lippai?= Date: Thu, 17 Oct 2024 22:27:37 -0400 Subject: [PATCH 1/3] Fix turbodbc_intern import and test pyarrow as a hard dependency --- tests/test_executemanycolumns.py | 13 ++----------- tests/test_executemanycolumns_corner_cases.py | 15 +-------------- turbodbc/arrow_support.py | 2 +- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/tests/test_executemanycolumns.py b/tests/test_executemanycolumns.py index 0dcc56f65..6f902f310 100644 --- a/tests/test_executemanycolumns.py +++ b/tests/test_executemanycolumns.py @@ -1,5 +1,6 @@ import datetime +import pyarrow as pa import pytest from helpers import ( for_each_database, @@ -11,17 +12,7 @@ from numpy.ma import MaskedArray from query_fixture import query_fixture -column_backends = ["numpy"] - -try: - import pyarrow as pa - import turbodbc_arrow_support # noqa: F401 - - column_backends.append("arrow") - # column_backends.append('pandas') -except ImportError: - pass - +column_backends = ["numpy", "arrow"] for_each_column_backend = pytest.mark.parametrize("column_backend", column_backends) diff --git a/tests/test_executemanycolumns_corner_cases.py b/tests/test_executemanycolumns_corner_cases.py index 32a9ec02d..756541403 100644 --- a/tests/test_executemanycolumns_corner_cases.py +++ b/tests/test_executemanycolumns_corner_cases.py @@ -1,3 +1,4 @@ +import pyarrow as pa import pytest from helpers import for_one_database, open_cursor from numpy import array @@ -7,18 +8,6 @@ import turbodbc from turbodbc import InterfaceError -try: - import pyarrow as pa - import turbodbc_arrow_support # noqa: F401 - - HAVE_ARROW = True -except ImportError: - HAVE_ARROW = False - - -arrow_support = pytest.mark.skipif( - not HAVE_ARROW, reason="not build with Arrow support" -) @for_one_database @@ -119,7 +108,6 @@ def test_passing_empty_column_is_ok(dsn, configuration): assert results == [] -@arrow_support @for_one_database def test_arrow_table_exceeds_expected_columns(dsn, configuration): with open_cursor(configuration) as cursor: @@ -140,7 +128,6 @@ def test_arrow_table_exceeds_expected_columns(dsn, configuration): ) -@arrow_support @for_one_database def test_arrow_table_chunked_arrays_not_supported(dsn, configuration): with open_cursor(configuration) as cursor: diff --git a/turbodbc/arrow_support.py b/turbodbc/arrow_support.py index ea059b63d..61eaffa56 100644 --- a/turbodbc/arrow_support.py +++ b/turbodbc/arrow_support.py @@ -8,4 +8,4 @@ for lib_dir in pyarrow.get_library_dirs(): os.add_dll_directory(lib_dir) -from turbodbc_arrow_support import * # noqa +from turbodbc_intern import * # noqa From cd287c0bc91fadff7ffa1b4e4eb1b641446ad3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Lippai?= Date: Thu, 17 Oct 2024 22:40:12 -0400 Subject: [PATCH 2/3] Better cleanup of optional arrow support --- meson.build | 1 - turbodbc/arrow_support.py | 11 ----------- turbodbc/cursor.py | 5 ++--- 3 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 turbodbc/arrow_support.py diff --git a/meson.build b/meson.build index df8c256b1..e5420399e 100644 --- a/meson.build +++ b/meson.build @@ -190,7 +190,6 @@ py.install_sources( 'turbodbc/data_types.py', 'turbodbc/api_constants.py', 'turbodbc/connection.py', - 'turbodbc/arrow_support.py', 'turbodbc/exceptions.py', 'turbodbc/constructors.py', 'turbodbc/cursor.py', diff --git a/turbodbc/arrow_support.py b/turbodbc/arrow_support.py deleted file mode 100644 index 61eaffa56..000000000 --- a/turbodbc/arrow_support.py +++ /dev/null @@ -1,11 +0,0 @@ -import os -import sys - -import pyarrow - -# Ensure arrow_python${SHLIB_EXT} is on the PATH. -if sys.platform == "win32": - for lib_dir in pyarrow.get_library_dirs(): - os.add_dll_directory(lib_dir) - -from turbodbc_intern import * # noqa diff --git a/turbodbc/cursor.py b/turbodbc/cursor.py index d5c0f2ff8..572186c89 100644 --- a/turbodbc/cursor.py +++ b/turbodbc/cursor.py @@ -8,7 +8,8 @@ make_numpy_result_set, make_parameter_set, make_row_based_result_set, - set_numpy_parameters, + set_arrow_parameters, + set_numpy_parameters ) from .exceptions import InterfaceError, translate_exceptions @@ -184,8 +185,6 @@ def _num_chunks(c): return c.num_chunks if isinstance(columns, pa.Table): - from turbodbc.arrow_support import set_arrow_parameters # type: ignore - for column in columns.itercolumns(): if _num_chunks(column) != 1: raise NotImplementedError("Chunked Arrays are " "not yet supported") From 67a06fbe420ea7eeec6ea6f19c2b5a9cfabc4919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Lippai?= Date: Thu, 17 Oct 2024 23:46:29 -0400 Subject: [PATCH 3/3] Update changelog [skip ci] --- CHANGELOG.rst | 5 +++++ pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ca9a442c8..b56bc54b1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,11 @@ Version history / changelog From version 2.0.0, turbodbc adapts semantic versioning. +Version 5.0.2 +------------- + +* Fix and clean up the PyArrow integration + Version 5.0.0 ------------- diff --git a/pyproject.toml b/pyproject.toml index 2df87f3f4..41b9d69b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "mesonpy" [project] name = "turbodbc" -version = "5.0.1" +version = "5.0.2" description = "turbodbc is a Python DB API 2.0 compatible ODBC driver" readme = "README.md" requires-python = ">=3.10"