Skip to content

Commit cca9b9e

Browse files
authored
[ci] make test-macos-wheel.sh macos only (#53208)
drops other paltform support also fixes some small lints. Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
1 parent 6854e05 commit cca9b9e

File tree

1 file changed

+47
-57
lines changed

1 file changed

+47
-57
lines changed

ci/build/test-macos-wheels.sh

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@ set -x
88

99
ROOT_DIR=$(cd "$(dirname "$0")/$(dirname "$(test -L "$0" && readlink "$0" || echo "/")")"; pwd)
1010

11-
platform=""
12-
case "${OSTYPE}" in
13-
linux*) platform="linux";;
14-
darwin*) platform="macosx";;
15-
msys*) platform="windows";;
16-
*) echo "Unrecognized platform."; exit 1;;
17-
esac
11+
if [[ ! "${OSTYPE}" =~ ^darwin ]]; then
12+
echo "ERROR: This wheel test script is only for MacOS platforms." >/dev/stderr
13+
exit 1
14+
fi
1815

1916
BUILD_DIR="${TRAVIS_BUILD_DIR-}"
20-
if [ -z "${BUILD_DIR}" ]; then
17+
if [[ -z "${BUILD_DIR}" ]]; then
2118
BUILD_DIR="${GITHUB_WORKSPACE}"
2219
fi
23-
if [ -n "${BUILDKITE-}" ]; then
20+
if [[ -n "${BUILDKITE-}" ]]; then
2421
BUILD_DIR="${ROOT_DIR}/../.."
2522
fi
2623
TEST_DIR="${BUILD_DIR}/python/ray/tests"
@@ -45,66 +42,59 @@ function retry {
4542
done
4643
}
4744

48-
if [[ "$platform" == "macosx" ]]; then
49-
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
45+
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
5046

51-
PY_WHEEL_VERSIONS=("39" "310")
52-
PY_MMS=("3.9" "3.10")
47+
PY_WHEEL_VERSIONS=("39" "310")
48+
PY_MMS=("3.9" "3.10")
5349

54-
for ((i=0; i<${#PY_MMS[@]}; ++i)); do
55-
PY_MM="${PY_MMS[i]}"
50+
for ((i=0; i<${#PY_MMS[@]}; ++i)); do
51+
PY_MM="${PY_MMS[i]}"
5652

57-
PY_WHEEL_VERSION="${PY_WHEEL_VERSIONS[i]}"
53+
PY_WHEEL_VERSION="${PY_WHEEL_VERSIONS[i]}"
5854

59-
# Todo: The main difference between arm64 and x86_64 is
60-
# the Mac OS version. We should move everything to a
61-
# single path when it's acceptable to move up our lower
62-
# Python + MacOS compatibility bound.
63-
if [ "$(uname -m)" = "arm64" ]; then
64-
CONDA_ENV_NAME="test-wheels-p$PY_MM"
55+
# Todo: The main difference between arm64 and x86_64 is
56+
# the Mac OS version. We should move everything to a
57+
# single path when it's acceptable to move up our lower
58+
# Python + MacOS compatibility bound.
59+
if [[ "$(uname -m)" == "arm64" ]]; then
60+
CONDA_ENV_NAME="test-wheels-p$PY_MM"
6561

66-
[ -f "$HOME/.bash_profile" ] && conda init bash
62+
[[ -f "$HOME/.bash_profile" ]] && conda init bash
6763

68-
source ~/.bash_profile
64+
source ~/.bash_profile
6965

70-
conda create -y -n "$CONDA_ENV_NAME"
71-
conda activate "$CONDA_ENV_NAME"
72-
conda remove -y python || true
73-
conda install -y python="${PY_MM}"
66+
conda create -y -n "$CONDA_ENV_NAME"
67+
conda activate "$CONDA_ENV_NAME"
68+
conda remove -y python || true
69+
conda install -y python="${PY_MM}"
7470

75-
PYTHON_EXE="/opt/homebrew/opt/miniconda/envs/${CONDA_ENV_NAME}/bin/python"
76-
PIP_CMD="/opt/homebrew/opt/miniconda/envs/${CONDA_ENV_NAME}/bin/pip"
77-
else
78-
PYTHON_EXE="$MACPYTHON_PY_PREFIX/$PY_MM/bin/python$PY_MM"
79-
PIP_CMD="$(dirname "$PYTHON_EXE")/pip$PY_MM"
80-
fi
71+
PYTHON_EXE="/opt/homebrew/opt/miniconda/envs/${CONDA_ENV_NAME}/bin/python"
72+
PIP_CMD="/opt/homebrew/opt/miniconda/envs/${CONDA_ENV_NAME}/bin/pip"
73+
else
74+
PYTHON_EXE="$MACPYTHON_PY_PREFIX/$PY_MM/bin/python$PY_MM"
75+
PIP_CMD="$(dirname "$PYTHON_EXE")/pip$PY_MM"
76+
fi
8177

82-
# Find the appropriate wheel by grepping for the Python version.
83-
PYTHON_WHEEL="$(printf "%s\n" "$ROOT_DIR"/../../.whl/*"cp$PY_WHEEL_VERSION-cp$PY_WHEEL_VERSION"* | head -n 1)"
78+
# Find the appropriate wheel by grepping for the Python version.
79+
PYTHON_WHEEL="$(printf "%s\n" "$ROOT_DIR"/../../.whl/*"cp$PY_WHEEL_VERSION-cp$PY_WHEEL_VERSION"* | head -n 1)"
8480

85-
# Print some env info
86-
"$PYTHON_EXE" --version
87-
"$PYTHON_EXE" -c "from distutils import util; print(util.get_platform())" || true
81+
# Print some env info
82+
"$PYTHON_EXE" --version
83+
"$PYTHON_EXE" -c "from distutils import util; print(util.get_platform())" || true
8884

89-
# Update pip
90-
"$PIP_CMD" install -U pip
85+
# Update pip
86+
"$PIP_CMD" install -U pip
9187

92-
# Install the wheel.
93-
"$PIP_CMD" uninstall -y ray
94-
"$PIP_CMD" install -q "$PYTHON_WHEEL"
88+
# Install the wheel.
89+
"$PIP_CMD" uninstall -y ray
90+
"$PIP_CMD" install -q "$PYTHON_WHEEL"
9591

96-
# Install the dependencies to run the tests.
97-
"$PIP_CMD" install -q aiohttp numpy 'pytest==7.0.1' requests proxy.py
92+
# Install the dependencies to run the tests.
93+
"$PIP_CMD" install -q aiohttp numpy 'pytest==7.0.1' requests proxy.py
9894

99-
# Run a simple test script to make sure that the wheel works.
100-
# We set the python path to prefer the directory of the wheel content: https://github.com/ray-project/ray/pull/30090
101-
for SCRIPT in "${TEST_SCRIPTS[@]}"; do
102-
PY_IGNORE_IMPORTMISMATCH=1 PATH="$(dirname "$PYTHON_EXE"):$PATH" retry "$PYTHON_EXE" "$SCRIPT"
103-
done
95+
# Run a simple test script to make sure that the wheel works.
96+
# We set the python path to prefer the directory of the wheel content: https://github.com/ray-project/ray/pull/30090
97+
for SCRIPT in "${TEST_SCRIPTS[@]}"; do
98+
PY_IGNORE_IMPORTMISMATCH=1 PATH="$(dirname "$PYTHON_EXE"):$PATH" retry "$PYTHON_EXE" "$SCRIPT"
10499
done
105-
elif [ "${platform}" = windows ]; then
106-
echo "WARNING: Wheel testing not yet implemented for Windows."
107-
else
108-
echo "Unrecognized environment."
109-
exit 3
110-
fi
100+
done

0 commit comments

Comments
 (0)