Skip to content

Commit

Permalink
pantab 4.0 (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd authored Jan 14, 2024
1 parent f69dbef commit 6059ad7
Show file tree
Hide file tree
Showing 31 changed files with 934 additions and 2,154 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ jobs:

- name: Build wheels for ${{ matrix.os }}
uses: pypa/[email protected]
env:
MACOSX_DEPLOYMENT_TARGET: "10.14"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.mypy_cache
*.hyper
hyper_db*
compile_commands.json
_deps

#########################################
# Editor temporary/working/backup files #
Expand Down
52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.18)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (MSVC)
else()
add_compile_options(-Wall -Wextra)
endif()

find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)

# Detect the installed nanobind package and import it into CMake
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR)
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
find_package(nanobind CONFIG REQUIRED)

if(WIN32)
set(TABLEAU_DOWNLOAD_URL "https://downloads.tableau.com/tssoftware//tableauhyperapi-cxx-windows-x86_64-release-main.0.0.18441.r118d57bb.zip")
elseif(APPLE)
set(TABLEAU_DOWNLOAD_URL "https://downloads.tableau.com/tssoftware//tableauhyperapi-cxx-macos-x86_64-release-main.0.0.18441.r118d57bb.zip")
else()
set(TABLEAU_DOWNLOAD_URL "https://downloads.tableau.com/tssoftware//tableauhyperapi-cxx-linux-x86_64-release-main.0.0.18441.r118d57bb.zip")
endif()

include(FetchContent)
FetchContent_Declare(
tableauhyperapi-cxx
URL "${TABLEAU_DOWNLOAD_URL}"
)

FetchContent_MakeAvailable(tableauhyperapi-cxx)
list(APPEND CMAKE_PREFIX_PATH "${tableauhyperapi-cxx_SOURCE_DIR}/share/cmake")
find_package(tableauhyperapi-cxx CONFIG REQUIRED)


FetchContent_Declare(nanoarrow-project
GIT_REPOSITORY https://github.com/apache/arrow-nanoarrow.git
GIT_TAG apache-arrow-nanoarrow-0.3.0
)
FetchContent_MakeAvailable(nanoarrow-project)

if (PANTAB_USE_SANITIZERS)
add_compile_options(-fsanitize=address -fsanitize=undefined)
add_link_options(-fsanitize=address -fsanitize=undefined)
endif()

add_subdirectory(pantab/src)
16 changes: 1 addition & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,7 @@ git checkout -b a-new-branch

### Building the Project

To install pantab, simply run:

```sh
python -m pip install .
```

From the project root. Because pandas uses meson as a build backend, you can pass options (like building a debug version) via meson command line arguments:

```
python -m pip install . --config-settings=builddir="debug" --config-settings=setup-args="-Dbuildtype=debug"
```

At the moment editable installs are not supported.

Please also note that the above will fail without a C compiler - if you don't have one installed check out the appropriate documentation from the [Python Developer Guide](https://devguide.python.org/setup/#compile-and-build) for your platform.
For an editable install of pantab you can simply run `pip install -ve .` from the project root.

### Creating tests and running the test suite

Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ dependencies:
- black
- flake8
- isort
- meson-python
- mypy
- nanobind
- pandas
- pandas-stubs
- pip
- pyarrow
- python
- pytest
- scikit-build-core
- sphinx
- pre-commit
- sphinx_rtd_theme
Expand Down
33 changes: 0 additions & 33 deletions meson.build

This file was deleted.

113 changes: 1 addition & 112 deletions pantab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
__version__ = "3.0.3"
__version__ = "4.0.0rc"

import libpantab # type: ignore
from tableauhyperapi import __version__ as hyperapi_version

from ._reader import frame_from_hyper, frame_from_hyper_query, frames_from_hyper
from ._tester import test
Expand All @@ -16,112 +14,3 @@
"frames_to_hyper",
"test",
]

# We link against HyperAPI in a fun way: In Python, we extract the function
# pointers directly from the Python HyperAPI. We pass those function pointers
# over to the C module which will then use those pointers to directly interact
# with HyperAPI. Furthermore, we check the function signatures to guard
# against API-breaking changes in HyperAPI.
#
# Directly using HyperAPI's C functions always was and still is discouraged and
# unsupported by Tableu. In particular, Tableau will not be able to provide
# official support for this hack.
#
# Because this is highly brittle, we try to make the error message as
# actionable as possible and guide users in the right direction.

api_incompatibility_msg = """
pantab is incompatible with version {} of Tableau Hyper API. Please upgrade
both `tableauhyperapi` and `pantab` to the latest version. See also
https://pantab.readthedocs.io/en/latest/caveats.html#tableauhyperapi-compatability
""".format(
hyperapi_version
)

try:
from tableauhyperapi.impl.dll import ffi, lib
except ImportError as e:
raise NotImplementedError(api_incompatibility_msg) from e


def _check_compatibility(check, message):
if not check:
raise NotImplementedError(message + "\n" + api_incompatibility_msg)


def _get_hapi_function(name, sig):
_check_compatibility(hasattr(lib, name), f"function '{name}' missing")
f = getattr(lib, name)
func_type = ffi.typeof(f)
_check_compatibility(
func_type.kind == "function",
f"expected '{name}' to be a function, got {func_type.kind}",
)
_check_compatibility(
func_type.cname == sig,
f"expected '{name}' to have the signature '{sig}', got '{func_type.cname}'",
)
return f


libpantab.load_hapi_functions(
_get_hapi_function("hyper_decode_date", "hyper_date_components_t(*)(uint32_t)"),
_get_hapi_function("hyper_encode_date", "uint32_t(*)(hyper_date_components_t)"),
_get_hapi_function("hyper_decode_time", "hyper_time_components_t(*)(uint64_t)"),
_get_hapi_function("hyper_encode_time", "uint64_t(*)(hyper_time_components_t)"),
_get_hapi_function(
"hyper_inserter_buffer_add_null",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_bool",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *, _Bool)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_int16",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *, int16_t)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_int32",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *, int32_t)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_int64",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *, int64_t)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_double",
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *, double)",
),
_get_hapi_function(
"hyper_inserter_buffer_add_binary",
(
"struct hyper_error_t *(*)"
"(struct hyper_inserter_buffer_t *, uint8_t *, size_t)"
),
),
_get_hapi_function(
"hyper_inserter_buffer_add_raw",
(
"struct hyper_error_t *(*)(struct hyper_inserter_buffer_t *"
", uint8_t *, size_t)"
),
),
_get_hapi_function(
"hyper_rowset_get_next_chunk",
(
"struct hyper_error_t *(*)(struct hyper_rowset_t *"
", struct hyper_rowset_chunk_t * *)"
),
),
_get_hapi_function(
"hyper_destroy_rowset_chunk", "void(*)(struct hyper_rowset_chunk_t *)"
),
_get_hapi_function(
"hyper_rowset_chunk_field_values",
(
"void(*)(struct hyper_rowset_chunk_t *"
", size_t *, size_t *, uint8_t * * *, size_t * *)"
),
),
)
7 changes: 0 additions & 7 deletions pantab/_compat.py

This file was deleted.

29 changes: 0 additions & 29 deletions pantab/_hyper_util.py

This file was deleted.

Loading

0 comments on commit 6059ad7

Please sign in to comment.