You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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?
Now Pylance doesn't complain about the missing import anymore.
Can only be replicated if using new (the latest?) versions of setuptools and pip
When trying to replicate, ensure that you're not inside the mne-python directory, as Pylance may pick up the nested mne directory there (I'm not 100% sure about this but it's better to exclude this possibility) -> May explain why this problem is not an issue when developing MNE-Python itself; but I often want to use the devel version from an editable install in other projects, where I then run into this limitation
I can confirm that this is indeed not working. However, as you suspected, it does work if your working directory is actually mne-python (i.e. the base directory of the editable install). So for developing MNE-Python, the editable install works as expected.
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.
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).
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.
What exactly is your use case?
For example, when I'm developing MNE-BIDS-Pipeline and want to improve mne.Report, I have my workspace / environment with MNE-BIDS-Pipeline open in VS code, and an editable install of MNE-Python into that environment, such that every time I change something on my MNE-Python development branch, the Pipeline will pick it up upon a re-run.
I had a similar issue recently when developing MNE-BIDS.
Just a note to self, I just ran into the same issue when trying to use an editable install of MNE-BIDS.
With autoreject, I receive:
❯ 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.
I'd be interested in what adopting hatchling as a build backend means for users. It will probably not affect normal pip install mne, right? But I'm assuming pip install -e /some/path/to/mne-python will require the hatch package. Is this correct?
So it's the process of building a wheel, more or less, right? Which means that this change does not affect pip install mne at all, because the wheel has already been built.
Activity
cbrnr commentedon Nov 3, 2023
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?
hoechenberger commentedon Nov 3, 2023
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.pyEnsure VS Code is using the correct Python environment
Add the following content to the file:
Save the file
You will get red squiggly lines under
mne:Close VS Code
Run:
❯ pip install --quiet --config-settings editable-mode=strict -e ~/Development/mne-pythonStart VS Code:
Now Pylance doesn't complain about the missing import anymore.
mne-pythondirectory, as Pylance may pick up the nestedmnedirectory there (I'm not 100% sure about this but it's better to exclude this possibility) -> May explain why this problem is not an issue when developing MNE-Python itself; but I often want to use the devel version from an editable install in other projects, where I then run into this limitationcbrnr commentedon Nov 3, 2023
I can confirm that this is indeed not working. However, as you suspected, it does work if your working directory is actually
mne-python(i.e. the base directory of the editable install). So for developing MNE-Python, the editable install works as expected.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.
hoechenberger commentedon Nov 3, 2023
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
mne.Report, I have my workspace / environment with MNE-BIDS-Pipeline open in VS code, and an editable install of MNE-Python into that environment, such that every time I change something on my MNE-Python development branch, the Pipeline will pick it up upon a re-run.I had a similar issue recently when developing MNE-BIDS.
drammock commentedon Nov 3, 2023
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
pyproject.toml(and installation ofhatchling) is enough to fix the issue?One thing we'd need to watch out for is whether we can still get
setuptools_scm-like behavior for our version string.cbrnr commentedon Nov 3, 2023
A bit more info is also available here: https://learn.scientific-python.org/development/guides/packaging-simple/
hoechenberger commentedon Nov 3, 2023
Excellent resource, @cbrnr!
@drammock I can look into this tomorrow
hoechenberger commentedon Nov 3, 2023
Just a note to self, I just ran into the same issue when trying to use an editable install of MNE-BIDS.
With
autoreject, I receive:❯ 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
cbrnr commentedon Nov 3, 2023
I'd be interested in what adopting
hatchlingas a build backend means for users. It will probably not affect normalpip install mne, right? But I'm assumingpip install -e /some/path/to/mne-pythonwill require thehatchpackage. Is this correct?hoechenberger commentedon Nov 3, 2023
@cbrnr The nice thing about
pyproject.tomland PEP 660 (?) is that we can specify a build system:mne-python/pyproject.toml
Lines 45 to 47 in fcb5926
This will be installed automatically before the build process starts.
Users don't have to worry about this.
cbrnr commentedon Nov 3, 2023
But what is "the build process"?
hoechenberger commentedon Nov 3, 2023
The package is first built, then installed, when you run
pip install ./my-packageorpip install ./my-sdist.zipcbrnr commentedon Nov 3, 2023
So it's the process of building a wheel, more or less, right? Which means that this change does not affect
pip install mneat all, because the wheel has already been built.drammock commentedon Nov 3, 2023
Looks like that won't be a problem... from the scientific-python page that @cbrnr linked to:
hoechenberger commentedon Nov 3, 2023
Yes
Switch build backend to hatchling
Switch build backend to hatchling
Switch build backend to hatchling
Switch build backend to hatchling
Switch build backend to hatchling
Switch build backend to hatchling
Switch build backend to hatchling
ofek commentedon Dec 3, 2023
Maintainer of Hatch/Hatchling here! Let me know if I can be of assistance 🙂
Make Pylance recognize `cliffordep` package
typechecking issues
Add lazy loader (#87)
From py39 to py312 (#89)
Ruff gh actions (#88)