Skip to content

Commit f79b925

Browse files
authored
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
1 parent 1e94e00 commit f79b925

File tree

1 file changed

+17
-41
lines changed

1 file changed

+17
-41
lines changed

run.sh

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,27 @@
11
#!/bin/sh
22

3-
if [ "$(uname)" = "Darwin" ]; then
4-
# macOS specific env:
5-
export PYTORCH_ENABLE_MPS_FALLBACK=1
6-
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
3+
set -fa
4+
5+
# Check if Python is installed
6+
if ! command -v python; then
7+
echo "Python not found. Please install Python using your package manager or via PyEnv."
8+
exit 1
79
fi
810

9-
if [ -d ".venv" ]; then
10-
echo "Activate venv..."
11-
. .venv/bin/activate
12-
else
13-
echo "Create venv..."
14-
requirements_file="requirements/main.txt"
11+
requirements_file="requirements/main.txt"
12+
venv_path=".venv"
1513

16-
# Check if Python 3.8 is installed
17-
if ! (command -v python3.8 >/dev/null 2>&1 || pyenv versions --bare | grep -q "3.8"); then
18-
echo "Python 3 not found. Attempting to install 3.8..."
19-
if [ "$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
20-
brew install [email protected]
21-
elif [ "$(uname)" = "Linux" ] && command -v apt-get >/dev/null 2>&1; then
22-
sudo apt update
23-
sudo apt install -y python3.8
24-
else
25-
echo "Please install Python 3.8 manually."
26-
exit 1
27-
fi
28-
fi
14+
if [[ ! -d "${venv_path}" ]]; then
15+
echo "Creating venv..."
2916

30-
python3.8 -m venv .venv
31-
. .venv/bin/activate
17+
python -m venv "${venv_path}"
18+
source "${venv_path}/bin/activate"
3219

33-
# Check if required packages are installed and install them if not
34-
if [ -f "${requirements_file}" ]; then
35-
installed_packages=$(python3.8 -m pip freeze)
36-
while IFS= read -r package; do
37-
expr "${package}" : "^#.*" > /dev/null && continue
38-
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
39-
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
40-
echo "${package_name} not found. Attempting to install..."
41-
python3.8 -m pip install --upgrade "${package}"
42-
fi
43-
done < "${requirements_file}"
44-
else
45-
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
46-
exit 1
47-
fi
20+
# Check if required packages are up-to-date
21+
pip install --upgrade -r "${requirements_file}"
4822
fi
23+
echo "Activating venv..."
24+
source "${venv_path}/bin/activate"
4925

5026
# Run the main script
51-
python3 web.py --pycmd python3
27+
python web.py --pycmd python

0 commit comments

Comments
 (0)