-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editable installs with pip and VS Code #12169
Comments
Wait, I've been using editable installs and Visual Studio Code forever, and I haven't noticed any regressions recently. Can you give an example what's not working anymore? |
I've had this issue for months, it only occurs with new versions of setuptools and pip ❯ mamba create -c conda-forge -n mne-base-test mne-base ipykernel
❯ mamba activate mne-base-test
❯ mamba uninstall --force mne-base
❯ pip --version
pip 23.3.1 from /Users/richardhochenberger/mambaforge/envs/mne-base-test/lib/python3.12/site-packages/pip (python 3.12)
❯ pip install --quiet -e ~/Development/mne-python
❯ code foo.py Ensure VS Code is using the correct Python environment Add the following content to the file: # %%
import mne Save the file You will get red squiggly lines under
Close VS Code Run: ❯ pip install --quiet --config-settings editable-mode=strict -e ~/Development/mne-python Start VS Code: ❯ code foo.py Now Pylance doesn't complain about the missing import anymore.
|
I can confirm that this is indeed not working. However, as you suspected, it does work if your working directory is actually The solutions/workarounds you point out don't really sound convincing to me. Why do you need an editable install? If you have to re-install even in editable strict mode when adding new files, this seems a bit pointless (meaning you might as well install in non-editable mode and re-install every time you make a change). What exactly is your use case? I'm fine with documenting this special case, but as we've mentioned previously, this does not affect you when you're developing MNE-Python, so I'm not even sure where we should document it. |
Normally I edit existing files only; I don't add new ones. Changes to files that existed by the time the "strict" editable install was performed will be reflected when importing the package. Only newly-created files don't show up.
For example, when I'm developing MNE-BIDS-Pipeline and want to improve I had a similar issue recently when developing MNE-BIDS. |
It actually should be fairly simple to try this out: napari/npe2#280 (comment) / https://github.com/napari/npe2/pull/282/files @hoechenberger can you see if that minimal change to One thing we'd need to watch out for is whether we can still get |
A bit more info is also available here: https://learn.scientific-python.org/development/guides/packaging-simple/ |
Just a note to self, I just ran into the same issue when trying to use an editable install of MNE-BIDS. With ❯ pip install --quiet --config-settings editable-mode=strict -e ../autoreject
DEPRECATION: Config settings are ignored for project file:///Users/richardhochenberger/Library/CloudStorage/OneDrive-FirmenichSA/Documents/Development/autoreject. pip 24.0 will enforce this behaviour change. A possible replacement is to use --use-pep517 or add a pyproject.toml file to the project. cc @sappelhoff |
I'd be interested in what adopting |
@cbrnr The nice thing about Lines 45 to 47 in fcb5926
This will be installed automatically before the build process starts. Users don't have to worry about this. |
But what is "the build process"? |
The package is first built, then installed, when you run |
So it's the process of building a wheel, more or less, right? Which means that this change does not affect |
Looks like that won't be a problem... from the scientific-python page that @cbrnr linked to:
|
Yes |
Maintainer of Hatch/Hatchling here! Let me know if I can be of assistance 🙂 |
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 ofpip
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.
The text was updated successfully, but these errors were encountered: