sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.19k stars 2.03k forks source link

Failing to use autodoc on .pyd files #10254

Open flotang-gtt opened 2 years ago

flotang-gtt commented 2 years ago

Describe the bug

Hi there,

after recently updating (not sure if really related?) to sphinx 4.4.0 - and I did not check which version I was using previously - , my build does not seem to work anymore.

I am getting a

    raise PycodeError('source is not a .py file: %r' % filename)
sphinx.errors.PycodeError: source is not a .py file: '[...somefile...].cp38-win_amd64.pyd'

After looking at that pycode__init__.py, I am wondering what happened, because it wasn't updated in the last two years, and I surely haven't used such an old version previously.

So what am I missing about using autodoc on cython generated .pyd modules? The code around where the exception is thrown looks like I need to provide the files as plain .py files, it does not seem to filter/accept .pyx cython files. Obviously pure python parsing also fails on e.g. cimport commands, so just renaming to .py does not solve this.

Yes, the embedsignature=True signal is used when cythonizing - and this was never changed when using the older versions.

Obviously I can provide e.g. the .log file as well as conf.py, but most of my setup is pretty standard and I would rather not invest the time into anonymizing these files. I really do think it's caused by my configuration, especially since it did work previously and failed with one of the later updates.

The environment in which the build fails is configured as follows, running on python 3.8.12:

requirements.txt

How to Reproduce

I gave some info above, and may fill in this info later.

Expected behavior

No response

Your project

-

Screenshots

No response

OS

Windows

Python version

3.8.12

Sphinx version

4.4.0

Sphinx extensions

sphinx.ext.autodoc, sphinx.ext.doctest, sphinx.ext.intersphinx, sphinx.ext.todo, sphinx.ext.coverage, sphinx.ext.imgmath

Extra tools

No response

Additional context

No response

tk0miya commented 2 years ago

Could you share the stacktrace of the error, please? I'd like to know the reason of the error. It would be nice if you have a minimal reproducible example.