-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Mocked modules aren't ignored, redux #8205
Comments
Hi, looks like the import error comes from using autoprogram https://github.com/rbeyer/hiproc/blob/2a245d3ed299dc2a6a356fba62740d2432549b28/docs/conf.py#L55 https://github.com/rbeyer/hiproc/blob/main/docs/console.rst
I can increase the resources for your project, so you can try using conda. |
Thanks. Apparently, I don't understand It seems wasteful to me to to use more cycles to have conda do its thing to install a library that only needs to sit there so that "import osgeo" doesn't fail when Sphinx imports "my" modules to read their docstrings. No part of the Sphinx documentation run needs gdal/osgeo. I'll try and dig deeper into how to mock the imports so it isn't needed. I was hoping that I was just missing something about how I'll spend some more time digging, but may still sheepishly come back to ask for more resources, but I hope I won't have to. Thanks again. |
@rbeyer Is there a chance that installing libgdal with |
@astrojuanlu, I tried that in RTD Build 13831893, but then I got import errors about _gdal_array:
I had this in my
And |
Oh, I see. I think I arrived to the same answers as you: https://gis.stackexchange.com/a/274328/99665 (Also, sorry - I just realized you wrote it in the first comment) I confirmed locally with a Ubuntu Bionic image that installing NumPy before the GDAL Python bindings indeed fixes the The last thing I'd suggest is switching back the configuration to conda, and turn |
@astrojuanlu, no worries, and thank you. Hmm, does the requirements.txt file get run serially in order? Maybe I just need to try changing the order (I have gdal first, just because I typically arrange my requirements.txt file alphabetically). When I get a chance, I'll try that. And will also try the mamba approach. Thanks for the suggestions. |
I think pip largely ignores the order, wouldn't trust it that much. The mamba approach would require an action from our side, let us know when you're ready 👍🏽 |
So, the thing that I was missing about how So no amount of adding things to Then I messed around some more, and got a mocking situation to work (as detailed in that Issue) that didn't require a code change to autoprogram, and also allowed my RTD run to complete, without needing to install gdal/osgeo at all (either via apt_packages, pip, or conda). Hopefully I've mentioned GDAL enough in this issue that folks will find it, if they end up having similar trouble getting something that just uses gdal/osgeo to work with RTD. Thanks to all the help in this thread as I lurched myself to understanding and solution! |
Details
Expected Result
My Python project uses GDAL, which has all kinds of difficulty in installing cleanly via pip, so I used
autodoc_mock_imports
in my conf.py file to keep it from being imported (and did not include it in my requirements.txt file). I expected the build to complete.It appears that #6209 had a similar issue, but did get things to work?
Actual Result
Unfortunately, the build failed with a ModuleNotFoundError (which I assumed the
autodoc_mock_imports
would handle). The unfound module is "osgeo" which is the top level import statement in the modules (why it is "osgeo" and not "gdal" is a historical oddity, but if you install the gdal python package, youimport osgeo
).Instead of
autodoc_mock_imports
I tried using conda (but the solve took too long and the build failed). I tried using apt_packages in the.readthedocs.yaml
file to install GDAL (as suggested in #8160), and set environment variables. This allowed GDAL to install, but yielded a failure when it tried to import_gdal_array
(My failing Build 13831926 ) which was something that gdal/osgeo was doing internally, so that didn't seem like I could get much farther.It seems like
autodoc_mock_imports
should do what I want to safely ignore gdal/osgeo, but it doesn't. Do I have some syntax wrong somewhere?The text was updated successfully, but these errors were encountered: