Skip to content
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

jupyterlite_contents paths not picked up if run from outside of app.srcdir #261

Open
LoicGrobol opened this issue Jan 25, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@LoicGrobol
Copy link

When the top build command is run outside of Sphinx' srcdir (which is the case when buliding from Jupyterbook for instance) the following happens:

  1. jupyterlite_contents path are expanded with glob using the cwd as root. This means that paths that don't exist after expansion are removed from the list.
  2. jupyter lite build is invoked using app.srcdir as 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"], glob in 1. will be able to find it since for glob, the root dir is repo, but when jupyter lite build runs in 2., since its cwd is book, it won't find book/notebooks and the build will fail.
  • If I set jupyterlite_contents = ["notebooks"] instead, glob in 1. won't find it, sot it will silently remove it from the list. The build will succeed but the notebook won'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 :-)

@LoicGrobol LoicGrobol added the bug Something isn't working label Jan 25, 2025
@agriyakhetarpal
Copy link
Member

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). :)

  1. 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 running python sphinx -b html --conf-dir ./book/ internally from the repo folder?

  2. Your suggested fix is to set the rootdir parameter for glob.glob here:

    # Expand globs in the contents strings
    jupyterlite_contents = [
    match
    for pattern in jupyterlite_contents
    for match in glob.glob(pattern, recursive=True)
    ]
    contents = []
    for content in jupyterlite_contents:
    contents.extend(["--contents", content])
    Would it better if we were to allow absolute paths here as well, so that we aren't bound to looking just in app.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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants