Skip to content

Commit 17d5426

Browse files
committed
build(python): Use meson-python for adbc_driver_manager
1 parent 332e145 commit 17d5426

14 files changed

Lines changed: 207 additions & 143 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ target/
124124
/ci/linux-packages/yum/tmp/
125125

126126
# Meson subproject support
127-
/c/subprojects/*
128-
!/c/subprojects/*.wrap
127+
**/subprojects/*
128+
!**/subprojects/*.wrap

c/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ if(ADBC_BUILD_PYTHON)
9999
# but you don't technically need -DADBC_DRIVER_MANAGER=ON when installing
100100
# other Python packages. To be safe then, we always install the driver
101101
# manager package, regardless of the value of -DABC_DRIVER_MANAGER
102-
# --config-settings eidtable_mode=compat required due to
103-
# https://github.com/python/mypy/issues/13392
104-
add_custom_target(python
105-
COMMAND ${Python3_EXECUTABLE} -m pip install --no-deps -e
106-
"${REPOSITORY_ROOT}/python/adbc_driver_manager"
107-
--config-settings editable_mode=compat)
102+
add_custom_target(python COMMAND ${Python3_EXECUTABLE} -m pip install --no-deps -e
103+
"${REPOSITORY_ROOT}/python/adbc_driver_manager")
108104

109105
macro(adbc_install_python_package TARGET)
110106
string(TOUPPER ${TARGET} ${TARGET}_LIB_upper)

ci/scripts/python_sdist_build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ echo "=== (${PYTHON_VERSION}) Building ADBC sdists ==="
3030

3131
# https://github.com/pypa/pip/issues/7555
3232
# Get the latest pip so we have in-tree-build by default
33-
pip install --upgrade pip setuptools
33+
pip install --upgrade pip build
3434

3535
# For drivers, which bundle shared libraries, defer that to install time
3636
export _ADBC_IS_SDIST=1
@@ -41,7 +41,7 @@ for component in ${COMPONENTS}; do
4141
echo "=== Building $component sdist ==="
4242
# python -m build copies to a tempdir, so we can't reference other files in the repo
4343
# https://github.com/pypa/pip/issues/5519
44-
python setup.py sdist
44+
python -m build --sdist .
4545

4646
popd
4747
done

ci/scripts/python_wheel_unix_relocate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ for component in $COMPONENTS; do
7676
# container during build, but it only copies the package
7777
# directory, which omits the C++ sources and .git directory,
7878
# causing the build to fail.
79-
python setup.py sdist
79+
python -m build --sdist .
8080
if [[ "$component" = "adbc_driver_manager" ]]; then
8181
python -m cibuildwheel --output-dir repaired_wheels/ dist/$component-*.tar.gz
8282
else

dev/release/rat_exclude_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ go/adbc/status_string.go
2929
go/adbc/infocode_string.go
3030
go/adbc/go.sum
3131
java/.mvn/jvm.config
32+
python/*/subprojects/arrow-adbc/*
3233
python/*/*/py.typed
3334
rat.txt
3435
r/*/DESCRIPTION
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
py.extension_module(
19+
'_backward',
20+
sources: ['_backward.pyx'],
21+
dependencies: [backward_dep],
22+
include_directories: backward_incdir,
23+
override_options: ['cython_language=cpp'],
24+
install: true,
25+
subdir: 'adbc_driver_manager',
26+
)
27+
28+
py.extension_module(
29+
'_lib',
30+
sources: ['_blocking_impl.cc', '_lib.pyx'],
31+
dependencies: [adbc_driver_manager_dep],
32+
override_options: ['cython_language=cpp'],
33+
install: true,
34+
subdir: 'adbc_driver_manager',
35+
)
36+
37+
py.extension_module(
38+
'_reader',
39+
sources: ['_reader.pyx'],
40+
dependencies: [adbc_driver_manager_dep],
41+
override_options: ['cython_language=cpp'],
42+
install: true,
43+
subdir: 'adbc_driver_manager',
44+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
project(
19+
'adbc_driver_manager',
20+
'cython',
21+
version: run_command(
22+
['python', 'adbc_driver_manager/_version.py'],
23+
check: true,
24+
).stdout().replace(
25+
'Version:',
26+
'',
27+
).strip(),
28+
license: 'Apache-2.0',
29+
meson_version: '>=1.2.1',
30+
default_options: [
31+
'buildtype=release',
32+
'warning_level=2',
33+
'cpp_std=c++17',
34+
# conda environments may only provide a static library for
35+
# libbfd, which backward-cpp requires.
36+
'default_library=static',
37+
],
38+
)
39+
40+
backward_dep = dependency('backward-cpp')
41+
# hack until https://github.com/mesonbuild/wrapdb/pull/2072
42+
backward_incdir = include_directories('subprojects/backward-cpp-1.6')
43+
44+
adbc_driver_manager_dep = dependency(
45+
'adbc-driver-manager',
46+
fallback: ['arrow-adbc', 'adbc_driver_manager_dep'],
47+
default_options: ['driver_manager=enabled'],
48+
)
49+
py = import('python').find_installation(pure: false)
50+
51+
cython_args = []
52+
if get_option('buildtype') in ['debug', 'debugoptimized']
53+
cython_args += ['--gdb']
54+
endif
55+
56+
subdir('adbc_driver_manager')
57+
58+
meson.add_dist_script(py, files('scripts/remove_third_party_wraps.py'))

python/adbc_driver_manager/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ homepage = "https://arrow.apache.org/adbc/"
3434
repository = "https://github.com/apache/arrow-adbc"
3535

3636
[build-system]
37-
requires = ["Cython", "setuptools >= 61.0.0"]
38-
build-backend = "setuptools.build_meta"
37+
requires = ["Cython", "meson-python"]
38+
build-backend = "mesonpy"
3939

4040
[tool.pytest.ini_options]
4141
markers = [
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# This script is a workaround for the issue described in
19+
# https://github.com/mesonbuild/meson/issues/14520
20+
21+
import os
22+
import pathlib
23+
24+
dist_root = pathlib.Path(os.environ["MESON_DIST_ROOT"])
25+
os.unlink(dist_root / "subprojects" / "nanoarrow.wrap")
26+
os.unlink(dist_root / "subprojects" / "fmt.wrap")

python/adbc_driver_manager/setup.py

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)