Skip to content

Commit 0e2bb53

Browse files
SemyonSinchenkoSemyonSinchenko
andauthored
chore: refactor pyproject (#936)
* chore: refactor pyproject * fix: regenerate lock * fix: pytest * feat: exclude pyarrow * fix: remove duplicated row * fix: fix deps for now * fix: apt syntax * fix: fix version and orc support * fix: fix ubuntu branch * fix: fix macos * chore: dynamic version and fix warnings * chore: bump cache version to the latest * chore: update publish workflow * chore: sync publish with dev ci --------- Co-authored-by: SemyonSinchenko <semyon.sinchenko@gmail.com>
1 parent 277d666 commit 0e2bb53

7 files changed

Lines changed: 672 additions & 431 deletions

File tree

.github/workflows/python-wheel-workflow.yml

Lines changed: 123 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Licensed to the Apache Software Foundation (ASF) under one
32
# or more contributor license agreements. See the NOTICE file
43
# distributed with this work for additional information
@@ -32,15 +31,13 @@ on:
3231
- 'cpp/**'
3332
- 'python/**'
3433
- '.github/workflows/python-wheel-workflow.yml'
35-
- '.github/scripts/update_version.py'
3634
pull_request:
3735
branches:
3836
- "main"
3937
paths:
4038
- 'cpp/**'
4139
- 'python/**'
4240
- '.github/workflows/python-wheel-workflow.yml'
43-
- '.github/scripts/update_version.py'
4441
workflow_dispatch:
4542
inputs:
4643
publish_pypi:
@@ -52,30 +49,32 @@ on:
5249
jobs:
5350
build_sdist:
5451
name: Build source distribution
55-
runs-on: ubuntu-22.04
52+
runs-on: ubuntu-24.04
5653
steps:
57-
- uses: actions/checkout@v4
54+
# fetch-depth 0 is required: since version
55+
# is derived from git history
56+
- uses: actions/checkout@v7
57+
with:
58+
fetch-depth: 0
5859

5960
- name: Set up Python
60-
uses: actions/setup-python@v5
61+
uses: actions/setup-python@v6
6162
with:
62-
python-version: "3.9"
63+
python-version: "3.10"
6364

6465
- name: Install dependencies
6566
run: |
6667
python -m pip install --upgrade pip
6768
pip install build twine
68-
- name: update pyproject version
69-
if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_pypi != 'true'
70-
run: |
71-
python .github/scripts/update_version.py
69+
7270
- name: Build sdist
7371
run: |
7472
# Bundle C++ sources into python/ so the sdist contains them.
7573
rm -rf python/_bundled_cpp
7674
cp -a cpp python/_bundled_cpp
7775
cd python
7876
python -m build --sdist
77+
7978
- name: Store artifacts
8079
uses: actions/upload-artifact@v4
8180
with:
@@ -91,33 +90,41 @@ jobs:
9190
include:
9291
# Job 1: Native x86_64 build
9392
- platform: x86_64
94-
runner: ubuntu-latest # This is the standard x86_64 runner
93+
runner: ubuntu-24.04 # This is the standard x86_64 runner
9594
os: linux
9695
manylinux: _2_28
9796

9897
# Job 2: Native aarch64 build
9998
- platform: aarch64
100-
runner: ubuntu-22.04-arm # This is a native ARM64 runner
99+
runner: ubuntu-24.04-arm # This is a native ARM64 runner
101100
os: linux
102101
manylinux: _2_28
103102

104103
# Job 3: macOS arm64 build
104+
# Pinned, not macos-latest: the runner OS sets the effective macOS
105+
# deployment target (see CIBW_ENVIRONMENT_MACOS), so a mutable label
106+
# could silently change the minimum macOS of the produced wheels.
105107
- platform: arm64
106-
runner: macos-latest
108+
runner: macos-15
107109
os: macos
108110

109-
110111
env:
112+
# Must match the pyarrow pinned in python/pyproject.toml (pyarrow == 24.0.0).
113+
# Single source of truth for the Arrow version: it is used by the macOS
114+
# steps (build from source) and by the Linux dnf pins below.
115+
ARROW_VERSION: "24.0.0"
111116
CIBW_PLATFORM: ${{ matrix.os }}
112-
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
117+
# Keep in sync with requires-python (>= 3.10) and the classifiers in
118+
# python/pyproject.toml. pyarrow ~= 24.0 (the runtime Arrow provider) has
119+
# wheels for cp310-cp314 on every platform we build.
120+
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*"
113121
CIBW_SKIP: "*-musllinux_*"
114122
# Use uv on macOS to avoid transient GitHub rate limits when cibuildwheel
115123
CIBW_BUILD_FRONTEND: ${{ matrix.os == 'macos' && 'build[uv]' || 'build' }}
116124
# Pin arch to the matrix platform
117125
CIBW_ARCHS: ${{ matrix.platform }}
118126
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.os == 'linux' && format('manylinux{0}', matrix.manylinux) || '' }}
119127
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.os == 'linux' && format('manylinux{0}', matrix.manylinux) || '' }}
120-
CIBW_ENVIRONMENT_WINDOWS: DISTUTILS_USE_SDK=1 MSSdk=1
121128
CIBW_ENVIRONMENT_MACOS: ${{ matrix.os == 'macos' && 'MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) CMAKE_OSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) CFLAGS=-mmacosx-version-min=$(sw_vers -productVersion) CXXFLAGS=-mmacosx-version-min=$(sw_vers -productVersion) LDFLAGS=-mmacosx-version-min=$(sw_vers -productVersion)' || '' }}
122129
CIBW_BEFORE_BUILD_LINUX: |
123130
set -eux
@@ -137,59 +144,116 @@ jobs:
137144
dnf config-manager --set-enabled ol$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)_codeready_builder || :
138145
dnf config-manager --set-enabled codeready-builder-for-rhel-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)-rhui-rpms || :
139146
subscription-manager repos --enable codeready-builder-for-rhel-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)-$(arch)-rpms || :
140-
dnf install -y arrow-devel # For C++
141-
dnf install -y arrow-glib-devel # For GLib (C)
142-
dnf install -y arrow-dataset-devel # For Apache Arrow Dataset C++
143-
dnf install -y arrow-dataset-glib-devel # For Apache Arrow Dataset GLib (C)
144-
dnf install -y arrow-acero-devel # For Apache Arrow Acero C++
145-
dnf install -y arrow-flight-devel # For Apache Arrow Flight C++
146-
dnf install -y arrow-flight-glib-devel # For Apache Arrow Flight GLib (C)
147-
dnf install -y arrow-flight-sql-devel # For Apache Arrow Flight SQL C++
148-
dnf install -y arrow-flight-sql-glib-devel # For Apache Arrow Flight SQL GLib (C)
149-
dnf install -y gandiva-devel # For Apache Gandiva C++
150-
dnf install -y gandiva-glib-devel # For Apache Gandiva GLib (C)
151-
dnf install -y parquet-devel # For Apache Parquet C++
152-
dnf install -y parquet-glib-devel # For Apache Parquet GLib (C)
147+
# Pin the exact Arrow version: the wheel must be built against the same
148+
# 24.0.0 that pyarrow == 24.0.0 ships (and that ARROW_VERSION above
149+
# pins for macOS), because Arrow is resolved at runtime from the
150+
# sibling pyarrow package instead of being bundled (see
151+
# CIBW_REPAIR_WHEEL_COMMAND_* below). Installing the unpinned "latest"
152+
# (e.g. 25.x) would produce libs whose SONAME does not exist in
153+
# pyarrow, breaking every wheel.
154+
dnf install -y arrow-devel-24.0.0 # For C++
155+
dnf install -y arrow-glib-devel-24.0.0 # For GLib (C)
156+
dnf install -y arrow-dataset-devel-24.0.0 # For Apache Arrow Dataset C++
157+
dnf install -y arrow-dataset-glib-devel-24.0.0 # For Apache Arrow Dataset GLib (C)
158+
dnf install -y arrow-acero-devel-24.0.0 # For Apache Arrow Acero C++
159+
dnf install -y arrow-flight-devel-24.0.0 # For Apache Arrow Flight C++
160+
dnf install -y arrow-flight-glib-devel-24.0.0 # For Apache Arrow Flight GLib (C)
161+
dnf install -y arrow-flight-sql-devel-24.0.0 # For Apache Arrow Flight SQL C++
162+
dnf install -y arrow-flight-sql-glib-devel-24.0.0 # For Apache Arrow Flight SQL GLib (C)
163+
dnf install -y parquet-devel-24.0.0 # For Apache Parquet C++
164+
dnf install -y parquet-glib-devel-24.0.0 # For Apache Parquet GLib (C)
165+
# Do NOT bundle Arrow/Parquet/Dataset/Acero/Compute into the wheel: the
166+
# python/CMakeLists.txt RPATH ($ORIGIN/../pyarrow on Linux,
167+
# @loader_path/../pyarrow on macOS) resolves them at runtime from the
168+
# sibling pyarrow package (pyarrow ~= 24.0). auditwheel/delocate keep the
169+
# preserved RPATH entry and only bundle whatever else is left (e.g. re2,
170+
# zstd from the manylinux container).
171+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
172+
auditwheel repair --exclude libarrow.so.* --exclude libarrow_compute.so.* --exclude libarrow_dataset.so.* --exclude libarrow_acero.so.* --exclude libparquet.so.* -w {dest_dir} {wheel}
173+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
174+
delocate-wheel --exclude libarrow --exclude libarrow_compute --exclude libarrow_dataset --exclude libarrow_acero --exclude libparquet -w {dest_dir} -v {wheel}
153175
154176
steps:
155177
- name: Checkout (needed for some tooling)
156-
uses: actions/checkout@v4
157-
158-
- name: Set up Python
159-
uses: actions/setup-python@v5
178+
uses: actions/checkout@v7
160179
with:
161-
python-version: "3.9"
180+
# fetch-depth 0 is required: the sdist is extracted inside this
181+
# checkout and setuptools-scm (search_parent_directories) picks up the
182+
# parent .git. Without tags the wheel version collapses to "0.1.dev1"
183+
# instead of reproducing the version baked into the sdist's PKG-INFO.
184+
fetch-depth: 0
162185

