Skip to content

Editable installs with pip and VS Code #12169

@hoechenberger

Description

@hoechenberger

Since we adopted PEP 660 by moving to pyproject.toml, I'm having trouble with Pylance (VS Code) when working with editable installs.

Usually I do:

pip install -e .

from the MNE-Python directory. I can then import mne, and Pylance will recognize the package and provide tab completion etc.

Since we adopted pyproject.toml, I had to install in non-editable mode to have Pylance recognize the package.

I started digging a little and found out it's a pain point for static type checkers (like Pylance) introduced through PEP 660.

The proposed solution is to run setuptools in "legacy" or "compat" mode. However, recent releases of pip don't support this anymore.

My current solution is using the new "strict" mode:

pip install --config-settings editable-mode=strict -e .

With that, everything works as expected, with the only limitation that newly created files don't show up in the editable install – one has to "re-install" in that case. But I can live with that.

We should probably document this behavior.

Another alternative is switching our build backend to Hatch, like Napari did recently to work around this issue. But this step seems to be a bit much.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions