Remove pyenv (#32786)

* no pyenv

* better

* check poetry

* docker

* syntax

* manual env

* pre-commit

* revert

* format
old-commit-hash: de75372880
testing-closet^2
Maxime Desroches 10 months ago committed by GitHub
parent 99a7c5de93
commit 4558fbd824
  1. 16
      Dockerfile.openpilot_base
  2. 60
      tools/install_python_dependencies.sh
  3. 2
      tools/install_ubuntu_dependencies.sh

@ -68,20 +68,18 @@ RUN usermod -aG sudo $USER
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER $USER 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 pyproject.toml poetry.lock /tmp/
COPY --chown=$USER tools/install_python_dependencies.sh /tmp/tools/ 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 && \ tools/install_python_dependencies.sh && \
rm -rf /tmp/* && \ rm -rf /tmp/* && \
rm -rf /home/$USER/.cache && \ 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
USER root USER root
RUN sudo git config --global --add safe.directory /tmp/openpilot 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" RC_FILE="$HOME/.bash_profile"
fi fi
if ! command -v "pyenv" > /dev/null 2>&1; then if ! command -v "poetry" > /dev/null 2>&1; then
echo "pyenv install ..." echo "installing poetry..."
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash curl -sSL https://install.python-poetry.org | python3 -
PYENV_PATH_SETUP="export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$HOME/.pyenv/versions/${PYENV_PYTHON_VERSION}/bin:\$PATH" 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 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.prefer-active-python true --local
poetry config virtualenvs.in-project true --local poetry config virtualenvs.in-project true --local
@ -77,9 +34,8 @@ fi
poetry self add poetry-dotenv-plugin@^0.1.0 poetry self add poetry-dotenv-plugin@^0.1.0
echo "pip packages install..." echo "installing python packages..."
poetry install --no-cache --no-root poetry install --no-cache --no-root
pyenv rehash
[ -n "$POETRY_VIRTUALENVS_CREATE" ] && RUN="" || RUN="poetry run" [ -n "$POETRY_VIRTUALENVS_CREATE" ] && RUN="" || RUN="poetry run"

@ -94,7 +94,7 @@ function install_ubuntu_lts_latest_requirements() {
qt5-qmake \ qt5-qmake \
qtbase5-dev-tools \ qtbase5-dev-tools \
python3-dev \ python3-dev \
tk-dev python3-venv
} }
# Install Ubuntu 20.04 packages # Install Ubuntu 20.04 packages

Loading…
Cancel
Save