Skip to content

Commit

Permalink
apacheGH-43883: [CI] Remove Python version guard when installing GCS …
Browse files Browse the repository at this point in the history
…testbench (apache#43884)

We can now use the GCS testbench even if we are testing a Python version that does not support it.

* GitHub Issue: apache#43883

Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
pitrou authored and khwilson committed Sep 14, 2024
1 parent 9ed05af commit 7ed01ee
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ jobs:
shell: msys2 {0}
env:
PIPX_BIN_DIR: /usr/local/bin
PIPX_PYTHON: ${{ steps.python-install.outputs.python-path }}
PIPX_BASE_PYTHON: ${{ steps.python-install.outputs.python-path }}
run: |
ci/scripts/install_gcs_testbench.sh default
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/conda-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN mamba install -q -y \

# We want to install the GCS testbench using the Conda base environment's Python,
# because the test environment's Python may later change.
ENV PIPX_PYTHON=/opt/conda/bin/python3
ENV PIPX_BASE_PYTHON=/opt/conda/bin/python3
COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts
RUN /arrow/ci/scripts/install_gcs_testbench.sh default

Expand Down
14 changes: 10 additions & 4 deletions ci/docker/python-wheel-manylinux-test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ ARG arch
ARG python_image_tag
FROM ${arch}/python:${python_image_tag}

# RUN pip install --upgrade pip

# pandas doesn't provide wheel for aarch64 yet, so cache the compiled
# test dependencies in a docker image
COPY python/requirements-wheel-test.txt /arrow/python/
RUN pip install -r /arrow/python/requirements-wheel-test.txt

# Install the GCS testbench with the system Python
RUN apt-get update -y -q && \
apt-get install -y -q \
build-essential \
python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists*

COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts/
ARG python
RUN PYTHON_VERSION=${python} /arrow/ci/scripts/install_gcs_testbench.sh default
ENV PIPX_PYTHON=/usr/bin/python3 PIPX_PIP_ARGS=--prefer-binary
RUN /arrow/ci/scripts/install_gcs_testbench.sh default
25 changes: 14 additions & 11 deletions ci/scripts/install_gcs_testbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ if [[ "${version}" -eq "default" ]]; then
version="v0.39.0"
fi

: ${PIPX_PYTHON:=$(which python3)}
# The Python to install pipx with
: ${PIPX_BASE_PYTHON:=$(which python3)}
# The Python to install the GCS testbench with
: ${PIPX_PYTHON:=${PIPX_BASE_PYTHON:-$(which python3)}}

export PIP_BREAK_SYSTEM_PACKAGES=1
${PIPX_PYTHON} -m pip install -U pipx
${PIPX_BASE_PYTHON} -m pip install -U pipx

# This script is run with PYTHON undefined in some places,
# but those only use older pythons.
if [[ -z "${PYTHON_VERSION}" ]] || [[ "${PYTHON_VERSION}" != "3.13" ]]; then
pipx_flags=--verbose
if [[ $(id -un) == "root" ]]; then
# Install globally as /root/.local/bin is typically not in $PATH
pipx_flags="${pipx_flags} --global"
fi
${PIPX_PYTHON} -m pipx install ${pipx_flags} "https://github.com/googleapis/storage-testbench/archive/${version}.tar.gz"
pipx_flags=(--verbose --python ${PIPX_PYTHON})
if [[ $(id -un) == "root" ]]; then
# Install globally as /root/.local/bin is typically not in $PATH
pipx_flags+=(--global)
fi
if [[ -n "${PIPX_PIP_ARGS}" ]]; then
pipx_flags+=(--pip-args "'${PIPX_PIP_ARGS}'")
fi
${PIPX_BASE_PYTHON} -m pipx install ${pipx_flags[@]} \
"https://github.com/googleapis/storage-testbench/archive/${version}.tar.gz"
16 changes: 15 additions & 1 deletion dev/tasks/python-wheels/github.osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ jobs:
name: wheel
path: arrow/python/repaired_wheels/*.whl

# Use a well-known Python version for the GCS testbench, and avoid
# putting it in PATH.
- name: Set up Python for GCS testbench
uses: actions/setup-python@v5.1.1
id: gcs-python-install
with:
python-version: 3.12
update-environment: false

- name: Install GCS testbench
env:
PIPX_BIN_DIR: /usr/local/bin
PIPX_BASE_PYTHON: {{ '${{ steps.gcs-python-install.outputs.python-path }}' }}
run: arrow/ci/scripts/install_gcs_testbench.sh default

- name: Test Wheel
env:
PYTEST_ADDOPTS: "-k 'not test_cancellation'"
Expand All @@ -121,7 +136,6 @@ jobs:
source test-env/bin/activate
pip install --upgrade pip wheel
arch -{{ arch }} pip install -r arrow/python/requirements-wheel-test.txt
PYTHON_VERSION={{ python_version }} arch -{{ arch }} arrow/ci/scripts/install_gcs_testbench.sh default
arch -{{ arch }} arrow/ci/scripts/python_wheel_unix_test.sh $(pwd)/arrow
{{ macros.github_upload_releases("arrow/python/repaired_wheels/*.whl")|indent }}
Expand Down

0 comments on commit 7ed01ee

Please sign in to comment.