-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow editable install #155
Allow editable install #155
Conversation
dc93bc3
to
3709d74
Compare
|
spin/cmds/meson.py
Outdated
import importlib_metadata | ||
|
||
try: | ||
dist = importlib_metadata.Distribution.from_name(package) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Distribution.from_name(...)
expects the distribution name and not the package name!
As is, this line always raises a PackageNotFoundError
despite the editable install clearly working otherwise (installed with pip install --no-build-isolation -e .
). Running spin test ...
etc. still builds as if the editable install is not present.
However, when I set a breakpoint here and use
importlib_metadata.Distribution.from_name("scikit-image")
instead of package
which is "skimage"
it seems to work! Do you have access to the distribution name at this level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this is working for you? Maybe my setup is weird?
It works for packages where the distribution and package names are the same (example_pkg, numpy, etc.). Fortunately, I think we can get hold of the distribution name too, so will fix. |
@lagru How about now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great. However, there will be a few issues in scikit-image we need to address before we can use this.
The skimage
module of the editable install seems to have a empty __path__
which makes apigen.py and spin docs
fail. But that's something we can fix in skimage with
Details
diff --git a/doc/tools/apigen.py b/doc/tools/apigen.py
--- a/doc/tools/apigen.py (revision f4c1b34ac968d9fda332d7d9a63c83499aaac1f6)
+++ b/doc/tools/apigen.py (date 1706272296049)
@@ -20,6 +20,7 @@
# Stdlib imports
import os
import re
+from pathlib import Path
from types import BuiltinFunctionType, FunctionType, ModuleType
@@ -91,7 +92,7 @@
# It's also possible to imagine caching the module parsing here
self._package_name = package_name
root_module = self._import(package_name)
- self.root_path = root_module.__path__[-1]
+ self.root_path = str(Path(root_module.__file__).parent)
self.written_modules = None
package_name = property(
Also spin test
is behaving weird. spin test
works, spin test -- skimage/
as well, but spin test -- --doctest-plus skimage/
runs into a heaps of ModuleNotFoundError
. Even worse spin test --doctest-plus
without a target seems to execute the gallery examples and is effectively a DOS attack on the window manager because of plotting windows. Not sure what's going on yet, but I don't think it's the fault of spin.
Edit: Might be solved by moving the test suite into its own directory.
This came up on the |
Editable installs are by design incomplete installs, other things that can be missing:
|
Thanks @rgommers! That will be very useful to know when we eventually get to updating that in skimage. |
0d90393
to
bf036f4
Compare
f71492d
to
9cc70b4
Compare
9cc70b4
to
844db07
Compare
I think it is unrelated, since I see the same using |
At least in 2018, doctests could not be run against an installed package. Has that changed since? |
This seems to work:
|
I'm a bit hesitant to make this the default, given what I read at https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html:
|
I think this is now close-enough to ready to release into the wild for testing. We may need to make a point release as issues are uncovered. |
Thanks for working on this feature and releasing 0.9! FYI I have opened a WIP PR to gather feed-back on using spin in scikit-learn scikit-learn/scikit-learn#29012. |
With this change,
spin
should be able to detect and work with existing editable installs.It also checks that the editable install is from the current directory.
@lagru, can you give it a try?