mirror of
https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-06-05 01:10:22 +08:00
refactor(scripts): simplify run.sh script (#48)
* refactor(scripts): simplify run.sh script a lot of the contents of run.sh is either wrong, unnecessary, or both! a program runner-script that installs software on your PC is a terrible idea, since users themselves should make such decisions, not some random installer/runner scripts from a github repo. the overfixation on python3.8 makes this script practically entirely useless on any linux system that isn't based on debian, or is based on debian but is heavily modified. on archlinux this script is useless, it wont install anything for you and it wont find python3.8 since there's no such thing as python3.8 ANYWHERE except for a few distros where older versions of software are not stored in an archive, but rather in the packages repo * refactor(scripts): apply a lot more of refactoring of run script * fix(scripts): remove env variable setting for macOS systems use --pycmd python instead of --pycmd python3
This commit is contained in:
58
run.sh
58
run.sh
@@ -1,51 +1,27 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
set -fa
|
||||||
# macOS specific env:
|
|
||||||
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
# Check if Python is installed
|
||||||
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
|
if ! command -v python; then
|
||||||
|
echo "Python not found. Please install Python using your package manager or via PyEnv."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d ".venv" ]; then
|
requirements_file="requirements/main.txt"
|
||||||
echo "Activate venv..."
|
venv_path=".venv"
|
||||||
. .venv/bin/activate
|
|
||||||
else
|
|
||||||
echo "Create venv..."
|
|
||||||
requirements_file="requirements/main.txt"
|
|
||||||
|
|
||||||
# Check if Python 3.8 is installed
|
if [[ ! -d "${venv_path}" ]]; then
|
||||||
if ! (command -v python3.8 >/dev/null 2>&1 || pyenv versions --bare | grep -q "3.8"); then
|
echo "Creating venv..."
|
||||||
echo "Python 3 not found. Attempting to install 3.8..."
|
|
||||||
if [ "$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
|
|
||||||
brew install python@3.8
|
|
||||||
elif [ "$(uname)" = "Linux" ] && command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y python3.8
|
|
||||||
else
|
|
||||||
echo "Please install Python 3.8 manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
python3.8 -m venv .venv
|
python -m venv "${venv_path}"
|
||||||
. .venv/bin/activate
|
source "${venv_path}/bin/activate"
|
||||||
|
|
||||||
# Check if required packages are installed and install them if not
|
# Check if required packages are up-to-date
|
||||||
if [ -f "${requirements_file}" ]; then
|
pip install --upgrade -r "${requirements_file}"
|
||||||
installed_packages=$(python3.8 -m pip freeze)
|
|
||||||
while IFS= read -r package; do
|
|
||||||
expr "${package}" : "^#.*" > /dev/null && continue
|
|
||||||
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
|
|
||||||
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
|
|
||||||
echo "${package_name} not found. Attempting to install..."
|
|
||||||
python3.8 -m pip install --upgrade "${package}"
|
|
||||||
fi
|
|
||||||
done < "${requirements_file}"
|
|
||||||
else
|
|
||||||
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
echo "Activating venv..."
|
||||||
|
source "${venv_path}/bin/activate"
|
||||||
|
|
||||||
# Run the main script
|
# Run the main script
|
||||||
python3 web.py --pycmd python3
|
python web.py --pycmd python
|
||||||
|
|||||||
Reference in New Issue
Block a user