hydrus/setup_venv.sh

261 lines
7.8 KiB
Bash
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
2023-09-20 19:58:17 +00:00
echo " r::::::::::::::::::::::::::::::::::r"
echo " : :"
echo " : :PP. :"
echo " : vBBr :"
echo " : 7BB: :"
echo " : rBB: :"
echo " : :DQRE: rBB: :gMBb: :"
echo " : :BBBi rBB: 7BBB. :"
echo " : KBB: rBB: rBBI :"
echo " : qBB: rBB: rQBU :"
echo " : qBB: rBB: iBBS :"
echo " : qBB: iBB: 7BBj :"
echo " : iBBY iBB. 2BB. :"
echo " : SBQq iBQ: EBBY :"
echo " : :MQBZMBBDRBBP. :"
echo " : .YBB7 :"
echo " : :BB. :"
echo " : 7BBi :"
echo " : rBB: :"
echo " : :"
echo " r::::::::::::::::::::::::::::::::::r"
echo
echo " hydrus"
echo
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
2023-09-20 19:58:17 +00:00
echo "No \"python3\" found, using \"python\"."
2023-08-09 21:12:17 +00:00
py_command=python
2022-11-16 21:34:30 +00:00
fi
if [ -d "venv" ]; then
2023-08-09 21:12:17 +00:00
echo "Virtual environment will be reinstalled. Hit Enter to start."
read -r
echo "Deleting old venv..."
rm -rf venv
else
2023-08-09 21:12:17 +00:00
echo "If you do not know what this is, check the 'running from source' help. Hit Enter to start."
read -r
fi
2024-02-21 21:09:02 +00:00
if [ -d "venv" ]; then
echo "It looks like the venv directory did not delete correctly. Do you have it activated in a terminal or IDE anywhere? Please close that and try this again!"
exit 1
fi
2023-09-20 19:58:17 +00:00
echo "--------"
echo "Users on older OSes or Python >=3.11 need the advanced install."
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
if [ "$install_type" = "s" ]; then
2023-08-09 21:12:17 +00:00
:
2023-04-12 20:34:43 +00:00
elif [ "$install_type" = "a" ]; then
2023-09-20 19:58:17 +00:00
echo "--------"
echo "We are now going to choose which versions of some larger libraries we are going to use. If something doesn't install, or hydrus won't boot, just run this script again and it will delete everything and start over."
2023-04-12 20:34:43 +00:00
echo
2023-09-20 19:58:17 +00:00
echo "Qt - User Interface"
echo "Most people want \"6\"."
2023-10-25 21:23:53 +00:00
echo "If you are <=Ubuntu 18.04 or equivalent, choose \"5\". If you want a specific version, choose \"a\"."
echo "Do you want Qt(5), Qt(6), or (a)dvanced? "
2023-04-12 20:34:43 +00:00
read -r qt
if [ "$qt" = "5" ]; then
:
elif [ "$qt" = "6" ]; then
:
2023-10-25 21:23:53 +00:00
elif [ "$qt" = "a" ]; then
2023-04-12 20:34:43 +00:00
:
else
echo "Sorry, did not understand that input!"
exit 1
fi
2023-10-25 21:23:53 +00:00
if [ "$qt" = "a" ]; then
echo
2024-05-01 21:13:34 +00:00
echo "If you cannot boot with the normal Qt6, try \"o\" on Python 3.9 or \"m\" on Python 3.10."
2023-10-25 21:23:53 +00:00
echo "Do you want Qt6 (o)lder, Qt6 (m)iddle, Qt6 (t)est, or (w)rite your own? "
read -r qt
if [ "$qt" = "o" ]; then
:
elif [ "$qt" = "m" ]; then
:
elif [ "$qt" = "t" ]; then
:
elif [ "$qt" = "w" ]; then
:
else
echo "Sorry, did not understand that input!"
exit 1
fi
fi
if [ "$qt" = "w" ]; then
echo
2024-05-01 21:13:34 +00:00
echo "Enter the exact PySide6 version you want, e.g. '6.6.0':"
echo "- For Python 3.10, your earliest available version is 6.2.0"
echo "- For Python 3.11, your earliest available version is 6.4.0.1"
echo "- For Python 3.12, your earliest available version is 6.6.0"
echo "Version: "
2023-10-25 21:23:53 +00:00
read -r qt_custom_pyside6
2024-05-01 21:13:34 +00:00
echo "Enter the exact qtpy version you want (probably '2.4.1'; if older try '2.3.1'): "
2023-10-25 21:23:53 +00:00
read -r qt_custom_qtpy
fi
2023-09-20 19:58:17 +00:00
echo "--------"
echo "mpv - audio and video playback"
2023-04-12 20:34:43 +00:00
echo
2023-09-20 19:58:17 +00:00
echo "We need to tell hydrus how to talk to your existing mpv install."
echo "Most people want \"n\"."
echo "If it doesn't work, fall back to \"o\"."
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
:
elif [ "$mpv" = "n" ]; then
:
2023-09-05 20:01:54 +00:00
elif [ "$mpv" = "t" ]; then
:
2023-04-12 20:34:43 +00:00
else
echo "Sorry, did not understand that input!"
popd || exit 1
exit 1
fi
2023-09-20 19:58:17 +00:00
echo "--------"
2024-10-02 19:44:01 +00:00
echo "OpenCV - Images"
2023-09-20 19:58:17 +00:00
echo
echo "Most people want \"n\"."
2024-10-02 19:44:01 +00:00
echo "Python >=3.11 might need \"t\"."
echo "Do you want (n)ew OpenCV or (t)est OpenCV? "
read -r opencv
if [ "$opencv" = "o" ]; then
:
elif [ "$opencv" = "n" ]; then
2023-09-20 19:58:17 +00:00
:
2024-10-02 19:44:01 +00:00
elif [ "$opencv" = "t" ]; then
2023-09-20 19:58:17 +00:00
:
else
echo "Sorry, did not understand that input!"
popd || exit 1
exit 1
fi
2024-10-02 19:44:01 +00:00
future=n
# comment this guy out if no special stuff going on
2024-10-09 02:28:06 +00:00
# echo "--------"
# echo "Future Libraries"
# echo
# echo "There is a test of new requests and setuptools. Want to try it?"
# echo "(y)es/(n)o? "
# read -r future
# if [ "$future" = "y" ]; then
# :
# elif [ "$future" = "n" ]; then
# :
# else
# echo "Sorry, did not understand that input!"
# popd || exit 1
# exit 1
# fi
else
2023-08-09 21:12:17 +00:00
echo "Sorry, did not understand that input!"
popd || exit 1
exit 1
fi
2023-09-20 19:58:17 +00:00
echo "--------"
echo "Creating new venv..."
2022-11-16 21:34:30 +00:00
$py_command -m venv venv
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-08-09 21:12:17 +00:00
popd || exit 1
exit 1
2022-11-16 21:34:30 +00:00
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
2023-10-25 21:23:53 +00:00
2023-08-09 21:12:17 +00:00
python -m pip install -r requirements.txt
2023-10-25 21:23:53 +00:00
2023-04-12 20:34:43 +00:00
elif [ "$install_type" = "a" ]; then
2023-10-25 21:23:53 +00:00
if [ "$qt" = "w" ]; then
2024-01-31 21:20:50 +00:00
python -m pip install qtpy=="$qt_custom_qtpy"
2023-10-25 21:23:53 +00:00
if [ $? -ne 0 ]; then
echo "It looks like we could not find that qtpy version!"
popd || exit 1
exit 1
fi
2024-01-31 21:20:50 +00:00
python -m pip install PySide6=="$qt_custom_pyside6"
2023-10-25 21:23:53 +00:00
if [ $? -ne 0 ]; then
echo "It looks like we could not find that PySide6 version!"
popd || exit 1
exit 1
fi
fi
2023-08-09 21:12:17 +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
python -m pip install -r static/requirements/advanced/requirements_qt5.txt
elif [ "$qt" = "6" ]; then
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
python -m pip install -r static/requirements/advanced/requirements_qt6_test.txt
fi
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
2023-04-12 20:34:43 +00:00
fi
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
2023-04-12 20:34:43 +00:00
fi
2024-10-02 19:44:01 +00:00
if [ "$future" = "n" ]; then
python -m pip install -r static/requirements/advanced/requirements_other_normal.txt
elif [ "$future" = "y" ]; then
python -m pip install -r static/requirements/advanced/requirements_other_future.txt
fi
fi
deactivate
2023-09-20 19:58:17 +00:00
echo "--------"
echo "Done!"
2022-11-23 21:01:41 +00:00
2023-04-12 20:34:43 +00:00
popd || exit