mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:06:31 +08:00
Speedups for GitHub Actions (#9343)
Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
|
||||
WORKSPACE_DIR="${ROOT_DIR}/.."
|
||||
|
||||
PY_VERSIONS=(3.6 3.7 3.8)
|
||||
PY_SCRIPT_SUBDIR=Scripts # 'bin' for UNIX, 'Scripts' for Windows
|
||||
|
||||
get_python_version() {
|
||||
python -s -c "import sys; sys.stdout.write('%s.%s' % sys.version_info[:2])"
|
||||
}
|
||||
|
||||
is_python_version() {
|
||||
local expected result=0
|
||||
expected="$1"
|
||||
case "$(get_python_version).0." in
|
||||
"${expected}".*) ;;
|
||||
*) result=1;;
|
||||
esac
|
||||
case "$(pip --version | tr -d "\r")" in
|
||||
*" (python ${expected})") ;;
|
||||
*) result=1;;
|
||||
esac
|
||||
return "${result}"
|
||||
}
|
||||
|
||||
install_ray() {
|
||||
# TODO(mehrdadn): This function should be unified with the one in ci/travis/ci.sh.
|
||||
(
|
||||
pip install wheel
|
||||
|
||||
cd "${WORKSPACE_DIR}"/python
|
||||
pip install -v -e .
|
||||
)
|
||||
}
|
||||
|
||||
uninstall_ray() {
|
||||
pip uninstall -y ray
|
||||
}
|
||||
|
||||
build_wheel_windows() {
|
||||
local ray_uninstall_status=0
|
||||
uninstall_ray || ray_uninstall_status=1
|
||||
|
||||
local pyversion pyversions=()
|
||||
for pyversion in "${PY_VERSIONS[@]}"; do
|
||||
if [ "${pyversion}" = "${PYTHON-}" ]; then continue; fi # we'll build ${PYTHON} last
|
||||
pyversions+=("${pyversion}")
|
||||
done
|
||||
pyversions+=("${PYTHON-}") # build this last so any subsequent steps use the right version
|
||||
|
||||
local local_dir="python/dist"
|
||||
for pyversion in "${pyversions[@]}"; do
|
||||
if [ -z "${pyversion}" ]; then continue; fi
|
||||
"${WORKSPACE_DIR}"/ci/travis/bazel-preclean.sh
|
||||
git clean -q -f -f -x -d -e "${local_dir}" -e python/ray/dashboard/client
|
||||
git checkout -q -f -- .
|
||||
|
||||
# Start a subshell to prevent PATH and cd from affecting our shell environment
|
||||
(
|
||||
if ! is_python_version "${pyversion}"; then
|
||||
local pydirs=("${RUNNER_TOOL_CACHE}/Python/${pyversion}".*/x64)
|
||||
local pydir="${pydirs[-1]}"
|
||||
pydir="$(cygpath -u "${pydir}")" # Translate Windows path
|
||||
test -d "${pydir}"
|
||||
export PATH="${pydir}:${pydir}/${PY_SCRIPT_SUBDIR}:${PATH}"
|
||||
fi
|
||||
if ! is_python_version "${pyversion}"; then
|
||||
echo "Expected pip for Python ${pyversion} but found Python $(get_python_version) with $(pip --version); exiting..." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unset PYTHON2_BIN_PATH PYTHON3_BIN_PATH # make sure these aren't set by some chance
|
||||
install_ray
|
||||
cd "${WORKSPACE_DIR}"/python
|
||||
python setup.py --quiet bdist_wheel
|
||||
uninstall_ray
|
||||
)
|
||||
done
|
||||
|
||||
"${WORKSPACE_DIR}"/ci/travis/bazel-preclean.sh
|
||||
if [ 0 -eq "${ray_uninstall_status}" ]; then # If Ray was previously installed, restore it
|
||||
install_ray
|
||||
fi
|
||||
}
|
||||
|
||||
build_wheel_windows "$@"
|
||||
Reference in New Issue
Block a user