Skip to content

Monorepo: allow a way to configure cwd based on pyproject.toml or ini file location #259

@tamird

Description

@tamird

The instructions added in aee3832 don't work in the presence of additional directories. Consider:

- libA
  - pyproject.toml
  - subDirA
    - myfile.py
- libB
  - pyproject.toml

when running on myfile.py I want the cwd to be libA, not subDirA. I think the correct value should be ${fileWorkspaceFolder} but this produces a crash before and after this patch.

It would also be good to log something better when this crash happens. Right now you just get

2024-01-24 10:04:59.330 [info] Server: Start requested.
2024-01-24 10:04:59.330 [info] [Error - 10:04:59 AM] Mypy Type Checker client: couldn't create connection to server.
2024-01-24 10:04:59.331 [info] Launching server using command python_monorepo/common/.venv/bin/python failed. Error: spawn python_monorepo/common/.venv/bin/python ENOENT
2024-01-24 10:04:59.331 [error] Server: Start failed: Launching server using command python_monorepo/common/.venv/bin/python failed. Error: spawn python_monorepo/common/.venv/bin/python ENOENT

This is a common thing when using multiple virtual environments as suggested in https://github.com/microsoft/vscode-python/wiki/Mono-Repo-Set%E2%80%90up-Guide#scenario-2-separate-virtual-environments. I think what we want is ${fileWorkspaceFolder} or ${workspaceFolder} -- I'm not sure because the docs are confusing. But we want the workspace folder to which the currently open file belongs.

https://code.visualstudio.com/docs/editor/variables-reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions