Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check python version compatibility in install script #177

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion syftbox/server/templates/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ downloader() {
fi
}

get_python_command() {
# check if either python3 or python is available
# and return the python command

if check_cmd python3; then
echo "python3"
elif check_cmd python; then
echo "python"
else
err "need 'python' or 'python3' (command not found)"
fi
}


need_python() {
# check if either python3 or python is available
if ! check_cmd python && ! check_cmd python3
Expand Down Expand Up @@ -116,13 +130,38 @@ install_syftbox() {
fi
}


check_python_version() {
# Try python3, if it exists; otherwise, fall back to python
python_command=$(get_python_command)

# Check if python_command is empty (meaning no python was found)
if [ -z "$python_command" ]; then
return 1
fi
yashgorana marked this conversation as resolved.
Show resolved Hide resolved

# Check if the python version is >= 3.10
pyver_check=$($python_command -c "import sys; print((sys.version_info[:2] >= (3, 10)))")

# Check if Python version not is greater than or equal to 3.10
if [ "$pyver_check" = "False" ]; then
err "Minimum python version is 3.10. Found: $($python_command -V)"
fi

}


pre_install() {
# ----- pre-install checks ----
# uv doesn't really need python,
# ... but incase we want we can toggle this on
# need_python
# need_python

# check if python version is >= 3.10
check_python_version

# if you see this message, you're good to go

echo "
____ __ _ ____
/ ___| _ _ / _| |_| __ ) _____ __
Expand Down