forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-wheel-windows.sh
executable file
·147 lines (121 loc) · 4.3 KB
/
build-wheel-windows.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env bash
set -euxo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
WORKSPACE_DIR="${ROOT_DIR}/.."
PY_VERSIONS=("3.8" "3.9" "3.10" "3.11")
bazel_preclean() {
"${WORKSPACE_DIR}"/ci/run/bazel.py preclean "mnemonic(\"Genrule\", deps(//:*))"
}
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}"
}
refreshenv() {
# https://gist.github.com/jayvdb/1daf8c60e20d64024f51ec333f5ce806
powershell -NonInteractive - <<\EOF
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
# Print out the list of env vars we're going to export.
# Sometimes the bash source fails, this will help with debugging.
gci env:
# Round brackets in variable names cause problems with bash
Get-ChildItem env:* | %{
if (!($_.Name.Contains('('))) {
$value = $_.Value
if ($_.Name -eq 'PATH') {
$value = $value -replace ';',':'
}
# Use heredocs to wrap values. This fixes problems with environment variables containing single quotes.
# An environment variable containing the string REFRESHENV_EOF could still cause problems, but is
# far less likely than a single quote.
Write-Output ("export " + $_.Name + "=$`(cat <<- 'REFRESHENV_EOF'`n" + $value + "`nREFRESHENV_EOF`)")
}
} | Out-File -Encoding ascii $env:TEMP\refreshenv.sh
EOF
source "$TEMP/refreshenv.sh"
}
install_ray() {
# TODO(mehrdadn): This function should be unified with the one in ci/ci.sh.
(
pip install wheel
pushd dashboard/client
choco install nodejs -y
refreshenv
# https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported
export NODE_OPTIONS=--openssl-legacy-provider
npm install
npm run build
popd
cd "${WORKSPACE_DIR}"/python
"${WORKSPACE_DIR}"/ci/keep_alive pip install -v -e .
)
}
uninstall_ray() {
pip uninstall -y ray
python -s -c "import runpy, sys; runpy.run_path(sys.argv.pop(), run_name='__api__')" clean "${ROOT_DIR}"/setup.py
}
build_wheel_windows() {
local ray_uninstall_status=0
uninstall_ray || ray_uninstall_status=1
local local_dir="python/dist"
{
echo "build --announce_rc";
echo "build --config=ci";
echo "startup --output_user_root=c:/raytmp";
echo "build --remote_cache=${BUILDKITE_BAZEL_CACHE_URL}";
} >> ~/.bazelrc
if [[ "$BUILDKITE_PIPELINE_ID" == "0189942e-0876-4b8f-80a4-617f988ec59b" ]]; then
# Do not upload cache results for premerge pipeline
echo "build --remote_upload_local_results=false" >> ~/.bazelrc
fi
for pyversion in "${PY_VERSIONS[@]}"; do
if [[ "${BUILD_ONE_PYTHON_ONLY:-}" != "" && "${pyversion}" != "${BUILD_ONE_PYTHON_ONLY}" ]]; then
continue
fi
bazel_preclean
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
conda install -y conda=23.1.0 python="${pyversion}"
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
# Set the commit SHA in _version.py.
if [ -n "$BUILDKITE_COMMIT" ]; then
sed -i.bak "s/{{RAY_COMMIT_SHA}}/$BUILDKITE_COMMIT/g" ray/_version.py && rm ray/_version.py.bak
else
echo "BUILDKITE_COMMIT variable not set - required to populated ray.__commit__."
exit 1
fi
# build ray wheel
python setup.py --quiet bdist_wheel
# build ray-cpp wheel
RAY_INSTALL_CPP=1 python setup.py --quiet bdist_wheel
uninstall_ray
)
done
bazel_preclean
if [ 0 -eq "${ray_uninstall_status}" ]; then # If Ray was previously installed, restore it
install_ray
fi
}
build_wheel_windows "$@"