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

RTD installs python module, but can't import it afterwards #8357

Closed
FirefoxMetzger opened this issue Jul 20, 2021 · 2 comments
Closed

RTD installs python module, but can't import it afterwards #8357

FirefoxMetzger opened this issue Jul 20, 2021 · 2 comments

Comments

@FirefoxMetzger
Copy link

I moved the dependencies of my python project from a setup.cfg into a setup.py (to allow Dependabot pick them up) and since then RTD is unable to correctly generate the docs.

Locally, the docs build fine. If I build the same project on RTD, however, (after migrating the dependencies) then sphinx.autosummary can't import any modules. Similarly, if I add the line import ropy (name of the project) into sphinx's conf.py the entire build crashes because RTD can't import ropy (log attached).

I am using a .readthedocs.yaml which should install the project together with doc-related dependencies. Indeed, the logs show pip building the wheel and then claiming that it was installed. However, this does not seem to be the case. I tried to add the module to the path manually inside the conf.py, which allows to import ropy, but then breaks later when sub-modules are imported, because they depend on specific versions of external libraries which don't seem to be present. In particular, I need numpy in a sufficiently recent version to support from numpy.typing import ArrayLike, but this then crashes (build: https://readthedocs.org/projects/robotics-python/builds/14282476/) with an exception that suggests that the required numpy version isn't present.

Any pointers on where I should look to debug this are highly appreciated :)

.readthedocs.yaml
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
   configuration: doc/source/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
   - pdf

# Optionally set the version of Python and requirements required to build your docs
python:
   install:
    - method: pip
      path: .
      extra_requirements:
        - docs

Details

Expected Result

The rendered docs match the local build and sphinx.automodule can import the module.

Actual Result

sphinx.automodule (and sphinx in general) can not import the module; however, the logs suggest that it has been installed.

@FirefoxMetzger FirefoxMetzger changed the title RTD builds python module, but can't import it afterwards RTD installs python module, but can't import it afterwards Jul 20, 2021
@astrojuanlu
Copy link
Contributor

Hi @FirefoxMetzger ! I think the typing error you get from NumPy in FirefoxMetzger/scikit-bot#21 is actually numpy/numpy#19521.

Regarding the migration to setup.py, you are right:

However, it turns out that Sphinx autosummary can give bogus import errors, as I have recently learned from sphinx-doc/sphinx#7989. Therefore, let me confirm to you what is the source of the problem here.

@astrojuanlu
Copy link
Contributor

Yes, RTD was installing ropy. However, the ropy package contained no files, that's why import ropy failed. I fixed that for you in FirefoxMetzger/scikit-bot#22. Notice that it departs from FirefoxMetzger/scikit-bot@6623b1e rather than your current main branch, be mindful if you end up merging it.

I'm closing this issue, feel free to open a new one if you still have problems.

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

No branches or pull requests

2 participants