mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 14:13:53 +08:00
Remove pyenv (#32786)
* no pyenv
* better
* check poetry
* docker
* syntax
* manual env
* pre-commit
* revert
* format
old-commit-hash: de75372880
This commit is contained in:
@@ -68,20 +68,18 @@ RUN usermod -aG sudo $USER
|
||||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
USER $USER
|
||||
|
||||
ENV POETRY_VIRTUALENVS_CREATE=false
|
||||
ENV PYENV_VERSION=3.12.4
|
||||
ENV PYENV_ROOT="/home/$USER/pyenv"
|
||||
ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
|
||||
|
||||
COPY --chown=$USER pyproject.toml poetry.lock /tmp/
|
||||
COPY --chown=$USER tools/install_python_dependencies.sh /tmp/tools/
|
||||
|
||||
RUN cd /tmp && \
|
||||
ENV POETRY_VIRTUALENVS_CREATE=false
|
||||
ENV VIRTUAL_ENV=/home/$USER/venv/.venv
|
||||
RUN python3 -m venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
RUN . $VIRTUAL_ENV/bin/activate && \
|
||||
cd /tmp && \
|
||||
tools/install_python_dependencies.sh && \
|
||||
rm -rf /tmp/* && \
|
||||
rm -rf /home/$USER/.cache && \
|
||||
find /home/$USER/pyenv -type d -name ".git" | xargs rm -rf && \
|
||||
rm -rf /home/$USER/pyenv/versions/3.12.4/lib/python3.12/test
|
||||
rm -rf /home/$USER/.cache
|
||||
|
||||
USER root
|
||||
RUN sudo git config --global --add safe.directory /tmp/openpilot
|
||||
|
||||
@@ -13,58 +13,15 @@ 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:\$HOME/.pyenv/versions/${PYENV_PYTHON_VERSION}/bin:\$PATH"
|
||||
if ! command -v "poetry" > /dev/null 2>&1; then
|
||||
echo "installing poetry..."
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
POETRY_BIN='$HOME/.local/bin'
|
||||
ADD_PATH_CMD="export PATH=\"$POETRY_BIN:\$PATH\""
|
||||
eval $ADD_PATH_CMD
|
||||
printf "\n#poetry path\n$ADD_PATH_CMD\n" >> $RC_FILE
|
||||
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="3.12.4"
|
||||
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)"
|
||||
eval "$(pyenv init -)"
|
||||
eval "$(pyenv virtualenv-init -)"
|
||||
pyenv local ${PYENV_PYTHON_VERSION}
|
||||
pyenv rehash
|
||||
|
||||
echo "update pip"
|
||||
pip install pip==24.0
|
||||
pip install poetry==1.7.0
|
||||
|
||||
poetry config virtualenvs.prefer-active-python true --local
|
||||
poetry config virtualenvs.in-project true --local
|
||||
|
||||
@@ -77,9 +34,8 @@ fi
|
||||
|
||||
poetry self add poetry-dotenv-plugin@^0.1.0
|
||||
|
||||
echo "pip packages install..."
|
||||
echo "installing python packages..."
|
||||
poetry install --no-cache --no-root
|
||||
pyenv rehash
|
||||
|
||||
[ -n "$POETRY_VIRTUALENVS_CREATE" ] && RUN="" || RUN="poetry run"
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ function install_ubuntu_lts_latest_requirements() {
|
||||
qt5-qmake \
|
||||
qtbase5-dev-tools \
|
||||
python3-dev \
|
||||
tk-dev
|
||||
python3-venv
|
||||
}
|
||||
|
||||
# Install Ubuntu 20.04 packages
|
||||
|
||||
Reference in New Issue
Block a user