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:
|
|
|
|
# - NPCOMP_BUILD_DIR
|
|
|
|
|
|
|
|
portable_realpath() {
|
|
|
|
# Create the directory if needed so that the `cd` doesn't fail.
|
|
|
|
mkdir -p $1 && cd $1 && pwd
|
|
|
|
}
|
|
|
|
|
|
|
|
td="$(portable_realpath $(dirname $0)/..)"
|
|
|
|
build_dir="$(portable_realpath "${NPCOMP_BUILD_DIR:-$td/build}")"
|
|
|
|
python_packages_dir="$build_dir/python_packages"
|
|
|
|
|
|
|
|
write_env_file() {
|
|
|
|
echo "Updating $build_dir/.env file"
|
2021-09-17 06:18:17 +08:00
|
|
|
echo "PYTHONPATH=\"$(portable_realpath "$python_packages_dir/npcomp_core"):$(portable_realpath "$python_packages_dir/torch_mlir"):$(portable_realpath "$python_packages_dir/torch_mlir_dialects")\"" > "$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
|