mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 01:53:57 +08:00
Revert no pyenv (#32547)
* Revert "`ubuntu_setup`: fix `No module apt_pkg` error when setting up (#32526)"
This reverts commit d850f07acb58e4fc6d530241a31c0917c2b6613e.
* Revert "Removal of pyenv (#32512)"
This reverts commit 41f72d5ca75aab9a9beb3181aca9f177e5a003f8.
old-commit-hash: 1eb938b8e8
This commit is contained in:
@@ -10,18 +10,50 @@ if [ "$(uname)" == "Darwin" ] && [ $SHELL == "/bin/bash" ]; then
|
||||
RC_FILE="$HOME/.bash_profile"
|
||||
fi
|
||||
|
||||
if ! command -v "pyenv" > /dev/null 2>&1; 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"
|
||||
fi
|
||||
|
||||
if [ -z "$PYENV_SHELL" ] || [ -n "$PYENV_PATH_SETUP" ]; then
|
||||
echo "pyenvrc setup ..."
|
||||
cat <<EOF > "${HOME}/.pyenvrc"
|
||||
if [ -z "\$PYENV_ROOT" ]; then
|
||||
$PYENV_PATH_SETUP
|
||||
export PYENV_ROOT="\$HOME/.pyenv"
|
||||
eval "\$(pyenv init -)"
|
||||
eval "\$(pyenv virtualenv-init -)"
|
||||
fi
|
||||
EOF
|
||||
|
||||
SOURCE_PYENVRC="source ~/.pyenvrc"
|
||||
if ! grep "^$SOURCE_PYENVRC$" $RC_FILE > /dev/null; then
|
||||
printf "\n$SOURCE_PYENVRC\n" >> $RC_FILE
|
||||
fi
|
||||
|
||||
eval "$SOURCE_PYENVRC"
|
||||
# $(pyenv init -) produces a function which is broken on bash 3.2 which ships on macOS
|
||||
if [ $(uname) == "Darwin" ]; then
|
||||
unset -f pyenv
|
||||
fi
|
||||
fi
|
||||
|
||||
export MAKEFLAGS="-j$(nproc)"
|
||||
|
||||
|
||||
PYENV_PYTHON_VERSION=$(cat $ROOT/.python-version)
|
||||
if ! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null; then
|
||||
# no pyenv update on mac
|
||||
if [ "$(uname)" == "Linux" ]; then
|
||||
echo "pyenv update ..."
|
||||
pyenv update
|
||||
fi
|
||||
echo "python ${PYENV_PYTHON_VERSION} install ..."
|
||||
CONFIGURE_OPTS="--enable-shared" pyenv install -f ${PYENV_PYTHON_VERSION}
|
||||
fi
|
||||
eval "$(pyenv init --path)"
|
||||
|
||||
echo "update pip"
|
||||
if [ ! -z "$VIRTUAL_ENV_ROOT" ] || [ ! -z "$INSTALL_DEADSNAKES_PPA" ] ; then
|
||||
if [ -z "$VIRTUAL_ENV_ROOT" ]; then
|
||||
export VIRTUAL_ENV_ROOT="venv"
|
||||
fi
|
||||
python3 -m venv --system-site-packages $VIRTUAL_ENV_ROOT
|
||||
source $VIRTUAL_ENV_ROOT/bin/activate
|
||||
fi
|
||||
pip install pip==24.0
|
||||
pip install poetry==1.7.0
|
||||
|
||||
@@ -39,6 +71,7 @@ poetry self add poetry-dotenv-plugin@^0.1.0
|
||||
|
||||
echo "pip packages install..."
|
||||
poetry install --no-cache --no-root
|
||||
pyenv rehash
|
||||
|
||||
[ -n "$POETRY_VIRTUALENVS_CREATE" ] && RUN="" || RUN="poetry run"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user