-
Notifications
You must be signed in to change notification settings - Fork 16
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
Mkdocs gallery and sys.path
#82
Conversation
Thanks @Louis-Pujol for this proposal ! Could you please also add a changelog entry for your mod ? Thanks ! |
Co-authored-by: Sylvain Marié <[email protected]>
Co-authored-by: Sylvain Marié <[email protected]>
Thanks, I committed your suggestions. I'm not sure about what I need to do for adding a changelog entry. Do I need to create a new release on my repository ? And if yes, which tag do I need to choose ? Sorry if my questions are naive, I'm not very familiar with those things |
Thanks @Louis-Pujol . No, simply modify the file |
Thanks, I just did it. |
Thanks @Louis-Pujol . Now I had some afterthought: we do not want any sys path leak to happen between one example file and the others. So now that sys path is preserved across blocks of a single example, we have to reset the sys path when the example is completed. Could you please modify Thanks a lot ! |
docs/changelog.md
Outdated
@@ -3,6 +3,7 @@ | |||
### 0.7.9 - (In Progress) | |||
|
|||
- Swapped from deprecated `disutils.version` to `packaging.version`. PR [#79](https://github.com/smarie/mkdocs-gallery/pull/79) by [Samreay](https://github.com/Samreay) | |||
- Rewrited `gen_single._reset_cwd_syspath` function to let `sys.path` modifications persist accross blocks. PR [#82](https://github.com/smarie/mkdocs-gallery/pull/82) by [Louis-Pujol](https://github.com/Louis-Pujol). |
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.
- Rewrited `gen_single._reset_cwd_syspath` function to let `sys.path` modifications persist accross blocks. PR [#82](https://github.com/smarie/mkdocs-gallery/pull/82) by [Louis-Pujol](https://github.com/Louis-Pujol). | |
- `sys.path` modifications now persist accross blocks of an example. `sys.path` is still reset after each example. PR [#82](https://github.com/smarie/mkdocs-gallery/pull/82) by [Louis-Pujol](https://github.com/Louis-Pujol). |
Thank you for pointing this out. I did the resetting of |
Perfect @Louis-Pujol ! Thanks a lot. Will this this now. Two releases on the same day :D |
Hello,
I have a little issue with
sys.path
andmkdocs-gallery
. I realized that changes to sys.path were not persistent across code blocks. Here is a simple illustration script :And the resulting example:
sys.path
Were reinitialized between block 2 and block 3 as/home/mypath
is no longer insidesys.path
.This behavior comes from this function, which is called between blocks and reset sys.path:https://github.com/smarie/mkdocs-gallery/blob/d4c2d7fd7991a590abc2c947a61334b3a56ab9f7/src/mkdocs_gallery/gen_single.py#L731-#L735
This caused me some trouble because I use some libraries that add cache directories to
sys.path
. If I understand correctly the purpose of_reset_cwd_path
, it is meant to remove cwd fromsys.path
, but it actually removes all new additions.In this PR, I propose to modify
_reset_cwd_path
in order to remove only the last cwd and do not erase other modifications tosys.path
. With this new version, my example works as I expected:Let me know what are your thoughts about this changes.
Many thanks,
Louis