This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3193b95ae7 GH-43514: [Python] Deprecate passing build flags to 
setup.py (#43515)
3193b95ae7 is described below

commit 3193b95ae757750669f6181441171fd84240c749
Author: Joris Van den Bossche <[email protected]>
AuthorDate: Thu Aug 1 17:11:22 2024 +0200

    GH-43514: [Python] Deprecate passing build flags to setup.py (#43515)
    
    ### Rationale for this change
    
    As mentioned in 
https://github.com/apache/arrow/pull/41494#issuecomment-2092829903 (while 
refactoring how to specify to the pyarrow build which components to build, i.e. 
to let it follow the Arrow C++ components by default), we do have a "feature" 
that you can specify which components to build directly to setup.py, like 
`python setup.py build_ext --with-parquet`.
    
    This is currently not used in our own codebase, and is also not documented 
anymore, but we did document it in the past.
    
    In general calling setup.py directly is not recommended (although for 
development installs, it is still useful), furthermore there are alternatives 
to those flags (relying on Arrow C++ or setting an environment variable), and 
this would go away anyhow in case we would move away from setuptools at some 
point.
    So I think it is better to deprecate those options.
    
    ### What changes are included in this PR?
    
    Whenever a user passes such a `--with-` flag, a warning is raised.
    
    ### Are these changes tested?
    
    Tested it locally
    
    ### Are there any user-facing changes?
    
    Only for developers building pyarrow from source, they have to potentially 
update their build instructions.
    * GitHub Issue: #43514
    
    Lead-authored-by: Joris Van den Bossche <[email protected]>
    Co-authored-by: Raúl Cumplido <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 python/setup.py | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/python/setup.py b/python/setup.py
index 11cd702802..2cef1c2d31 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -24,6 +24,7 @@ from os.path import join as pjoin
 import re
 import shlex
 import sys
+import warnings
 
 if sys.version_info >= (3, 10):
     import sysconfig
@@ -84,6 +85,23 @@ def strtobool(val):
         raise ValueError("invalid truth value %r" % (val,))
 
 
+MSG_DEPR_SETUP_BUILD_FLAGS = """
+  !!
+
+        ***********************************************************************
+        The '{}' flag is being passed to setup.py, but this is
+        deprecated.
+
+        If a certain component is available in Arrow C++, it will automatically
+        be enabled for the PyArrow build as well. If you want to force the
+        build of a certain component, you can still use the
+        PYARROW_WITH_$COMPONENT environment variable.
+        ***********************************************************************
+
+  !!
+"""
+
+
 class build_ext(_build_ext):
     _found_names = ()
 
@@ -258,9 +276,16 @@ class build_ext(_build_ext):
                     varname, 'on' if value else 'off'))
 
             def append_cmake_component(flag, varname):
-                # only pass this to cmake is the user pass the --with-component
+                # only pass this to cmake if the user pass the --with-component
                 # flag to setup.py build_ext
                 if flag is not None:
+                    flag_name = (
+                        "--with-"
+                        + 
varname.removeprefix("PYARROW_").lower().replace("_", "-"))
+                    warnings.warn(
+                        MSG_DEPR_SETUP_BUILD_FLAGS.format(flag_name),
+                        UserWarning, stacklevel=2
+                    )
                     append_cmake_bool(flag, varname)
 
             if self.cmake_generator:

Reply via email to