-
Notifications
You must be signed in to change notification settings - Fork 41
Add note about not using editable installs for docs #209
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
Conversation
([sphinx-gallery](https://sphinx-gallery.github.io/stable/index.html)), you may | ||
need to install napari from source without using an editable install if your | ||
goal is to build the documentation locally. In that case, you should not use the | ||
`-e` argument of `pip install`. |
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.
Thanks for this @melissawm! I think without the context of #207 and the comments, this is a bit vague. I suggest adding language like: "If you see an error like the following: AttributeError: module 'napari.Viewer' has no attribute 'close_all'
, then make sure you install napari without an editable install. That is, don't use-e
to install a local version of napari. For more details, see the discussion at napari/docs#207."
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.
Yeah, I am debating not expanding too much to not be overwhelming for someone who only wants to build docs and giving full context. Maybe this isn't even necessary if we find out the source of the original error? I'll mark this PR as draft and explore a bit.
Could you point out your setup? I was able to build docs using editable installation without a problem. |
@Czaki the context is:
This generates errors that do not appear if the install from source is not set to editable.
This may be a sphinx-gallery issue, but since we could work around it by not using an editable install (and this may be easier than debugging sphinx-gallery) I am proposing this here. But now I'm reconsidering, maybe there is a fix. |
If you could modify the code: try:
napari.Viewer.close_all()
except AttributteError:
print(napari.__file__, dir(napari.Viewer))
raise and paste the result |
@Czaki here's the output:
|
If a Viewer ismodule could you add points of it's path? (print(napari.Viewer.file)) |
|
wait. It if is module it should have try:
napari.Viewer.close_all()
except AttributteError:
print(napari.__file__, getattr(napari.Viewer, "__file__", "Nope"))
raise |
With def napari_scraper(block, block_vars, gallery_conf):
"""Basic napari window scraper.
Looks for any QtMainWindow instances and takes a screenshot of them.
`app.processEvents()` allows Qt events to propagateo and prevents hanging.
"""
imgpath_iter = block_vars['image_path_iterator']
if app := napari.qt.get_app():
app.processEvents()
else:
return ""
img_paths = []
for win, img_path in zip(
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
imgpath_iter,
):
img_paths.append(img_path)
win._window.screenshot(img_path, canvas_only=False)
try:
napari.Viewer.close_all()
except AttributeError:
print(napari.__file__, getattr(napari.Viewer, "__file__", "Nope"))
raise
app.processEvents()
return scrapers.figure_rst(img_paths, gallery_conf['src_dir']) I get
|
Sorry I just noticed this issue. I've been digging into this problem. It's caused by a couple of things working together against us:
Together these create our problem in the docs build. Here are the steps to failure as I understand them:
Current workarounds (if there are no changes to |
After a bit more investigation there's slightly more to it.
...but this also sets |
This may not be relevant, but if we miss a reference to the
ref: https://docs.python.org/3/reference/import.html#the-module-cache But the question is, would all references to this module in |
Yes I think you're right this could happen. As with a lot of this stuff it's probably unlikely to cause a problem, but I'm sure it could (for example if using module-scope variables). I'm increasingly convinced the only truly safe way to test imports like this would be to do it in a subprocess. I tested this and it's predictably rather slow. Still, there's probably some reasonable best-effort that can be made. In any case we may be sufficiently off-topic for this PR 😅. I recommend keeping some simple wording here as proposed and we can revisit removing the language if/when fixes and workarounds are merged upstream. |
Ok - I have to say i don't really follow the full discussion so I'll mark this as ready for review and if we can do better on the sphinx-gallery itself we can revisit this note later. Thanks everyone! |
I will say I agree with @jni's wording suggestions. I don't want to throw |
I've created a new issue as a better place to have this discussion! #214 |
We might be able to close this now as a fix for these case-insensitive imports has been released in setuptools 68.1.0. |
Thanks @aganders3 ! |
Description
Adds note about building documentation with editable builds of napari.
Type of change
References
Related to #207 (comment)
Final checklist: