Skip to content

Commit

Permalink
Internal change.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702831948
  • Loading branch information
iindyk authored and copybara-github committed Dec 4, 2024
1 parent 94b6f2d commit fb97d67
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion oss/runner_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Builds ArrayRecord from source code located in SOURCE_DIR producing wheels
# under $SOURCE_DIR/all_dist.
function build_and_test_array_record() {
function build_and_test_array_record_linux() {
SOURCE_DIR=$1

# Automatically decide which platform to build for by checking on which
Expand Down Expand Up @@ -40,5 +40,63 @@ function build_and_test_array_record() {
bash oss/build_whl.sh
done

ls ${SOURCE_DIR}/all_dist/*.whl
}

function install_and_init_pyenv {
pyenv_root=${1:-$HOME/.pyenv}
export PYENV_ROOT=$pyenv_root
if [[ ! -d $PYENV_ROOT ]]; then
echo "Installing pyenv.."
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
fi

echo "Python setup..."
pyenv install -s "$PYENV_PYTHON_VERSION"
pyenv global "$PYENV_PYTHON_VERSION"
PYTHON=$(pyenv which python)
}

function setup_env_vars_py310 {
# This controls the python binary to use.
PYTHON=python3.10
PYTHON_STR=python3.10
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=10
# This is for pyenv install.
PYENV_PYTHON_VERSION=3.10.13
}

function update_bazel_macos {
BAZEL_VERSION=$1
ARCH="$(uname -m)"
curl -L https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-darwin-${ARCH}.sh -O
ls
chmod +x bazel-*.sh
./bazel-${BAZEL_VERSION}-installer-darwin-${ARCH}.sh --user
rm -f ./bazel-${BAZEL_VERSION}-installer-darwin-${ARCH}.sh
# Add new bazel installation to path
PATH="/Users/kbuilder/bin:$PATH"
}

function build_and_test_array_record_macos() {
SOURCE_DIR=$1
# Set up Bazel.
# Using a previous version of Bazel to avoid:
# https://github.com/bazelbuild/bazel/issues/8622
export BAZEL_VERSION="5.4.0"
update_bazel_macos ${BAZEL_VERSION}
bazel --version

# Set up Pyenv.
setup_env_vars_py310
install_and_init_pyenv

# Build and test ArrayRecord.
cd ${SOURCE_DIR}
bash ${SOURCE_DIR}/oss/build_whl.sh

ls ${SOURCE_DIR}/all_dist/*.whl
}

0 comments on commit fb97d67

Please sign in to comment.