hydrus/setup_venv.command

150 lines
3.9 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2023-04-12 20:34:43 +00:00
pushd "$(dirname "$0")" || exit 1
2022-11-23 21:01:41 +00:00
2022-11-16 21:34:30 +00:00
py_command=python3
2023-04-12 20:34:43 +00:00
if ! type -P $py_command >/dev/null 2>&1; then
2022-11-16 21:34:30 +00:00
echo "No python3 found, using python."
py_command=python
fi
if [ -d "venv" ]; then
echo "Virtual environment will be reinstalled. Hit Enter to start."
2023-04-12 20:34:43 +00:00
read -r
echo "Deleting old venv..."
rm -rf venv
else
echo "If you do not know what this is, check the 'running from source' help. Hit Enter to start."
2023-04-12 20:34:43 +00:00
read -r
fi
2023-08-16 20:46:51 +00:00
echo "If your macOS is slightly old, do the advanced install. Let hydev know what works for you."
echo
echo "Your Python version is:"
2022-11-16 21:34:30 +00:00
$py_command --version
echo
echo "Do you want the (s)imple or (a)dvanced install? "
2023-04-12 20:34:43 +00:00
read -r install_type
2023-04-12 20:34:43 +00:00
if [ "$install_type" = "s" ]; then
:
2023-04-12 20:34:43 +00:00
elif [ "$install_type" = "a" ]; then
echo
2023-08-16 20:46:51 +00:00
echo "Qt is the User Interface library. We are now on Qt6."
2023-09-05 20:01:54 +00:00
echo "If you are <= 10.13 (High Sierra), choose 5."
echo "If you are <=10.15 (Catalina) or otherwise have trouble with the normal Qt6, try the (o)lder build on Python ^<=3.10 or (m)iddle on Python ^>=3.11."
echo "Do you want Qt(5), Qt(6), Qt6 (o)lder, Qt6 (m)iddle or (t)est? "
2023-04-12 20:34:43 +00:00
read -r qt
if [ "$qt" = "5" ]; then
:
2023-04-12 20:34:43 +00:00
elif [ "$qt" = "6" ]; then
:
2023-08-09 21:12:17 +00:00
elif [ "$qt" = "o" ]; then
:
2023-09-05 20:01:54 +00:00
elif [ "$qt" = "m" ]; then
:
2023-04-12 20:34:43 +00:00
elif [ "$qt" = "t" ]; then
2022-12-07 22:41:53 +00:00
:
else
echo "Sorry, did not understand that input!"
2023-04-12 20:34:43 +00:00
popd || exit 1
exit 1
fi
echo
echo "mpv is broken on macOS. As a safe default, choose n."
2023-09-05 20:01:54 +00:00
echo "Do you want (o)ld mpv, (n)ew mpv, or (t)est mpv? "
2023-04-12 20:34:43 +00:00
read -r mpv
if [ "$mpv" = "o" ]; then
:
2023-04-12 20:34:43 +00:00
elif [ "$mpv" = "n" ]; then
:
2023-09-05 20:01:54 +00:00
elif [ "$mpv" = "t" ]; then
:
else
echo "Sorry, did not understand that input!"
2023-04-12 20:34:43 +00:00
popd || exit 1
exit 1
fi
echo
2023-08-16 20:46:51 +00:00
echo "OpenCV is the main image processing library."
echo "Try the n first. If it doesn't work, fall back to o. Very new python versions might need t."
echo "Do you want (o)ld OpenCV, (n)ew OpenCV, or (t)est OpenCV? "
2023-04-12 20:34:43 +00:00
read -r opencv
if [ "$opencv" = "o" ]; then
:
2023-04-12 20:34:43 +00:00
elif [ "$opencv" = "n" ]; then
:
elif [ "$opencv" = "t" ]; then
:
else
echo "Sorry, did not understand that input!"
2023-04-12 20:34:43 +00:00
popd || exit 1
exit 1
fi
else
echo "Sorry, did not understand that input!"
2023-04-12 20:34:43 +00:00
popd || exit 1
exit 1
fi
echo "Creating new venv..."
2022-11-16 21:34:30 +00:00
$py_command -m venv venv
source venv/bin/activate
2023-04-12 20:34:43 +00:00
if ! source venv/bin/activate; then
2022-11-16 21:34:30 +00:00
echo "The venv failed to activate, stopping now!"
2023-04-12 20:34:43 +00:00
popd || exit 1
2022-11-16 21:34:30 +00:00
exit 1
fi
python -m pip install --upgrade pip
2022-11-16 21:34:30 +00:00
python -m pip install --upgrade wheel
2023-04-12 20:34:43 +00:00
if [ "$install_type" = "s" ]; then
2022-11-16 21:34:30 +00:00
python -m pip install -r requirements.txt
2023-04-12 20:34:43 +00:00
elif [ "$install_type" = "a" ]; then
2022-11-16 21:34:30 +00:00
python -m pip install -r static/requirements/advanced/requirements_core.txt
2023-04-12 20:34:43 +00:00
if [ "$qt" = "5" ]; then
2022-11-16 21:34:30 +00:00
python -m pip install -r static/requirements/advanced/requirements_qt5.txt
2023-04-12 20:34:43 +00:00
elif [ "$qt" = "6" ]; then
2022-11-16 21:34:30 +00:00
python -m pip install -r static/requirements/advanced/requirements_qt6.txt
2023-08-09 21:12:17 +00:00
elif [ "$qt" = "o" ]; then
python -m pip install -r static/requirements/advanced/requirements_qt6_older.txt
2023-09-05 20:01:54 +00:00
elif [ "$qt" = "m" ]; then
python -m pip install -r static/requirements/advanced/requirements_qt6_middle.txt
2023-04-12 20:34:43 +00:00
elif [ "$qt" = "t" ]; then
2022-12-07 22:41:53 +00:00
python -m pip install -r static/requirements/advanced/requirements_qt6_test.txt
fi
2023-04-12 20:34:43 +00:00
if [ "$mpv" = "o" ]; then
python -m pip install -r static/requirements/advanced/requirements_mpv_old.txt
2023-04-12 20:34:43 +00:00
elif [ "$mpv" = "n" ]; then
python -m pip install -r static/requirements/advanced/requirements_mpv_new.txt
2023-09-05 20:01:54 +00:00
elif [ "$mpv" = "t" ]; then
python -m pip install -r static/requirements/advanced/requirements_mpv_test.txt
fi
2023-04-12 20:34:43 +00:00
if [ "$opencv" = "o" ]; then
python -m pip install -r static/requirements/advanced/requirements_opencv_old.txt
2023-04-12 20:34:43 +00:00
elif [ "$opencv" = "n" ]; then
python -m pip install -r static/requirements/advanced/requirements_opencv_new.txt
elif [ "$opencv" = "t" ]; then
python -m pip install -r static/requirements/advanced/requirements_opencv_test.txt
fi
fi
deactivate
echo "Done!"
2023-04-12 20:34:43 +00:00
read -r
2022-11-23 21:01:41 +00:00
2023-04-12 20:34:43 +00:00
popd || exit