-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_paths.sh
executable file
·48 lines (39 loc) · 1.56 KB
/
setup_paths.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
#!/bin/bash
# Detect the path to NVFlare binary
NVFLARE_PATH=$(which nvflare)
# Check if NVFlare is installed
if [ -z "$NVFLARE_PATH" ]; then
echo "Error: nvflare is not installed or not found in the system PATH."
exit 1
fi
# Automatically detect the path of the MeshDist_nvflare repo's app/code folder
REPO_ROOT=$(pwd)
PYTHONPATH_TO_ADD="$REPO_ROOT/app/code/"
# Detect the right shell configuration file
if [ -f ~/.bashrc ]; then
SHELL_CONFIG_FILE=~/.bashrc
elif [ -f ~/.bash_profile ]; then
SHELL_CONFIG_FILE=~/.bash_profile
elif [ -f ~/.zshrc ]; then
SHELL_CONFIG_FILE=~/.zshrc
else
echo "Error: Could not find .bashrc, .bash_profile, or .zshrc. Please manually configure your shell environment."
exit 1
fi
# Add NVFlare PATH to the detected shell configuration file if it's not already there
if grep -q "$NVFLARE_PATH" "$SHELL_CONFIG_FILE"; then
echo "NVFlare PATH already added to $SHELL_CONFIG_FILE."
else
echo "Adding NVFlare PATH to $SHELL_CONFIG_FILE..."
echo "export PATH=$(dirname $NVFLARE_PATH):\$PATH" >> "$SHELL_CONFIG_FILE"
fi
# Add PYTHONPATH to the detected shell configuration file if it's not already there
if grep -q "$PYTHONPATH_TO_ADD" "$SHELL_CONFIG_FILE"; then
echo "PYTHONPATH already added to $SHELL_CONFIG_FILE."
else
echo "Adding PYTHONPATH to $SHELL_CONFIG_FILE..."
echo "export PYTHONPATH=\$PYTHONPATH:$PYTHONPATH_TO_ADD" >> "$SHELL_CONFIG_FILE"
fi
# Apply the changes immediately in the current session
source "$SHELL_CONFIG_FILE"
echo "Environment setup complete. Changes applied to $SHELL_CONFIG_FILE."