Skip to content

GH-1497: [CI] Use python3 in build.sh on macOS - #1498

Open
andygrove wants to merge 1 commit into
apache:mainfrom
andygrove:fix/build-sh-python3
Open

andygrove wants to merge 1 commit into
apache:mainfrom
andygrove:fix/build-sh-python3

Conversation

@andygrove

Copy link
Copy Markdown
Member

What's Changed

macOS does not ship a python executable, only python3. When the release verification script builds the source release on macOS, ci/scripts/build.sh uses python to compute relative paths for the pom.xml files, so the build fails.

This uses ${PYTHON:-python3}, as dev/release/run_rat.sh already does. Linux uses realpath and is not affected.

Closes #1497.

🤖 Generated with Claude Code

macOS does not ship a python executable, so building the source
release fails when it computes pom.xml paths. Use ${PYTHON:-python3},
as dev/release/run_rat.sh already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andygrove andygrove added the chore PRs that make misc changes. label Nov 17, 2026
@andygrove
andygrove requested a review from jbonofre as a code owner November 17, 2026 14:25
@andygrove andygrove added the chore PRs that make misc changes. label Nov 17, 2026
@github-actions github-actions Bot added this to the 20.0.0 milestone Nov 17, 2026
Comment thread ci/scripts/build.sh
Comment on lines 46 to 56
# crawl back up to the top. GNU realpath has --relative-to but this does not
# work on macOS

poms=$(find "${source_dir}" -not \( -path "${source_dir}"/build -prune \) -type f -name pom.xml)
if [[ "$OSTYPE" == "darwin"* ]]; then
poms=$(echo "$poms" | xargs -n1 python -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")
poms=$(echo "$poms" | xargs -n1 "${PYTHON:-python3}" -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")
else
poms=$(echo "$poms" | xargs -n1 realpath -s --relative-to="${source_dir}")
fi

for source_root in $(echo "${poms}" | awk -F/ '{print $1}' | sort -u); do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using cd "${source_dir}" to get relative path?

Suggested change
# crawl back up to the top.
poms=$(cd "${source_dir}" && find . -not \( -path ./build -prune \) -type f -name pom.xml)
# ./dataset/pom.xml -> dataset
for source_root in $(echo "${poms}" | awk -F/ '{print $2}' | sort -u); do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this approach. Dropping the python/realpath branch removes the Python dependency completely, makes Linux and macOS take the exact same code path, and avoids interpolating ${source_dir} inside a single-quoted Python string.

I verified locally on macOS that cd "${source_dir}" && find . ... | awk -F/ '{print $2}' | sort -u produces the exact same top-level entries as the current os.path.relpath command (including the root pom.xml).

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove for catching and fixing this! The current change works, but I would prefer @kou cd "${source_dir}" && find . suggestion so we can drop the Python dependency and the macOS specific branch altogether.

Comment thread ci/scripts/build.sh
poms=$(find "${source_dir}" -not \( -path "${source_dir}"/build -prune \) -type f -name pom.xml)
if [[ "$OSTYPE" == "darwin"* ]]; then
poms=$(echo "$poms" | xargs -n1 python -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")
poms=$(echo "$poms" | xargs -n1 "${PYTHON:-python3}" -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using "${PYTHON:-python3}" fixes the missing python binary on macOS, though I prefer @kou suggest above: running find after cd "${source_dir}" removes both the Python dependency and the OS-specific if/else branch, and avoids pasting ${source_dir} directly into Python source ('${source_dir}').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore PRs that make misc changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] build.sh fails on macOS because python is not available

3 participants