Building works locally, but fails on upload to readthedocs
Details
- Read the Docs project URL: https://readthedocs.org/projects/pocketqube/
- Build URL (if applicable): https://pocketqube.readthedocs.io/en/latest/
- Read the Docs username (if applicable): https://readthedocs.org/profiles/thetazero/
Expected Result
When building with make html locally I get:
On this page: https://pocketqube.readthedocs.io/en/latest/applications/flight/
Actual Result
However in the actual build I get this:
And the logs say:
WARNING: autodoc: failed to import class 'naive.NaiveMessage' from module 'lib'; the following exception was raised:
No module named 'lib'
WARNING: autodoc: failed to import module 'priority_queue' from module 'lib'; the following exception was raised:
No module named 'lib'
WARNING: autodoc: failed to import function 'priority_queue.push' from module 'lib'; the following exception was raised:
No module named 'lib'
WARNING: autodoc: failed to import function 'priority_queue.pop' from module 'lib'; the following exception was raised:
No module named 'lib'
WARNING: autodoc: failed to import function 'priority_queue.heapify' from module 'lib'; the following exception was raised:
No module named 'lib'
Here is the entire build log if it helps: https://readthedocs.org/api/v2/build/17534486.txt
I was building on Ubuntu 22.04 LTS if it helps.
Hi, this is probably because of the CWD being different on RTD (relative to where your conf.py file is), and your local CWD being your docs directory.
https://github.com/PyCubed-Mini/PyCubedMiniDocs/blob/f8b494f7db4124a368f38e9d3f008636c0cd67b9/docs/source/conf.py#L5
To avoid these problems, you should always use explicit absolute paths from your conf.py file, for example:
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "../../flight_software/state_machine/applications/flight"))