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


##########
python/pyarrow/meson.build:
##########
@@ -0,0 +1,344 @@
+# 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
+
+cython_generated_headers = custom_target(

Review Comment:
   This is a piece I am struggling with and could use any of your expertise 
@eli-schwartz . The gist of the problem is that we need to use `cythonize` to 
generate the `lib.h` and `lib_api.h` header files before we compile the 
`arrow_python` shared library. `cythonize` takes a Cython file, and generates 
header files directly in the source tree right next to the source .pxd/.pyx 
files. As far as I can tell, there is no way to control this.
   
   Additionally, the pyarrow installation is expecting the lib.h and lib_api.h 
header files to be installed at `pyarrow/arrow/python`. I originally thought of 
moving lib.pyx to the `src/arrow/python` subdirectory for better control over 
where the output was going, but this breaks all of the cython imports that 
expect the current file structure.
   
   Another thought was to run the custom target and then use `fs.copyfile` to 
copy from the source tree to the appropriate target directory folder. However, 
I am not sure how to sequence that properly, since `fs.copyfile` does not take 
on a dependency argument



-- 
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