You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/12 07:12:30 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13311: ARROW-16340: [Python] Move all Python related code into PyArrow

pitrou commented on code in PR #13311:
URL: https://github.com/apache/arrow/pull/13311#discussion_r918623819


##########
python/setup.py:
##########
@@ -227,6 +228,94 @@ def initialize_options(self):
         '_hdfsio',
         'gandiva']
 
+    def _run_cmake_arrow_python(self):
+        # check if build_type is correctly passed / set
+        if self.build_type.lower() not in ('release', 'debug'):
+            raise ValueError("--build-type (or PYARROW_BUILD_TYPE) needs to "
+                             "be 'release' or 'debug'")
+
+        # The directory containing this setup.py
+        source = os.path.dirname(os.path.abspath(__file__))
+        # The directory containing this C PyArrow CMakeLists.txt
+        source_cpyarrow = pjoin(source, "pyarrow/src_arrow")
+
+        # The directory for the module being built
+        build_cmd = self.get_finalized_command('build')
+        saved_cwd = os.getcwd()
+        build_temp = pjoin(saved_cwd, 'build/dist/temp')
+        build_include = pjoin(saved_cwd, 'build/dist/include')
+        build_lib = pjoin(os.getcwd(), build_cmd.build_lib)
+
+        # The directory containing Arrow C++ build
+        arrow_build_dir = os.environ.get('ARROW_BUILD_DIR', 'build')
+
+        if self.inplace:
+            # a bit hacky
+            build_lib = saved_cwd
+
+        if not os.path.isdir(build_temp):
+            self.mkpath(build_temp)
+        if not os.path.isdir(build_lib):
+            self.mkpath(build_lib)
+        if not os.path.isdir(build_include):
+            self.mkpath(build_include)
+
+        # Change to the build directory
+        with changed_dir(build_temp):
+            # cmake args
+            cmake_options = [
+                '-DCMAKE_INSTALL_PREFIX=' +
+                str(pjoin(saved_cwd, 'build/dist')),
+                '-DCMAKE_BUILD_TYPE={0}'.format(self.build_type.lower()),
+                '-DARROW_BUILD_DIR=' + str(arrow_build_dir),
+                '-DPYTHON_EXECUTABLE=%s' % sys.executable,
+                '-DPython3_EXECUTABLE=%s' % sys.executable,
+            ]
+
+            # Check for specific options
+            def append_cmake_bool(value, varname):
+                cmake_options.append('-D{0}={1}'.format(
+                    varname, 'on' if value else 'off'))
+
+            append_cmake_bool(self.with_dataset, 'PYARROW_WITH_DATASET')
+            append_cmake_bool(self.with_parquet_encryption,
+                              'PYARROW_WITH_PARQUET_ENCRYPTION')
+            append_cmake_bool(self.with_hdfs,
+                              'PYARROW_WITH_HDFS')
+
+            # run cmake
+            print("-- Running cmake for C pyarrow")
+            self.spawn(['cmake'] + cmake_options + [source_cpyarrow])
+            print("-- Finished cmake for C pyarrow")
+            # run make & install
+            print("-- Running make build and install for C pyarrow")
+            self.spawn(['make', '-j4'])

Review Comment:
   Yes, and we should not invoke `make` directly but let `cmake` do the interface so that the right generator is invoked.



-- 
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-unsubscribe@arrow.apache.org

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