Skip to content

Commit f1b21f1

Browse files
raulcdjorisvandenbosscherok
authored
apacheGH-36411: [Python] Use scikit-build-core as build backend for PyArrow and get rid of setup.py (apache#49259)
### Rationale for this change Move our PyArrow build backend from setuptools and a custom setup.py to scikit-build-core which is just build backend for CMake related projects. ### What changes are included in this PR? Move from setuptools to scikit-build-core and remove PyArrow setup.py. Update some of the build requirements and minor fixes. A custom build backend has been also been created in order to wrap scikit-build-core in order to fix problems on License files for monorepos. pyproject.toml metadata validation expects license files to exist before exercising the build backend that's why we create symlinks. Our thin build backend will just make those symlinks hard-links in order for license and notice files to contain the contents and be added as part of the sdist. Remove flags that are not used anymore (were only part of setup.py) and documented and validated how the same flags have to be used now. ### Are these changes tested? Yes all Python CI tests, wheels and sdist are successful. ### Are there any user-facing changes? Yes, users building PyArrow will now require the new build dependencies to exercise the build and depending on the flags used they might require to use the new documented way of using those flags. * GitHub Issue: apache#36411 Lead-authored-by: Raúl Cumplido <raulcumplido@gmail.com> Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com> Co-authored-by: Rok Mihevc <rok@mihevc.org> Signed-off-by: Raúl Cumplido <raulcumplido@gmail.com>
1 parent 0d4f043 commit f1b21f1

30 files changed

+198
-586
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ VCPKG="66c0373dc7fca549e5803087b9487edfe3aca0a1" # 2026.01.16 Release
9999
# ci/docker/python-*-windows-*.dockerfile or the vcpkg config.
100100
# This is a workaround for our CI problem that "archery docker build" doesn't
101101
# use pulled built images in dev/tasks/python-wheels/github.windows.yml.
102-
PYTHON_WHEEL_WINDOWS_IMAGE_REVISION=2026-02-25
103-
PYTHON_WHEEL_WINDOWS_TEST_IMAGE_REVISION=2026-02-25
102+
PYTHON_WHEEL_WINDOWS_IMAGE_REVISION=2026-03-04
103+
PYTHON_WHEEL_WINDOWS_TEST_IMAGE_REVISION=2026-03-04
104104

105105
# Use conanio/${CONAN_BASE}:{CONAN_VERSION} for "docker compose run --rm conan".
106106
# See https://github.com/conan-io/conan-docker-tools#readme and

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
shell: bash
104104
run: |
105105
gem install test-unit openssl
106-
pip install "cython>=3.1" setuptools pytest requests setuptools-scm
106+
pip install build "cython>=3.1" pytest requests scikit-build-core setuptools-scm
107107
- name: Run Release Test
108108
shell: bash
109109
run: |

ci/conda_env_python.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ numpy>=1.16.6
2929
pytest
3030
pytest-faulthandler
3131
s3fs>=2023.10.0
32-
setuptools>=77
32+
scikit-build-core
3333
setuptools_scm>=8

ci/scripts/python_build.bat

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ echo "=== CCACHE Stats after build ==="
111111
ccache -sv
112112

113113
echo "=== Building Python ==="
114-
set PYARROW_BUILD_TYPE=%CMAKE_BUILD_TYPE%
115-
set PYARROW_BUILD_VERBOSE=1
116114
set PYARROW_BUNDLE_ARROW_CPP=ON
117-
set PYARROW_CMAKE_GENERATOR=%CMAKE_GENERATOR%
118115
set PYARROW_WITH_ACERO=%ARROW_ACERO%
119116
set PYARROW_WITH_AZURE=%ARROW_AZURE%
120117
set PYARROW_WITH_DATASET=%ARROW_DATASET%
@@ -137,6 +134,6 @@ pushd %SOURCE_DIR%\python
137134
%PYTHON_CMD% -m pip install -r requirements-build.txt || exit /B 1
138135

139136
@REM Build PyArrow
140-
%PYTHON_CMD% -m pip install --no-deps --no-build-isolation -vv . || exit /B 1
137+
%PYTHON_CMD% -m pip install --no-deps --no-build-isolation -vv -C build.verbose=true . || exit /B 1
141138

142139
popd

ci/scripts/python_build.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ if [ -n "${CONDA_PREFIX}" ]; then
5959
conda list
6060
fi
6161

62-
export PYARROW_CMAKE_GENERATOR=${CMAKE_GENERATOR:-Ninja}
63-
export PYARROW_BUILD_TYPE=${CMAKE_BUILD_TYPE:-debug}
64-
62+
export CMAKE_BUILD_PARALLEL_LEVEL=${n_jobs}
63+
export CMAKE_GENERATOR=${CMAKE_GENERATOR:-Ninja}
6564
export PYARROW_WITH_ACERO=${ARROW_ACERO:-OFF}
6665
export PYARROW_WITH_AZURE=${ARROW_AZURE:-OFF}
6766
export PYARROW_WITH_CUDA=${ARROW_CUDA:-OFF}
@@ -76,8 +75,6 @@ export PYARROW_WITH_PARQUET_ENCRYPTION=${PARQUET_REQUIRE_ENCRYPTION:-ON}
7675
export PYARROW_WITH_S3=${ARROW_S3:-OFF}
7776
export PYARROW_WITH_SUBSTRAIT=${ARROW_SUBSTRAIT:-OFF}
7877

79-
export PYARROW_PARALLEL=${n_jobs}
80-
8178
: "${CMAKE_PREFIX_PATH:=${ARROW_HOME}}"
8279
export CMAKE_PREFIX_PATH
8380
export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH}
@@ -90,11 +87,9 @@ export DYLD_LIBRARY_PATH=${ARROW_HOME}/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_P
9087
rm -rf "${python_build_dir}"
9188
cp -aL "${source_dir}" "${python_build_dir}"
9289
pushd "${python_build_dir}"
93-
# - Cannot call setup.py as it may install in the wrong directory
94-
# on Debian/Ubuntu (ARROW-15243).
9590
# - Cannot use build isolation as we want to use specific dependency versions
9691
# (e.g. Numpy, Pandas) on some CI jobs.
97-
${PYTHON:-python} -m pip install --no-deps --no-build-isolation -vv .
92+
${PYTHON:-python} -m pip install --no-deps --no-build-isolation -vv -C cmake.build-type="${CMAKE_BUILD_TYPE:-Debug}" .
9893
popd
9994

