[Python] VSCode devcontainer and UV

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developing using VSCode's devcontainer, and I used pip with a requirements.txt file for a few years with no problems. Works like charm. I'd like to upgrade to using uv, but I'm encountering a problem. My Dockerfile has the following lines:

    ADD https://astral.sh/uv/install.sh /install.sh
    RUN chmod -R 655 /install.sh && /install.sh && rm /install.sh
    ENV PATH="/root/.local/bin:$PATH"
    WORKDIR /app
    COPY ./pyproject.toml .
    RUN uv sync --dev


    These commands install all the modules under /app/.venv. However, when I open the container via VSCode, my working directory is /workspaces/, which is the mount directory, and I need to run uv sync --dev again, to install the modules under /workspaces/<project>/.venv.

    I guess it worked well with pip because there's no .venv there. So my question is: how can I avoid this duplication?

    Continue reading...

Compartilhe esta Página