163-
- name: Set up Miniconda (Windows)
164-
if: matrix.os == 'windows'
165-
uses: conda-incubator/setup-miniconda@v3
186+
- name: Set up Python
187+
uses: actions/setup-python@v6
166188
with:
167-
auto-activate-base: true
168-
miniforge-version: latest
169-
use-mamba: true
189+
python-version: "3.10"
170190

171191
- name: Install Arrow (macOS)
172192
if: matrix.os == 'macos'
173193
shell: bash
174194
run: |
175195
set -euxo pipefail
176-
brew install apache-arrow
177-
echo "CMAKE_PREFIX_PATH=/usr/local" >> "$GITHUB_ENV"
178-
# Optional sanity check: ensure Arrow dylib isn't built for a newer macOS than deployment target.
179-
if command -v otool >/dev/null 2>&1; then
180-
ls -lah /usr/local/lib || true
181-
if [ -f "/usr/local/lib/libarrow.dylib" ]; then
182-
otool -l "/usr/local/lib/libarrow.dylib" | (grep -A3 -E 'LC_BUILD_VERSION|LC_VERSION_MIN_MACOSX' || true)
183-
fi
184-
fi
196+
brew bundle --file=cpp/Brewfile
197+
# Homebrew's apache-arrow is built without ORC support, so it is
198+
# removed here and Arrow is built from source in the next step (with
199+
# ARROW_ORC), exactly like the python.yml CI workflow does.
200+
brew uninstall apache-arrow || true
201+
echo "CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/arrow-dist" >> "$GITHUB_ENV"
202+
203+
- name: Cache Arrow build (macOS)
204+
if: matrix.os == 'macos'
205+
id: arrow-cache
206+
uses: actions/cache@v6
207+
with:
208+
path: ${{ github.workspace }}/arrow-dist
209+
# The hash of this workflow is part of the key so that changing the
210+
# Arrow CMake flags below invalidates the cached build.
211+
key: arrow-${{ runner.os }}-${{ runner.arch }}-${{ env.ARROW_VERSION }}-${{ hashFiles('.github/workflows/python-wheel-workflow.yml') }}
185212

