2021-07-29 00:52:13 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# generate the .env file with default options.
|
|
|
|
#
|
|
|
|
# For arbitrary build/install directories, set the env variables:
|
2021-09-28 02:36:44 +08:00
|
|
|
# - TORCH_MLIR_BUILD_DIR
|
2021-07-29 00:52:13 +08:00
|
|
|
|
2022-07-07 05:39:30 +08:00
|
|
|
set -eu -o pipefail
|
|
|
|
|
2021-07-29 00:52:13 +08:00
|
|
|
portable_realpath() {
|
|
|
|
# Create the directory if needed so that the `cd` doesn't fail.
|
2022-07-07 05:39:30 +08:00
|
|
|
mkdir -p "$1" && cd "$1" && pwd
|
2021-07-29 00:52:13 +08:00
|
|
|
}
|
|
|
|
|
2022-07-07 05:39:30 +08:00
|
|
|
td="$(portable_realpath "$(dirname "$0")"/..)"
|
2021-09-28 02:36:44 +08:00
|
|
|
build_dir="$(portable_realpath "${TORCH_MLIR_BUILD_DIR:-$td/build}")"
|
2023-12-02 06:29:37 +08:00
|
|
|
python_packages_dir="$build_dir/python_packages"
|
2021-07-29 00:52:13 +08:00
|
|
|
|
|
|
|
write_env_file() {
|
|
|
|
echo "Updating $build_dir/.env file"
|
2021-09-28 02:36:44 +08:00
|
|
|
echo "PYTHONPATH=\"$(portable_realpath "$python_packages_dir/torch_mlir")\"" > "$build_dir/.env"
|
2021-07-29 00:52:13 +08:00
|
|
|
if ! cp "$build_dir/.env" "$td/.env"; then
|
|
|
|
echo "WARNING: Failed to write $td/.env"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
write_env_file
|