WillAyd commented on code in PR #45854:
URL: https://github.com/apache/arrow/pull/45854#discussion_r2019090418


##########
python/pyarrow/meson.build:
##########
@@ -0,0 +1,398 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+py = import('python').find_installation(pure: false)
+
+# When NumPy 2.0 becomes the minimum we can remove the
+# custom location check
+numpy_dep = dependency('numpy', required: false)
+if not numpy_dep.found()
+    incdir_numpy = run_command(
+        py,
+        [
+            '-c',
+            '''
+import os
+import numpy as np
+try:
+    # Check if include directory is inside the pyarrow dir
+    # e.g. a venv created inside the pyarrow dir
+    # If so, convert it to a relative path
+    incdir = os.path.relpath(np.get_include())
+except Exception:
+    incdir = np.get_include()
+print(incdir)
+''',
+        ],
+        check: true,
+    ).stdout().strip()
+
+    numpy_dep = declare_dependency(include_directories: incdir_numpy)
+endif
+
+cython_args = ['--include-dir', meson.current_source_dir()]
+if get_option('buildtype') in ['debug', 'debugoptimized']
+    cython_args += ['--gdb']
+endif
+
+pyarrow_srcs = files(
+    'src/arrow/python/arrow_to_pandas.cc',
+    'src/arrow/python/benchmark.cc',
+    'src/arrow/python/common.cc',
+    'src/arrow/python/datetime.cc',
+    'src/arrow/python/decimal.cc',
+    'src/arrow/python/extension_type.cc',
+    'src/arrow/python/gdb.cc',
+    'src/arrow/python/helpers.cc',
+    'src/arrow/python/inference.cc',
+    'src/arrow/python/io.cc',
+    'src/arrow/python/ipc.cc',
+    'src/arrow/python/numpy_convert.cc',
+    'src/arrow/python/numpy_init.cc',
+    'src/arrow/python/numpy_to_arrow.cc',
+    'src/arrow/python/pyarrow.cc',
+    'src/arrow/python/python_test.cc',
+    'src/arrow/python/python_to_arrow.cc',
+    'src/arrow/python/udf.cc',
+)
+
+# TODO: these are optional components so should detect if needed
+# if needs_csv
+pyarrow_srcs += files('src/arrow/python/csv.cc')
+#endif
+# if needs_filesystem
+pyarrow_srcs += files('src/arrow/python/filesystem.cc')
+#endif
+
+subdir('src/arrow/python')
+
+arrow_python_lib = shared_library(
+    'arrow_python',
+    sources: pyarrow_srcs,
+    include_directories: ['src'],
+    dependencies: [arrow_dep, numpy_dep, cython_generated_dep, 
py.dependency()],
+    cpp_args: '-DARROW_PYTHON_EXPORTING',
+    override_options: ['b_lundef=false'],
+    install: true,
+    install_dir: py.get_install_dir() / 'pyarrow',
+)
+
+cython_modules = {
+    'lib': {},
+    '_compute': {},
+    '_csv': {},
+    '_feather': {},
+    '_fs': {},
+    '_json': {},
+    '_pyarrow_cpp_tests': {},
+}
+
+if get_option('azure').enabled()
+    cython_modules += {'_azurefs': {}}
+endif
+
+if get_option('gcs').enabled()
+    cython_modules += {'_gcsfs': {}}
+endif
+
+if get_option('s3').enabled()
+    cython_modules += {'_s3fs': {}}
+endif
+
+if get_option('hdfs').enabled()
+    cython_modules += {'_hdfs': {}}
+endif
+
+if get_option('cuda').enabled()
+    cuda_dep = dependency(
+        'arrow-cuda',
+        'ArrowCUDA',
+        modules: ['ArrowCUDA::arrow_cuda_shared'],
+    )
+    cython_modules += {'_cuda': {'dependencies': cuda_dep}}
+endif
+
+if get_option('acero').enabled()
+    acero_dep = dependency(
+        'arrow-acero',
+        'ArrowAcero',
+        modules: ['ArrowAcero::arrow_acero_shared'],
+    )
+
+    cython_modules += {'_acero': {'dependencies': acero_dep}}
+endif
+
+if get_option('dataset').enabled()
+    dataset_dep = dependency(
+        'arrow-dataset',
+        'ArrowDataset',
+        modules: ['ArrowDataset::arrow_dataset_shared'],
+    )
+
+    cython_modules += {'_dataset': {'dependencies': dataset_dep}}
+endif
+
+if get_option('parquet').enabled()
+    parquet_dep = dependency(
+        'parquet',
+        'Parquet',
+        modules: ['Parquet::parquet_shared'],
+    )
+
+    cython_modules += {'_parquet': {'dependencies': parquet_dep}}
+
+    if get_option('parquet_encryption').enabled()
+        arrow_encryption_lib = shared_library(
+            'arrow_python_parquet_encryption',
+            sources: ['src/arrow/python/parquet_encryption.cc'],
+            include_directories: ['src'],
+            link_with: [arrow_python_lib],
+            dependencies: [parquet_dep, py.dependency()],
+            cpp_args: '-DARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING',
+            override_options: ['b_lundef=false'],
+            install: true,
+            install_dir: py.get_install_dir() / 'pyarrow',
+        )
+
+        arrow_encryption_dep = declare_dependency(
+            link_with: arrow_encryption_lib,
+        )
+
+        cython_modules += {
+            '_parquet_encryption': {
+                'dependencies': [parquet_dep, arrow_encryption_dep],
+            },
+        }
+    endif
+
+    if get_option('dataset').enabled()
+        cython_modules += {
+            '_dataset_parquet': {'dependencies': [dataset_dep, parquet_dep]},
+        }
+
+        if get_option('parquet_encryption').enabled()
+            cython_modules += {
+                '_dataset_parquet_encryption': {
+                    'dependencies': [dataset_dep, parquet_dep],
+                },
+            }
+        endif
+    endif
+endif
+
+if get_option('parquet_encryption').enabled() and not 
get_option('parquet').enabled()
+    warning(
+        'Building PyArrow with Parquet Encryption is requested, but Parquet 
itself is not enabled. Ignoring the Parquet Encryption setting.',
+    )
+endif
+
+if get_option('orc').enabled()
+    cython_modules += {'_orc': {}}
+
+    if get_option('dataset').enabled()
+        cython_modules += {'_dataset_orc': {'dependencies': [dataset_dep]}}
+    endif
+endif
+
+if get_option('flight').enabled()
+    flight_dep = dependency(
+        'arrow-flight',
+        'ArrowFlight',
+        modules: ['ArrowFlight::arrow_flight_shared'],
+    )
+
+    flight_lib = shared_library(
+        'arrow_flight_lib',
+        sources: ['src/arrow/python/flight.cc'],
+        link_with: [arrow_python_lib],
+        dependencies: [flight_dep, py.dependency()],
+        include_directories: ['src'],
+        cpp_args: '-DARROW_PYFLIGHT_EXPORTING',
+        override_options: ['b_lundef=false'],
+        install: true,
+        install_dir: py.get_install_dir() / 'pyarrow',
+    )
+
+    arrow_flight_dep = declare_dependency(link_with: flight_lib)
+    cython_modules += {'_flight': {'dependencies': arrow_flight_dep}}
+endif
+
+if get_option('substrait').enabled()
+    substrait_dep = dependency(
+        'arrow-substrait',
+        'ArrowSubstrait',
+        modules: ['ArrowSubstrait::arrow_substrait_shared'],
+    )
+
+    cython_modules += {'_substrait': {'dependencies': substrait_dep}}
+endif
+
+if get_option('gandiva').enabled()
+    gandiva_dep = dependency(
+        'gandiva',
+        'Gandiva',
+        modules: ['Gandiva::gandiva_shared'],
+    )
+
+    cython_modules += {'gandiva': {'dependencies': gandiva_dep}}
+endif
+
+foreach key, val : cython_modules
+    cython_mod_name = '@0@.pyx'.format(key)
+    py.extension_module(
+        key,
+        sources: [cython_mod_name],
+        include_directories: ['src'],
+        link_with: arrow_python_lib,
+        cython_args: cython_args,
+        dependencies: [arrow_dep, numpy_dep] + val.get('dependencies', []),
+        override_options: ['cython_language=cpp'],
+        install: true,
+        subdir: 'pyarrow',
+    )
+
+    install_data(cython_mod_name, install_dir: py.get_install_dir() / 
'pyarrow')
+endforeach
+
+cython_headers = [
+    '_acero.pxd',
+    'array.pxi',
+    'benchmark.pxi',
+    'builder.pxi',
+    'compat.pxi',
+    '_compute.pxd',
+    'config.pxi',
+    '_csv.pxd',
+    '_cuda.pxd',
+    '_dataset_parquet.pxd',
+    '_dataset.pxd',
+    'device.pxi',
+    '_dlpack.pxi',
+    'error.pxi',
+    '_fs.pxd',
+    '__init__.pxd',
+    'io.pxi',
+    'ipc.pxi',
+    '_json.pxd',
+    'lib.pxd',
+    'memory.pxi',
+    '_orc.pxd',
+    'pandas-shim.pxi',
+    '_parquet_encryption.pxd',
+    '_parquet.pxd',
+    'public-api.pxi',
+    '_pyarrow_cpp_tests.pxd',
+    'scalar.pxi',
+    'table.pxi',
+    'tensor.pxi',
+    'types.pxi',
+]
+
+install_data(cython_headers, install_dir: py.get_install_dir() / 'pyarrow')
+
+install_subdir('includes', install_dir: py.get_install_dir() / 'pyarrow')
+
+install_subdir(
+    'src/arrow/python',
+    install_dir: py.get_install_dir() / 'pyarrow/src/arrow',
+)
+
+pysources = [
+    'acero.py',
+    'benchmark.py',
+    'cffi.py',
+    '_compute_docstrings.py',
+    'compute.py',
+    'conftest.py',
+    'csv.py',
+    'cuda.py',
+    'dataset.py',
+    'feather.py',
+    'flight.py',
+    'fs.py',
+    '_generated_version.py',
+    '__init__.py',
+    'ipc.py',
+    'json.py',
+    'jvm.py',
+    'orc.py',
+    'pandas_compat.py',
+    'substrait.py',
+    'types.py',
+    'util.py',
+]
+py.install_sources(pysources, subdir: 'pyarrow')
+
+py.install_sources(
+    files(
+        'src/arrow/python/api.h',
+        'src/arrow/python/arrow_to_pandas.h',
+        'src/arrow/python/async.h',
+        'src/arrow/python/benchmark.h',
+        'src/arrow/python/common.h',
+        'src/arrow/python/csv.h',
+        'src/arrow/python/datetime.h',
+        'src/arrow/python/decimal.h',
+        'src/arrow/python/extension_type.h',
+        'src/arrow/python/filesystem.h',
+        'src/arrow/python/flight.h',
+        'src/arrow/python/gdb.h',
+        'src/arrow/python/helpers.h',
+        'src/arrow/python/inference.h',
+        'src/arrow/python/io.h',
+        'src/arrow/python/ipc.h',
+        'src/arrow/python/iterators.h',
+        'src/arrow/python/numpy_convert.h',
+        'src/arrow/python/numpy_init.h',
+        'src/arrow/python/numpy_interop.h',
+        'src/arrow/python/numpy_to_arrow.h',
+        'src/arrow/python/parquet_encryption.h',
+        'src/arrow/python/pch.h',
+        'src/arrow/python/platform.h',
+        'src/arrow/python/pyarrow.h',
+        'src/arrow/python/pyarrow_lib.h',
+        'src/arrow/python/python_test.h',
+        'src/arrow/python/python_to_arrow.h',
+        'src/arrow/python/type_traits.h',
+        'src/arrow/python/udf.h',
+        'src/arrow/python/visibility.h',
+    ),
+    subdir: 'pyarrow/include/arrow/python',
+)
+
+if arrow_dep.found()
+    arrow_header_dir = arrow_dep.get_variable(
+        cmake: 'ARROW_INCLUDE_DIR',

Review Comment:
   In Crossbow I see this is failing in an environment where cmake is present 
but not pkgconfig. It looks like `ARROW_INCLUDE_DIR` is not an exported 
variable, but rather a local variable pointing to the 
`INTERFACE_INCLUDE_DIRECTORIES` property of the `arrow_shared` target.
   
   I couldn't find a good way in Meson to extract that property from a target, 
if its even possible. Maybe the CMake configuration needs to export this as a 
variable so other build systems can benefit?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to