Skip to content

Commit dd85d94

Browse files
committed
Bootstrap into subprojects directory
1 parent 614da15 commit dd85d94

15 files changed

+126
-82
lines changed

.github/workflows/build-and-test-device.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ on:
2828
- 'CMakeLists.txt'
2929
- '.github/workflows/build-and-test-device.yaml'
3030
- 'src/nanoarrow/**'
31-
- 'python/setup.py'
31+
- 'python/meson.build'
32+
- 'python/src/nanoarrow/meson.build'
3233

3334
permissions:
3435
contents: read
@@ -156,4 +157,4 @@ jobs:
156157
if: matrix.config.label == 'with-cuda'
157158
run: |
158159
cd python
159-
python3 -m pytest -vv
160+
python3 -m pytest -vv tests

.github/workflows/python-wheels.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ on:
2424
- main
2525
paths:
2626
- '.github/workflows/python-wheels.yaml'
27-
- 'python/setup.py'
27+
- 'python/meson.build'
28+
- 'python/src/nanoarrow/meson.build'
2829
- 'python/pyproject.toml'
2930
- 'python/bootstrap.py'
31+
- 'python/generate_dist.py'
3032
- 'python/MANIFEST.in'
3133
push:
3234
branches:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ __pycache__
3333
subprojects/*
3434
!subprojects/packagefiles
3535
!subprojects/*.wrap
36+
python/subprojects/*
3637

3738
compile_commands.json

dev/release/rat_exclude_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ dist/flatcc.c
1515
src/nanoarrow/ipc/flatcc_generated.h
1616
thirdparty/*
1717
python/src/nanoarrow/dlpack_abi.h
18+
python/subprojects/arrow-nanoarrow

dev/release/source_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ main() {
4343
# Resolve all hard and symbolic links
4444
rm -rf "${base_name}.tmp/"
4545
mv "${base_name}/" "${base_name}.tmp/"
46-
cp -R -L "${base_name}.tmp" "${base_name}"
46+
cp -R -d "${base_name}.tmp" "${base_name}"
4747
rm -rf "${base_name}.tmp/"
4848

4949
# Create new tarball

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ services:
4343
# Don't mix the "dev tools" and "source" checkouts
4444
- ./ci/scripts/build-docs.sh:/build-docs.sh
4545
- ${NANOARROW_DOCKER_SOURCE_DIR}:/nanoarrow
46-
command: "/bin/bash /build-docs.sh /nanoarrow"
46+
command: "/build-docs.sh /nanoarrow"
4747

4848
integration:
4949
# Don't cache here (building the image takes about the same amount of time

meson.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ if get_option('ipc')
103103
)
104104
nanoarrow_ipc_dep = declare_dependency(include_directories: [incdir],
105105
link_with: nanoarrow_ipc_lib,
106-
dependencies: [nanoarrow_dep, flatcc_dep])
106+
dependencies: [nanoarrow_dep])
107107
endif
108108

109109
needs_device = get_option('device') or get_option('metal') or get_option('cuda')
@@ -137,6 +137,10 @@ if needs_device
137137
install: true,
138138
cpp_args: device_defines,
139139
)
140+
141+
nanoarrow_device_dep = declare_dependency(include_directories: [incdir],
142+
link_with: nanoarrow_device_lib,
143+
dependencies: device_deps)
140144
endif
141145

142146
needs_testing = get_option('testing') or get_option('tests')

python/bootstrap.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ def _write_defs(self, output):
223223
output.write(b"\n")
224224

225225

226-
# Runs cmake -DNANOARROW_BUNDLE=ON if cmake exists or copies nanoarrow.c/h
227-
# from ../dist if it does not. Running cmake is safer because it will sync
228-
# any changes from nanoarrow C library sources in the checkout but is not
229-
# strictly necessary for things like installing from GitHub.
230226
def copy_or_generate_nanoarrow_c(target_dir: pathlib.Path):
231227
vendored_files = [
232228
"nanoarrow.h",
@@ -239,21 +235,12 @@ def copy_or_generate_nanoarrow_c(target_dir: pathlib.Path):
239235
dst = {name: target_dir / name for name in vendored_files}
240236

241237
this_dir = pathlib.Path(__file__).parent.resolve()
242-
source_dir = this_dir.parent
243-
is_cmake_dir = (source_dir / "CMakeLists.txt").exists()
244-
is_in_nanoarrow_repo = (
245-
is_cmake_dir and (source_dir / "src" / "nanoarrow" / "nanoarrow.h").exists()
246-
)
247-
248-
if not is_in_nanoarrow_repo:
249-
raise ValueError(
250-
"Attempt to build source distribution outside the nanoarrow repo"
251-
)
238+
arrow_proj_dir = this_dir / "subprojects" / "arrow-nanoarrow"
252239

253240
subprocess.run(
254241
[
255242
sys.executable,
256-
source_dir / "ci" / "scripts" / "bundle.py",
243+
arrow_proj_dir / "ci" / "scripts" / "bundle.py",
257244
"--symbol-namespace",
258245
"PythonPkg",
259246
"--header-namespace",

python/generate_dist.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
import os
19+
import pathlib
20+
import shutil
21+
22+
23+
def main():
24+
src_dir = pathlib.Path(os.environ["MESON_SOURCE_ROOT"]).parent.resolve()
25+
dist_dir = pathlib.Path(os.environ["MESON_DIST_ROOT"]).resolve()
26+
subproj_dir = dist_dir / "subprojects" / "arrow-nanoarrow"
27+
28+
if subproj_dir.is_symlink():
29+
subproj_dir.unlink()
30+
31+
subproj_dir.mkdir(parents=True)
32+
shutil.copy(src_dir / "meson.build", subproj_dir / "meson.build")
33+
shutil.copy(src_dir / "meson.options", subproj_dir / "meson.options")
34+
35+
# Copy over any subproject dependency / wrap files
36+
subproj_subproj_dir = subproj_dir / "subprojects"
37+
subproj_subproj_dir.mkdir()
38+
for f in (src_dir / "subprojects").glob("*.wrap"):
39+
shutil.copy(f, subproj_subproj_dir / f.name)
40+
shutil.copytree(
41+
src_dir / "subprojects" / "packagefiles", subproj_subproj_dir / "packagefiles"
42+
)
43+
44+
target_src_dir = subproj_dir / "src"
45+
shutil.copytree(src_dir / "src", target_src_dir)
46+
47+
# CMake isn't actually required for building, but the bundle.py script reads from
48+
# its configuration
49+
shutil.copy(src_dir / "CMakeLists.txt", subproj_dir / "CMakeLists.txt")
50+
51+
subproj_ci_scripts_dir = subproj_dir / "ci" / "scripts"
52+
subproj_ci_scripts_dir.mkdir(parents=True)
53+
shutil.copy(
54+
src_dir / "ci" / "scripts" / "bundle.py", subproj_ci_scripts_dir / "bundle.py"
55+
)
56+
57+
58+
if __name__ == "__main__":
59+
main()

python/meson.build

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ project(
2525
'warning_level=2',
2626
'c_std=c99',
2727
'default_library=static',
28+
# We need to set these options at the project default_option level
29+
# due to https://github.com/mesonbuild/meson/issues/6728
30+
'arrow-nanoarrow:ipc=true',
31+
'arrow-nanoarrow:device=true',
32+
'arrow-nanoarrow:namespace=PythonPkg',
2833
],
2934
)
3035

31-
py = import('python').find_installation(pure: false)
32-
33-
subdir('vendor')
3436
subdir('src/nanoarrow')
37+
38+
meson.add_dist_script('python', meson.current_source_dir() / 'generate_dist.py')

python/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ Changelog = "https://github.com/apache/arrow-nanoarrow/blob/main/CHANGELOG.md"
4040
requires = [
4141
"meson>=1.3.0",
4242
"meson-python",
43-
"cmake>=3.14",
4443
"Cython"
4544
]
4645
build-backend = "mesonpy"
46+
47+
48+
[tool.meson-python.args]
49+
install = ['--skip-subprojects']

python/src/nanoarrow/_ipc_lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ from nanoarrow._array cimport CArrayView
3838
from nanoarrow._utils cimport Error
3939

4040

41-
cdef extern from "nanoarrow_ipc.h" nogil:
41+
cdef extern from "nanoarrow/nanoarrow_ipc.h" nogil:
4242
struct ArrowIpcInputStream:
4343
ArrowErrorCode (*read)(ArrowIpcInputStream* stream, uint8_t* buf,
4444
int64_t buf_size_bytes, int64_t* size_read_out,

python/src/nanoarrow/meson.build

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

18+
nanoarrow_proj = subproject('arrow-nanoarrow')
19+
nanoarrow_dep = nanoarrow_proj.get_variable('nanoarrow_dep')
20+
nanoarrow_ipc_dep = nanoarrow_proj.get_variable('nanoarrow_ipc_dep')
21+
nanoarrow_device_dep = nanoarrow_proj.get_variable('nanoarrow_device_dep')
22+
23+
py = import('python').find_installation(pure: false)
24+
25+
vendored_files = custom_target(
26+
'generate-pyx',
27+
output: [
28+
'flatcc.c',
29+
'nanoarrow.c',
30+
'nanoarrow_c.pxd',
31+
'nanoarrow_device.c',
32+
'nanoarrow_device_c.pxd',
33+
'nanoarrow_device.h',
34+
'nanoarrow_device.hpp',
35+
'nanoarrow.h',
36+
'nanoarrow.hpp',
37+
'nanoarrow_ipc.c',
38+
'nanoarrow_ipc.h',
39+
'nanoarrow_ipc.hpp',
40+
],
41+
command: [
42+
py,
43+
meson.current_source_dir() + '/../../bootstrap.py',
44+
'--output-dir', meson.current_build_dir()
45+
],
46+
)
47+
48+
nanoarrow_pyx_dep = declare_dependency(
49+
sources: vendored_files[2],
50+
)
51+
1852
cyfiles = [
1953
'_array.pyx',
2054
'_array_stream.pyx',
@@ -30,19 +64,19 @@ cython_args = [
3064
'--include-dir',
3165
meson.current_source_dir(),
3266
'--include-dir',
33-
meson.project_build_root() / 'vendor',
67+
meson.current_build_dir(),
3468
]
3569
if get_option('buildtype') == 'debug'
3670
cython_args += ['--gdb']
3771
endif
3872

3973
fs = import('fs')
4074
foreach cyf : cyfiles
41-
cyfile_deps = [nanoarrow_pyx_dep]
75+
cyfile_deps = [nanoarrow_pyx_dep, nanoarrow_dep]
4276

4377
stem = fs.stem(cyf)
4478
if stem in ['_array', '_device']
45-
cyfile_deps += [nanoarrow_device_pyx_dep]
79+
cyfile_deps += [nanoarrow_device_dep]
4680
elif stem == '_ipc_lib'
4781
cyfile_deps += [nanoarrow_ipc_dep]
4882
endif

python/subprojects/arrow-nanoarrow

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../..

python/vendor/meson.build

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

0 commit comments

Comments
 (0)