2

How can I tell readthedocs not to load any Python files located at top root folder?

Background: I would like readthedocs to build Sphinx documentation for a Blender Python add-on, hosted on github. I have created docs folder in the repository for Sphinx files. I can build Sphinx docs OK on my local computer (in docs directory), but the build on readthedocs fails on error

  File "/home/docs/checkouts/readthedocs.org/user_builds/bvtknodes/envs/latest/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 20, in <module>
    from pip._vendor import pkg_resources
  File "/home/docs/checkouts/readthedocs.org/user_builds/bvtknodes/envs/latest/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 41, in <module>
    import inspect
  File "/home/docs/checkouts/readthedocs.org/user_builds/bvtknodes/checkouts/latest/inspect.py", line 1, in <module>
    import bpy
ModuleNotFoundError: No module named 'bpy'

The reason for this error was that there was inspect.py module located at root directory, so readthedocs setup process loaded that instead of system version of inspect module. When I renamed my inspect.py to b_inspect.py, then the docs building process finished properly at readthedocs. However this is just a workaround, is there a better solution?

Original wrong interpretation: It seems that readthedocs is trying to inspect __init__.py (located at top folder level and can't be moved from there to a subfolder) contents and build fails when it can't import bpy. AFAIK there is no way to install bpy module via pip (but I wouldn't want to do that anyway). I'd like readthedocs to ignore all python files. language = None and extensions list in docs/conf.py is empty. I've also set "Python configuration file" setting in readthedocs Advanced Settings to docs/conf.py. Thanks!

Here is link to readthedocs build which failed.

  • Cannot reproduce or help without further information. Please include a link to the failed build so we can see the failure and troubleshoot. – Steve Piercy Mar 06 '20 at 21:48
  • OK, link added. – Tuomo Keskitalo Mar 07 '20 at 06:13
  • I think the issue is that RTD cannot find your `docs/conf.py` file. In your RTD configuration, go to Admin > Advanced Settings, and enter `docs/conf.py` for "Python configuration file". As a side note, and if that setting does not work, I would suggest that you put your source code into a nested folder `src/projectname` to separate docs from code. That could be an issue with RTD, but that's just a guess. – Steve Piercy Mar 07 '20 at 09:41
  • Thanks, but I've already set "Python configuration file", and it is unfortunately not an option to move code to a subfolder. I wonder is there some way to stop readthedocs from parsing `__init__.py` if it can't import a library? – Tuomo Keskitalo Mar 07 '20 at 09:59
  • Have you tried searching the [RTD issue tracker](https://github.com/readthedocs/readthedocs.org)? In general having source code at the root of your project is a bad idea. – Steve Piercy Mar 07 '20 at 10:31

0 Answers0