Skip to content

Build directories are messed up with SHARE_SPHINX_DOCTREE #7200

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

Closed
mgeier opened this issue Jun 16, 2020 · 3 comments · Fixed by #7303
Closed

Build directories are messed up with SHARE_SPHINX_DOCTREE #7200

mgeier opened this issue Jun 16, 2020 · 3 comments · Fixed by #7303
Labels
Bug A bug

Comments

@mgeier
Copy link
Contributor

mgeier commented Jun 16, 2020

Later builds seem to happen in the "doctree" directory of the previous build, then in the "doctree" directory of the "doctree" directory and so on ...

I guess this is happening because of the SHARE_SPHINX_DOCTREE flag.

First build, everything looks OK:

python /home/docs/checkouts/readthedocs.org/user_builds/nbsphinx/envs/latest/bin/sphinx-build -T -j auto -E -b readthedocs -d _build/doctrees -D language=en . _build/html
[...]    
building [readthedocs]: targets for 33 source files that are out of date
updating environment: [new config] 33 added, 0 changed, 0 removed
reading sources... [  3%] a-normal-rst-file
[...]

Second build, source files are suddenly in _build/doctrees/nbsphinx/:

python /home/docs/checkouts/readthedocs.org/user_builds/nbsphinx/envs/latest/bin/sphinx-build -T -j auto -b readthedocssinglehtmllocalmedia -d _build/doctrees -D language=en . _build/localmedia
[...]
updating environment: 58 added, 2 changed, 0 removed
reading sources... [  1%] _build/doctrees/nbsphinx/allow-errors
[...]

Third build, now we are in _build/doctrees/nbsphinx/_build/doctrees/nbsphinx/:

python /home/docs/checkouts/readthedocs.org/user_builds/nbsphinx/envs/latest/bin/sphinx-build -b latex -j auto -D language=en -d _build/doctrees . _build/latex
[...]
updating environment: 58 added, 8 changed, 0 removed
reading sources... [  1%] _build/doctrees/nbsphinx/_build/doctrees/nbsphinx/allow-errors
[...]

... and there are some warning messages, because files are not found, which isn't surprising given the strange build/source directories.

Details

@stsewd stsewd added the Bug A bug label Jun 16, 2020
@stsewd
Copy link
Member

stsewd commented Jul 20, 2020

Actually this is happening in all builds, and outside rtd too. The reason is that the "_build" directory gets included into the doctree directory on each run.

I can replicate this even with the defaults from sphinx, so a solution from our side would be to have the build directory outside the docs dir.

Another solution (from your side) is to add exclude_patterns = ['_build'] to your conf.py file (this one is the default from sphinx-quickstart).

I'm not sure if this is causing any problems though, (aside from doing an extra copy operation).

Anyway, I don't think we are going to change our build directories, since there is a lot of code that depends on that structure... But we can add exclude_patterns = ['_build'] to all conf.py files if isn't defined.

stsewd added a commit that referenced this issue Jul 20, 2020
We use the _build/ directory for all builders.
Some users may not have that directory excluded,
leading to some extra copy operations.

Fixes #7200
@mgeier
Copy link
Contributor Author

mgeier commented Jul 21, 2020

Thanks for looking into this!

Indeed, adding exclude_patterns = ['_build'] solves the problem.

Here's an example: https://readthedocs.org/projects/nbsphinx/builds/11497225/

The problem in my example is that my extension nbsphinx stores the executed Jupyter notebooks in the doctrees directory and copies them to the HTML output dir later.

But since those notebooks are themselves valid source files, they are unnecessarily parsed in the next step.

I'm not sure if this is causing any problems though, (aside from doing an extra copy operation).

Yes, it cancels the effect that SHARE_SPHINX_DOCTREE should have in the first place.

The idea is that in subsequent runs, no more sources have to be parsed, but since there are new sources in the _build directory now, they get parsed again.

It shouldn't have an effect on the result, but it does have an effect on the runtime and it produces spurious warnings.

so a solution from our side would be to have the build directory outside the docs dir.

Yes, that would make very much sense.

I don't think we are going to change our build directories, since there is a lot of code that depends on that structure...

OK, that's understandable.

But we can add exclude_patterns = ['_build'] to all conf.py files if isn't defined.

Yes, please!

Since you (= RTD) are choosing the _build directory, I think it is also your responsibility to add it to exclude_patterns.

stsewd added a commit that referenced this issue Jul 21, 2020
We use the _build/ directory for all builders.
Some users may not have that directory excluded,
leading to some extra copy operations.

Fixes #7200
@mgeier
Copy link
Contributor Author

mgeier commented Jul 21, 2020

Thanks @stsewd for the quick solution, that's great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants