jupyterlite-sphinx
jupyterlite-sphinx copied to clipboard
jupyterlite_contents paths not picked up if run from outside of app.srcdir
When the top build command is run outside of Sphinx' srcdir (which is the case when buliding from Jupyterbook for instance) the following happens:
jupyterlite_contentspath are expanded with glob using the cwd as root. This means that paths that don't exist after expansion are removed from the list.jupyter lite buildis invoked usingapp.srcdiras cwd.
So say I have the following structure
repo
└── book
├── conf.py
└── notebooks
└── nb.ipynb
To build the book, I have to run Jupyterbook in repo and I want notebooks/ to be in jupyterlite_contents.
- If I set
jupyterlite_contents = ["book/notebooks"],globin 1. will be able to find it since for glob, the root dir isrepo, but whenjupyter lite buildruns in 2., since its cwd isbook, it won't findbook/notebooksand the build will fail. - If I set
jupyterlite_contents = ["notebooks"]instead,globin 1. won't find it, sot it will silently remove it from the list. The build will succeed but thenotebookwon't be picked up.
Either way, I can't get notebook in my build if it's not run from app.srcdir.
A simple fix would be to set glob's rootdir parameter to src.appdir. It would still allow adding paths outside of the appdir using ... I can send a PR as soon as I have you go, or as soon as we figure out another solution if this one doesn't work, as I am very interested in having this fixed :-)
Hi @LoicGrobol, thanks for the report and sorry for the late response! I think this bug report is valid, but I'm unsure if I follow it correctly, so I want to seek some clarification(s). :)
-
Could you please explain how you're running
jupyterlite-sphinx? If I understand this correctly, it is Jupyter Book that's setting this requirement, as it might be runningpython sphinx -b html --conf-dir ./book/internally from therepofolder? -
Your suggested fix is to set the
rootdirparameter forglob.globhere: https://github.com/jupyterlite/jupyterlite-sphinx/blob/6f7aa459219e7d98921a65b14efe1e6be3b6e8aa/jupyterlite_sphinx/jupyterlite_sphinx.py#L991-L1001 Would it better if we were to allow absolute paths here as well, so that we aren't bound to looking just inapp.srcdir?
Either way, I'm happy to accept a PR for the changes, and we can release it as soon as possible – as we already have a bunch of fixes going in sooner or later. Thanks a lot!
Hi @LoicGrobol, I've started a solution in #280 that should allow using relative paths using ../<...>/ and also absolute paths to any directory on your system. Please feel free to comment on this approach, and I hope this resolves your issue!