• sugar_in_your_tea
    link
    fedilink
    arrow-up
    3
    ·
    4 days ago

    Anyone have a good solution for projects with multiple sub-projects? My structure is like this:

    • root - no venv
      • project_a
        • .venv
        • app/
      • project_b
        • .venv
        • app/

    To get completions to work, I need to manually switch venvs since each uses imports like app.a.b.c. But I frequently work on multiple projects at the same time, so I’d like it to switch venvs based on where the file lives.

    Anyone know if that’s possible? I’m probably missing something obvious since this seems like a fairly common thing.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      4 days ago

      Multi-root workspaces will let you choose the interpreter for each directory;

      I think that’s the best way to make it work if you want to have more than one project in the same VS Code instance.

      • sugar_in_your_tea
        link
        fedilink
        arrow-up
        1
        ·
        3 days ago

        I use poetry and that manages my venvs. I just want VSCode to select the right one based on where the file is.

    • nutcase2690@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      1
      ·
      4 days ago

      I can’t say that I’ve tried this for python, but have you looked into multi-root workspaces? That is how my current C++ and cmake setup performs, so Python might have something similar.

      • sugar_in_your_tea
        link
        fedilink
        arrow-up
        1
        ·
        4 days ago

        I’ll check it out, thanks for the tip. I don’t know much about VSCode, I’m more of a vim person, but I’ve been using it more and more at work.