From 7c5063ef608f62ff381ef5cbfdfb59023d83030e Mon Sep 17 00:00:00 2001 From: Ivaylo Bratoev Date: Thu, 25 Apr 2024 03:33:25 +0300 Subject: [PATCH] infra: fix how Poetry is installed in the dev container (#20521) Currently, when a new dev container is created, poetry does not work in it with the error "No module named 'rapidfuzz'". Install Poetry outside the project venv so that poetry and project dependencies do not get mixed. Use pipx to install poetry securely in its own isolated environment. Issue: #12237 Twitter handle: https://twitter.com/ibratoev Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> --- libs/langchain/dev.Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/langchain/dev.Dockerfile b/libs/langchain/dev.Dockerfile index 3cef968e31..78a3779775 100644 --- a/libs/langchain/dev.Dockerfile +++ b/libs/langchain/dev.Dockerfile @@ -14,10 +14,14 @@ ARG PYTHON_VIRTUALENV_HOME=/home/vscode/langchain-py-env \ ENV POETRY_VIRTUALENVS_IN_PROJECT=false \ POETRY_NO_INTERACTION=true -# Create a Python virtual environment for Poetry and install it +# Install Poetry outside of the v`irtual environment to avoid conflicts +RUN python3 -m pip install --user pipx && \ + python3 -m pipx ensurepath && \ + pipx install poetry==${POETRY_VERSION} + +# Create a Python virtual environment for the project RUN python3 -m venv ${PYTHON_VIRTUALENV_HOME} && \ - $PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip && \ - $PYTHON_VIRTUALENV_HOME/bin/pip install poetry==${POETRY_VERSION} + $PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip ENV PATH="$PYTHON_VIRTUALENV_HOME/bin:$PATH" \ VIRTUAL_ENV=$PYTHON_VIRTUALENV_HOME