186-
- name: Install Arrow (Windows)
187-
if: matrix.os == 'windows'
188-
shell: pwsh
213+
- name: Build Arrow from source (macOS, with ORC)
214+
if: matrix.os == 'macos' && steps.arrow-cache.outputs.cache-hit != 'true'
189215
run: |
190-
mamba install -y -c conda-forge arrow-cpp
191-
Add-Content $env:GITHUB_ENV "CMAKE_PREFIX_PATH=$env:CONDA_PREFIX\\Library"
192-
Add-Content $env:GITHUB_ENV "PATH=$env:CONDA_PREFIX\\Library\\bin;$env:PATH"
216+
set -euxo pipefail
217+
curl -fLsS -o "apache-arrow-${ARROW_VERSION}.tar.gz" \
218+
"https://archive.apache.org/dist/arrow/arrow-${ARROW_VERSION}/apache-arrow-${ARROW_VERSION}.tar.gz"
219+
tar xzf "apache-arrow-${ARROW_VERSION}.tar.gz"
220+
cmake -S "apache-arrow-${ARROW_VERSION}/cpp" -B arrow-build \
221+
-DCMAKE_BUILD_TYPE=Release \
222+
-DCMAKE_INSTALL_PREFIX="${CMAKE_PREFIX_PATH}" \
223+
-DCMAKE_INSTALL_LIBDIR=lib \
224+
-DARROW_BUILD_SHARED=ON \
225+
-DARROW_BUILD_STATIC=OFF \
226+
-DARROW_DEPENDENCY_SOURCE=BUNDLED \
227+
-DARROW_PARQUET=ON \
228+
-DARROW_DATASET=ON \
229+
-DARROW_ACERO=ON \
230+
-DARROW_ORC=ON \
231+
-DARROW_CSV=ON \
232+
-DARROW_JSON=ON \
233+
-DARROW_COMPUTE=ON \
234+
-DARROW_FILESYSTEM=ON \
235+
-DARROW_WITH_SNAPPY=ON \
236+
-DARROW_WITH_ZSTD=ON \
237+
-DARROW_WITH_LZ4=ON \
238+
-DARROW_WITH_BZ2=ON \
239+
-DARROW_WITH_BROTLI=ON \
240+
-DARROW_WITH_ZLIB=ON \
241+
-DARROW_WITH_UTF8PROC=ON \
242+
-DARROW_WITH_RE2=ON \
243+
-DARROW_S3=OFF \
244+
-DARROW_GCS=OFF \
245+
-DARROW_AZURE=OFF \
246+
-DARROW_FLIGHT=OFF \
247+
-DARROW_JEMALLOC=OFF \
248+
-DARROW_MIMALLOC=OFF \
249+
-DARROW_BUILD_TESTS=OFF \
250+
-DARROW_BUILD_BENCHMARKS=OFF \
251+
-DARROW_BUILD_EXAMPLES=OFF \
252+
-DARROW_BUILD_INTEGRATION=OFF \
253+
-DARROW_BUILD_UTILITIES=OFF \
254+
-DARROW_PYTHON=OFF
255+
cmake --build arrow-build --target install -j "$(sysctl -n hw.ncpu)"
256+
193257
- name: Download sdist artifact
194258
uses: actions/download-artifact@v4
195259
with:
@@ -254,11 +318,10 @@ jobs:
254318
python -c "import graphar; import graphar._core; print('GraphAr imported successfully')"
255319
graphar --help >/dev/null
256320
257-
258321
upload_test_pypi:
259322
name: Publish to TestPyPI (auto)
260323
needs: [build_wheels, build_sdist]
261-
runs-on: ubuntu-22.04
324+
runs-on: ubuntu-24.04
262325
if: github.event_name == 'push'
263326
permissions:
264327
contents: read
@@ -282,7 +345,7 @@ jobs:
282345
upload_pypi:
283346
name: Publish (manual)
284347
needs: [build_wheels, build_sdist]
285-
runs-on: ubuntu-22.04
348+
runs-on: ubuntu-24.04
286349
if: github.event_name == 'workflow_dispatch' && inputs.publish_pypi
287350
permissions:
288351
contents: read
@@ -300,4 +363,4 @@ jobs:
300363
- name: Publish to PyPI
301364
uses: pypa/gh-action-pypi-publish@release/2473ec6c6aa87f38946284d51289219fd0b87264
302365
with:
303-
packages-dir: python/dist/
366+
packages-dir: python/dist/

0 commit comments

Comments
 (0)