Skip to content

Commit

Permalink
fix syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
navistonks committed May 31, 2024
1 parent 5706d75 commit f4fb142
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions tools/install_python_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ if [ "$(uname)" == "Darwin" ] && [ $SHELL == "/bin/bash" ]; then
RC_FILE="$HOME/.bash_profile"
fi

PYENV_INSTALLED = true
if ! command -v "pyenv" > /dev/null 2>&1; then
PYENV_INSTALLED = false
PYENV_INSTALLED="false"
POETRY_INSTALLED="false"

if ! command -v "pyenv" > /dev/null 2>&1; then
if ask "Install pyenv?"; then
echo "pyenv install ..."
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
PYENV_PATH_SETUP="export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH"

PYENV_INSTALLED = true
PYENV_INSTALLED="true"
fi
else
PYENV_INSTALLED="true"
fi

if $PYENV_INSTALLED && ([ -z "$PYENV_SHELL" ] || [ -n "$PYENV_PATH_SETUP" ]); then
if [[ "$PYENV_INSTALLED" == "true" ]] && ([ -z "$PYENV_SHELL" ] || [ -n "$PYENV_PATH_SETUP" ]); then
echo "pyenvrc setup ..."
cat <<EOF > "${HOME}/.pyenvrc"
if [ -z "\$PYENV_ROOT" ]; then
Expand All @@ -60,7 +61,7 @@ fi
export MAKEFLAGS="-j$(nproc)"

PYENV_PYTHON_VERSION=$(cat $ROOT/.python-version)
if PYENV_INSTALLED && (! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null); then
if [[ "$PYENV_INSTALLED" == "true" ]] && (! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null); then
# no pyenv update on mac
if [ "$(uname)" == "Linux" ]; then
if ask "Update pyenv?"; then
Expand All @@ -75,7 +76,7 @@ if PYENV_INSTALLED && (! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null); the
fi
fi

PYENV_INSTALLED && eval "$(pyenv init --path)"
[[ "$PYENV_INSTALLED" == "true" ]] && eval "$(pyenv init --path)"

if ask "Update pip?"; then
echo "update pip"
Expand All @@ -90,7 +91,7 @@ if ask "Install poetry?"; then

poetry self add poetry-dotenv-plugin@^0.1.0

POETRY_INSTALLED = true
POETRY_INSTALLED="true"
fi

echo "PYTHONPATH=${PWD}" > $ROOT/.env
Expand All @@ -99,14 +100,14 @@ if [[ "$(uname)" == 'Darwin' ]]; then
echo "export ZMQ=1" >> $ROOT/.env
echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> $ROOT/.env

if [[! POETRY_INSTALLED]]; then
if [[ "$POETRY_INSTALLED" == "false" ]]; then
echo "Before running any python files, load the environment variables by running this command:"
echo "source ~/.env"
fi
fi


if POETRY_INSTALLED && PYENV_INSTALLED; then
if [[ "$POETRY_INSTALLED" == "true" ]] && [[ "$PYENV_INSTALLED" == "true" ]]; then
if ask "Install openpilot python dependencies?"
echo "pip packages install..."
poetry install --no-cache --no-root
Expand All @@ -118,7 +119,7 @@ else
echo "pip install ."
fi

(! POETRY_INSTALLED || [ -n "$POETRY_VIRTUALENVS_CREATE" ]) && RUN="" || RUN="poetry run"
([[ "$POETRY_INSTALLED" == "false" ]] || [ -n "$POETRY_VIRTUALENVS_CREATE" ]) && RUN="" || RUN="poetry run"

if [ "$(uname)" != "Darwin" ] && [ -e "$ROOT/.git" ]; then
if ask "Install git pre-commit hooks?"; then
Expand All @@ -127,3 +128,11 @@ if [ "$(uname)" != "Darwin" ] && [ -e "$ROOT/.git" ]; then
$RUN git submodule foreach pre-commit install
fi
fi

echo "Setup done."
if [[ "$POETRY_INSTALLED" == "true" ]]; then
echo "Before building, activate the poetry environment with this command:"
echo "poetry shell"
else
echo "Before building, activate your python virtual environment."
fi

0 comments on commit f4fb142

Please sign in to comment.