10095
if [ "${BUILD_DOCS_PYTHON}" == "ON" ]; then

ci/scripts/python_sdist_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ source_dir=${1}/python
2323

2424
pushd "${source_dir}"
2525
export SETUPTOOLS_SCM_PRETEND_VERSION=${PYARROW_VERSION:-}
26-
${PYTHON:-python} setup.py sdist
26+
${PYTHON:-python} -m build --sdist
2727
popd

ci/scripts/python_sdist_test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export ARROW_SOURCE_DIR=${arrow_dir}
2525
export ARROW_TEST_DATA=${arrow_dir}/testing/data
2626
export PARQUET_TEST_DATA=${arrow_dir}/cpp/submodules/parquet-testing/data
2727

28-
export PYARROW_CMAKE_GENERATOR=${CMAKE_GENERATOR:-Ninja}
29-
export PYARROW_BUILD_TYPE=${CMAKE_BUILD_TYPE:-debug}
28+
export CMAKE_GENERATOR=${CMAKE_GENERATOR:-Ninja}
3029
export PYARROW_WITH_ACERO=${ARROW_ACERO:-ON}
3130
export PYARROW_WITH_AZURE=${ARROW_AZURE:-OFF}
3231
export PYARROW_WITH_S3=${ARROW_S3:-OFF}
@@ -64,7 +63,7 @@ if [ -n "${ARROW_PYTHON_VENV:-}" ]; then
6463
. "${ARROW_PYTHON_VENV}/bin/activate"
6564
fi
6665

67-
${PYTHON:-python} -m pip install "${sdist}"
66+
${PYTHON:-python} -m pip install -C cmake.build-type="${CMAKE_BUILD_TYPE:-Debug}" "${sdist}"
6867

6968
# shellcheck disable=SC2086
7069
pytest -r s ${PYTEST_ARGS:-} --pyargs pyarrow

ci/scripts/python_wheel_macos_build.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ cmake --build . --target install
146146
popd
147147

148148
echo "=== (${PYTHON_VERSION}) Building wheel ==="
149-
export PYARROW_BUILD_TYPE=${CMAKE_BUILD_TYPE}
150-
export PYARROW_BUNDLE_ARROW_CPP=1
151-
export PYARROW_CMAKE_GENERATOR=${CMAKE_GENERATOR}
149+
export PYARROW_BUNDLE_ARROW_CPP=ON
152150
export PYARROW_WITH_ACERO=${ARROW_ACERO}
153151
export PYARROW_WITH_AZURE=${ARROW_AZURE}
154152
export PYARROW_WITH_DATASET=${ARROW_DATASET}
@@ -161,15 +159,18 @@ export PYARROW_WITH_PARQUET=${ARROW_PARQUET}
161159
export PYARROW_WITH_PARQUET_ENCRYPTION=${PARQUET_REQUIRE_ENCRYPTION}
162160
export PYARROW_WITH_SUBSTRAIT=${ARROW_SUBSTRAIT}
163161
export PYARROW_WITH_S3=${ARROW_S3}
164-
export PYARROW_CMAKE_OPTIONS="-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DARROW_SIMD_LEVEL=${ARROW_SIMD_LEVEL}"
165162
export ARROW_HOME=${build_dir}/install
166163
# PyArrow build configuration
167164
export CMAKE_PREFIX_PATH=${build_dir}/install
168165
# Set PyArrow version explicitly
169166
export SETUPTOOLS_SCM_PRETEND_VERSION=${PYARROW_VERSION}
170167

171168
pushd ${source_dir}/python
172-
python -m build --sdist --wheel . --no-isolation
169+
python -m build --sdist --wheel . --no-isolation \
170+
-C build.verbose=true \
171+
-C cmake.build-type=${CMAKE_BUILD_TYPE:-Debug} \
172+
-C cmake.args="-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}" \
173+
-C cmake.args="-DARROW_SIMD_LEVEL=${ARROW_SIMD_LEVEL}"
173174
popd
174175

175176
echo "=== (${PYTHON_VERSION}) Show dynamic libraries the wheel depend on ==="

ci/scripts/python_wheel_windows_build.bat

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ cmake --build . --config %CMAKE_BUILD_TYPE% --target install || exit /B 1
115115
popd
116116

117117
echo "=== (%PYTHON%) Building wheel ==="
118-
set PYARROW_BUILD_TYPE=%CMAKE_BUILD_TYPE%
119-
set PYARROW_BUILD_VERBOSE=1
120118
set PYARROW_BUNDLE_ARROW_CPP=ON
121-
set PYARROW_CMAKE_GENERATOR=%CMAKE_GENERATOR%
122-
set PYARROW_CMAKE_OPTIONS="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=%CMAKE_INTERPROCEDURAL_OPTIMIZATION%"
123119
set PYARROW_WITH_ACERO=%ARROW_ACERO%
124120
set PYARROW_WITH_AZURE=%ARROW_AZURE%
125121
set PYARROW_WITH_DATASET=%ARROW_DATASET%
@@ -138,7 +134,10 @@ set CMAKE_PREFIX_PATH=C:\arrow-dist
138134
pushd C:\arrow\python
139135

140136
@REM Build wheel
141-
%PYTHON_CMD% -m build --sdist --wheel . --no-isolation || exit /B 1
137+
%PYTHON_CMD% -m build --sdist --wheel . --no-isolation -vv ^
138+
-C build.verbose=true ^
139+
-C cmake.build-type=%CMAKE_BUILD_TYPE% ^
140+
-C cmake.args="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=%CMAKE_INTERPROCEDURAL_OPTIMIZATION%" || exit /B 1
142141

143142
@REM Repair the wheel with delvewheel
144143
@REM

ci/scripts/python_wheel_xlinux_build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ popd
154154
check_arrow_visibility
155155

156156
echo "=== (${PYTHON_VERSION}) Building wheel ==="
157-
export PYARROW_BUILD_TYPE=${CMAKE_BUILD_TYPE}
158-
export PYARROW_BUNDLE_ARROW_CPP=1
159-
export PYARROW_CMAKE_GENERATOR=${CMAKE_GENERATOR}
160-
export PYARROW_CMAKE_OPTIONS="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${CMAKE_INTERPROCEDURAL_OPTIMIZATION}"
157+
export PYARROW_BUNDLE_ARROW_CPP=ON
161158
export PYARROW_WITH_ACERO=${ARROW_ACERO}
162159
export PYARROW_WITH_AZURE=${ARROW_AZURE}
163160
export PYARROW_WITH_DATASET=${ARROW_DATASET}
@@ -175,7 +172,10 @@ export ARROW_HOME=/tmp/arrow-dist
175172
export CMAKE_PREFIX_PATH=/tmp/arrow-dist
176173

177174
pushd /arrow/python
178-
python -m build --sdist --wheel . --no-isolation
175+
python -m build --sdist --wheel . --no-isolation \
176+
-C build.verbose=true \
177+
-C cmake.build-type=${CMAKE_BUILD_TYPE:-Debug} \
178+
-C cmake.args="-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${CMAKE_INTERPROCEDURAL_OPTIMIZATION}"
179179

180180
echo "=== Strip symbols from wheel ==="
181181
mkdir -p dist/temp-fix-wheel

0 commit comments

Comments
 (0)