manodeep / Corrfunc

⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
https://corrfunc.readthedocs.io
MIT License
163 stars 50 forks source link

Readthedocs build fails on changing the CPython interpreter to 3.x #304

Closed manodeep closed 8 months ago

manodeep commented 9 months ago

Since RTD will require an yml file (as I found out from a different project), I was checking out the Corrfunc settings on RTD. Turns out we are using python2.7 on RTD. When I changed that to CPython3.x (python3.7), then the RTD build with an error message about reaching maximum recursion. I have reverted the change, but we will have to deal with this error sooner or later.

The error is many many lines like the following:


Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/envs/master/lib/python3.7/site-packages/sphinx/config.py", line 368, in eval_config_file
    execfile_(filename, namespace)
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/envs/master/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
    exec_(code, _globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/checkouts/master/docs/source/conf.py", line 34, in <module>
    sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/checkouts/master/docs/source/conf.py", line 34, in <genexpr>
    sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
  File "/home/docs/.pyenv/versions/3.7.9/lib/python3.7/unittest/mock.py", line 1901, in __init__
    self._mock_set_magics()  # make magic work for kwargs in init
  File "/home/docs/.pyenv/versions/3.7.9/lib/python3.7/unittest/mock.py", line 1909, in _mock_set_magics
    if getattr(self, "_mock_methods", None) is not None:
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/checkouts/master/docs/source/conf.py", line 31, in __getattr__
    return Mock()
  File "/home/docs/.pyenv/versions/3.7.9/lib/python3.7/unittest/mock.py", line 1901, in __init__
    self._mock_set_magics()  # make magic work for kwargs in init
  File "/home/docs/.pyenv/versions/3.7.9/lib/python3.7/unittest/mock.py", line 1909, in _mock_set_magics
    if getattr(self, "_mock_methods", None) is not None:
  File "/home/docs/checkouts/readthedocs.org/user_builds/corrfunc/checkouts/master/docs/source/conf.py", line 31, in __getattr__
    return Mock()

Likely culprit are these lines: https://github.com/manodeep/Corrfunc/blob/master/docs/source/conf.py#L21-L34 @lgarrison Is there something specific in those lines that work for py2 but not py3? Also @lgarrison can you please send me your RTD username so I can add you as a maintainer for Corrfunc on RTD.

Related: While solving this, perhaps we can also update the intersphinx mappings for numpy/scipy and pick the relevant ones from:

intersphinx_mapping = {
    'python': ('https://docs.python.org/3/', None),
    'numpy': ('https://numpy.org/doc/stable/', None),
    'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
    'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None),
    'matplotlib': ('https://matplotlib.org/stable', None),
}
lgarrison commented 9 months ago

Maybe infinite recursion if __getattr__() is used in construction?

Would autodoc_mock_imports work here? That's what I usually use: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_mock_imports