Skip to content

Commit cb94a30

Browse files
committed
Merge branch 'v1.4-andium'
2 parents af60d44 + 27b1d79 commit cb94a30

337 files changed

Lines changed: 12165 additions & 11620 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Code Quality Checks
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
git_ref:
6+
type: string
7+
description: Git ref of the DuckDB python package
8+
required: false
9+
workflow_call:
10+
inputs:
11+
git_ref:
12+
type: string
13+
description: Git ref of the DuckDB python package
14+
required: false
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
jobs:
21+
run_checks:
22+
name: Run linting and formatting
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.git_ref }}
28+
fetch-depth: 0
29+
persist-credentials: false
30+
31+
- name: Install Astral UV
32+
uses: astral-sh/setup-uv@v6
33+
with:
34+
version: "0.7.14"
35+
python-version: 3.9
36+
37+
- name: pre-commit (cache)
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cache/pre-commit
41+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
42+
43+
- name: pre-commit (--all-files)
44+
run: |
45+
uvx pre-commit run --show-diff-on-failure --color=always --all-files

β€Ž.github/workflows/coverage.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ jobs:
151151
echo "### C++ Coverage Summary" >> $GITHUB_STEP_SUMMARY
152152
echo '```' >> $GITHUB_STEP_SUMMARY
153153
echo "$SUMMARY_CPP" >> $GITHUB_STEP_SUMMARY
154-
echo '```' >> $GITHUB_STEP_SUMMARY
154+
echo '```' >> $GITHUB_STEP_SUMMARY

β€Ž.github/workflows/on_pr.ymlβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ jobs:
2323
name: Make sure submodule is in a sane state
2424
uses: ./.github/workflows/submodule_sanity.yml
2525

26+
code_quality:
27+
name: Code-quality checks
28+
needs: submodule_sanity_guard
29+
uses: ./.github/workflows/code_quality.yml
30+
2631
packaging_test:
2732
name: Build a minimal set of packages and run all tests on them
28-
needs: submodule_sanity_guard
33+
needs: code_quality
2934
# Skip packaging tests for draft PRs
3035
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
3136
uses: ./.github/workflows/packaging.yml
@@ -36,7 +41,7 @@ jobs:
3641

3742
coverage_test:
3843
name: Run coverage tests
39-
needs: submodule_sanity_guard
44+
needs: code_quality
4045
# Only run coverage test for draft PRs
4146
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true }}
4247
uses: ./.github/workflows/coverage.yml

β€Ž.github/workflows/on_push.ymlβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21+
code_quality:
22+
name: Code-quality checks
23+
uses: ./.github/workflows/code_quality.yml
24+
2125
test:
2226
name: Run coverage tests
27+
needs: code_quality
2328
uses: ./.github/workflows/coverage.yml
2429
with:
2530
git_ref: ${{ github.ref }}

β€Ž.pre-commit-config.yamlβ€Ž

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.13.0
5+
hooks:
6+
# Run the linter.
7+
- id: ruff-check
8+
# Run the formatter.
9+
- id: ruff-format
10+
11+
- repo: https://github.com/pre-commit/mirrors-clang-format
12+
rev: v18.1.8 # pick the version of clang-format you want
13+
hooks:
14+
- id: clang-format
15+
files: \.(c|cpp|cc|h|hpp|cxx|hxx)$
16+
17+
- repo: https://github.com/cheshirekow/cmake-format-precommit
18+
rev: v0.6.13
19+
hooks:
20+
- id: cmake-format
21+
22+
- repo: local
23+
hooks:
24+
- id: post-checkout-submodules
25+
name: Update submodule post-checkout
26+
entry: .githooks/post-checkout
27+
language: script
28+
stages: [ post-checkout ]

β€ŽCMakeLists.txtβ€Ž

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,50 +48,84 @@ duckdb_add_library(duckdb_target)
4848

