-
Notifications
You must be signed in to change notification settings - Fork 207
[MRG] FIX import local modules in examples #305
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
can anyone think of a way in which this could bite us in the long-run? |
The way I have solved this previously is by doing That being said, I don't mind adding this bit of code. My understanding is that SG running scripts is meant to mimic running them manually as much as possible. This seems like it will improve upon that. So +0.5 from me |
I have experienced the same kind of problem, although I ended up moving
the needed functions to the main package directory instead of a local
module once they where mature enough.
That being said, I don't mind adding this bit of code. My understanding is that SG running scripts is meant to mimic running them manually as much as possible. This seems like it will improve upon that. So +0.5 from me
I have the same feeling. SG should be equivalent to running a script as
an independent entity and I hope to get one day there. That would make
multiprocessing support possible and will help clearing all this tricks
we put in to emulate that (changing dirs, changing sys.argv, cleaning
seaborn imports).
This is very similar to what we do changing sys.argv to avoid those
problems, refer PR#252. I would thus prefer if we put this changes in
the generate_file_rst next to the sys.argv change. That should make
future maintenance simpler, they are not the nicest fixes but we have
them for now and I would like to keep them together.
|
This would be nice to have a test for this, ideally as a unit test, but a separate example will do if the former is very inconvenient. Without test, this kind of micro-features tend to be broken very quickly. |
Great! I'll write a test for this then (or add an example) |
Copying sys.path can be done with just |
Somewhat related, where does the information for the new style namespace packages get stashed? |
0c1f0d4
to
49d4f11
Compare
Is this still up to date? If so, @NelleV : can you fix the merge conflict, so that we merge this. |
Also maybe related to matplotlib/matplotlib#11838 (which breaks building on python3.7). |
Codecov Report
@@ Coverage Diff @@
## master #305 +/- ##
=========================================
- Coverage 95.48% 95.39% -0.1%
=========================================
Files 29 29
Lines 2239 2191 -48
=========================================
- Hits 2138 2090 -48
Misses 101 101
Continue to review full report at Codecov.
|
It would also be good to add a test. @NelleV if you do not have time I'm happy to take over and add one |
This patch allows to import a module placed in the same folder as the examples when executing the example by adding the current directory to the sys.path.
Rebased and tests added, I'll merge once it's green since folks were happy with it other than needing a test |
Thank you :) |
Thanks @NelleV |
Thanks! |
This patch allows to import a module placed in the same folder as the examples when executing the example by adding the current directory to the sys.path.
I used a deepcopy to restore the sys.path to the original state (before running the example).
This patch relates to a problem we are having on matplotlib/matplotlib#9402
I am honestly not entirely convince that sphinx-gallery should support this, as I think that good examples are self-contained examples.