4949
# Bundle in INTERFACE library
5050
add_library(_duckdb_dependencies INTERFACE)
51-
target_link_libraries(_duckdb_dependencies INTERFACE
52-
pybind11::pybind11
53-
duckdb_target
54-
)
51+
target_link_libraries(_duckdb_dependencies INTERFACE pybind11::pybind11
52+
duckdb_target)
5553
# Also add include directory
56-
target_include_directories(_duckdb_dependencies INTERFACE
57-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
54+
target_include_directories(
55+
_duckdb_dependencies
56+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
5857
)
5958

6059
# ────────────────────────────────────────────
6160
# Descend into the real DuckDB‑Python sources
6261
# ────────────────────────────────────────────
6362
add_subdirectory(src/duckdb_py)
6463

65-
pybind11_add_module(_duckdb
66-
$<TARGET_OBJECTS:python_src>
67-
$<TARGET_OBJECTS:python_arrow>
68-
$<TARGET_OBJECTS:python_common>
69-
$<TARGET_OBJECTS:python_functional>
70-
$<TARGET_OBJECTS:python_jupyter>
71-
$<TARGET_OBJECTS:python_native>
72-
$<TARGET_OBJECTS:python_numpy>
73-
$<TARGET_OBJECTS:python_pandas>
74-
$<TARGET_OBJECTS:python_pybind11>
75-
$<TARGET_OBJECTS:python_connection>
76-
$<TARGET_OBJECTS:python_expression>
77-
$<TARGET_OBJECTS:python_relation>
78-
$<TARGET_OBJECTS:python_type>
79-
)
64+
pybind11_add_module(
65+
_duckdb
66+
$<TARGET_OBJECTS:python_src>
67+
$<TARGET_OBJECTS:python_arrow>
68+
$<TARGET_OBJECTS:python_common>
69+
$<TARGET_OBJECTS:python_functional>
70+
$<TARGET_OBJECTS:python_jupyter>
71+
$<TARGET_OBJECTS:python_native>
72+
$<TARGET_OBJECTS:python_numpy>
73+
$<TARGET_OBJECTS:python_pandas>
74+
$<TARGET_OBJECTS:python_pybind11>
75+
$<TARGET_OBJECTS:python_connection>
76+
$<TARGET_OBJECTS:python_expression>
77+
$<TARGET_OBJECTS:python_relation>
78+
$<TARGET_OBJECTS:python_type>)
8079
# add _duckdb_dependencies
8180
target_link_libraries(_duckdb PRIVATE _duckdb_dependencies)
8281

82+
# ────────────────────────────────────────────
83+
# Controlling symbol export
84+
#
85+
# We want to export exactly two symbols: - PyInit__duckdb: this allows CPython
86+
# to load the module - duckdb_adbc_init: the DuckDB ADBC driver
87+
#
88+
# The export of symbols on OSX and Linux is controlled by: - Visibility
89+
# annotations in the code (for this lib we use the PYBIND11_EXPORT macro) -
90+
# Telling the linker which symbols we want exported, which we do below
91+
#
92+
# For Windows, we rely on just the visbility annotations.
93+
# ────────────────────────────────────────────
94+
set_target_properties(
95+
_duckdb
96+
PROPERTIES CXX_VISIBILITY_PRESET hidden
97+
C_VISIBILITY_PRESET hidden
98+
VISIBILITY_INLINES_HIDDEN ON)
99+
100+
if(APPLE)
101+
target_link_options(
102+
_duckdb PRIVATE "LINKER:-exported_symbol,_duckdb_adbc_init"
103+
"LINKER:-exported_symbol,_PyInit__duckdb")
104+
elseif(UNIX AND NOT APPLE)
105+
target_link_options(
106+
_duckdb PRIVATE "LINKER:--export-dynamic-symbol=duckdb_adbc_init"
107+
"LINKER:--export-dynamic-symbol=PyInit__duckdb")
108+
elseif(WIN32)
109+
target_link_options(_duckdb PRIVATE "/EXPORT:duckdb_adbc_init"
110+
"/EXPORT:PyInit__duckdb")
111+
endif()
112+
83113
# ────────────────────────────────────────────
84114
# Put the object file in the correct place
85115
# ────────────────────────────────────────────
86116

87-
# If we're not building through scikit-build-core then we have to set a different dest dir
117+
# If we're not building through scikit-build-core then we have to set a
118+
# different dest dir
88119
include(GNUInstallDirs)
89120
if(DEFINED SKBUILD_PLATLIB_DIR)
90121
set(_DUCKDB_PY_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}")
91122
elseif(DEFINED Python_SITEARCH)
92123
set(_DUCKDB_PY_INSTALL_DIR "${Python_SITEARCH}")
93124
else()
94-
message(WARNING "Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR.")
125+
message(
126+
WARNING
127+
"Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR."
128+
)
95129
set(_DUCKDB_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
96130
endif()
97131

β€Žadbc_driver_duckdb/__init__.pyβ€Ž

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919

2020
import enum
2121
import functools
22+
import importlib
2223
import typing
2324

2425
import adbc_driver_manager
2526

26-
__all__ = ["StatementOptions", "connect"]
27-
2827

2928
class StatementOptions(enum.Enum):
3029
"""Statement options specific to the DuckDB driver."""
@@ -36,12 +35,16 @@ class StatementOptions(enum.Enum):
3635
def connect(path: typing.Optional[str] = None) -> adbc_driver_manager.AdbcDatabase:
3736
"""Create a low level ADBC connection to DuckDB."""
3837
if path is None:
39-
return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), entrypoint="duckdb_adbc_init")
40-
return adbc_driver_manager.AdbcDatabase(driver=_driver_path(), entrypoint="duckdb_adbc_init", path=path)
38+
return adbc_driver_manager.AdbcDatabase(driver=driver_path(), entrypoint="duckdb_adbc_init")
39+
return adbc_driver_manager.AdbcDatabase(driver=driver_path(), entrypoint="duckdb_adbc_init", path=path)
4140

4241

4342
@functools.cache
44-
def _driver_path() -> str:
45-
import duckdb
46-
47-
return duckdb.duckdb.__file__
43+
def driver_path() -> str:
44+
"""Get the path to the DuckDB ADBC driver."""
45+
duckdb_module_spec = importlib.util.find_spec("_duckdb")
46+
if duckdb_module_spec is None:
47+
msg = "Could not find duckdb shared library. Did you pip install duckdb?"
48+
raise ImportError(msg)
49+
print(f"Found duckdb shared library at {duckdb_module_spec.origin}")
50+
return duckdb_module_spec.origin

β€Žadbc_driver_duckdb/dbapi.pyβ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
"""
19-
DBAPI 2.0-compatible facade for the ADBC DuckDB driver.
20-
"""
18+
"""DBAPI 2.0-compatible facade for the ADBC DuckDB driver."""
2119

2220
import typing
2321

2422
import adbc_driver_manager
2523
import adbc_driver_manager.dbapi
24+
2625
import adbc_driver_duckdb
2726

2827
__all__ = [

β€Žcmake/compiler_launcher.cmakeβ€Ž

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ include(CMakeParseArguments)
88
# Function to look for ccache and sccache to speed up builds, if available
99
# ────────────────────────────────────────────
1010
function(setup_compiler_launcher_if_available)
11-
if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER AND NOT DEFINED ENV{CMAKE_C_COMPILER_LAUNCHER})
12-
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
13-
if(COMPILER_LAUNCHER)
14-
message(STATUS "Using ${COMPILER_LAUNCHER} as C compiler launcher")
15-
set(CMAKE_C_COMPILER_LAUNCHER "${COMPILER_LAUNCHER}" CACHE STRING "" FORCE)
16-
endif()
11+
if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER AND NOT DEFINED
12+
ENV{CMAKE_C_COMPILER_LAUNCHER})
13+
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
14+
if(COMPILER_LAUNCHER)
15+
message(STATUS "Using ${COMPILER_LAUNCHER} as C compiler launcher")
16+
set(CMAKE_C_COMPILER_LAUNCHER
17+
"${COMPILER_LAUNCHER}"
18+
CACHE STRING "" FORCE)
1719
endif()
20+
endif()
1821

19-
if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER AND NOT DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER})
20-
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
21-
if(COMPILER_LAUNCHER)
22-
message(STATUS "Using ${COMPILER_LAUNCHER} as C++ compiler launcher")
23-
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_LAUNCHER}" CACHE STRING "" FORCE)
24-
endif()
22+
if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER
23+
AND NOT DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER})
24+
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
25+
if(COMPILER_LAUNCHER)
26+
message(STATUS "Using ${COMPILER_LAUNCHER} as C++ compiler launcher")
27+
set(CMAKE_CXX_COMPILER_LAUNCHER
28+
"${COMPILER_LAUNCHER}"
29+
CACHE STRING "" FORCE)
2530
endif()
31+
endif()
2632
endfunction()

0 commit comments

Comments
Β (0)