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

Sphinx does not yet support python packages with no __init__.py - PycodeError: no source found for module #7727

Closed
ben-spiller opened this issue May 26, 2020 · 5 comments

Comments

@ben-spiller
Copy link

Describe the bug
As of Python 3.3, init.py files are no longer required to make a directory be a valid package - http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html for ... and there are good reasons why it may not be be possible to have one. Sphinx doesn't yet support this aspect of Python's package mangement system, as it assumes that omission of init.py is an error:

Exception occurred: File "c:\dxxxx\sphinx\3.0.1\lib\python3.6\site-packages\sphinx\pycode\__init__.py", line 59, in get_module_source raise PycodeError('no source found for module %r' % modname) sphinx.errors.PycodeError: no source found for module 'mymodule'

To Reproduce
Steps to reproduce the behavior:
Just try to build sphinx documentation for a package that doesn't have a init.py file

Expected behavior
As omission of init.py is no longer a bug, Sphinx should not treat it as an error, and instead act as if an empty init.py file had been present.

Environment info

  • OS: all (Win/Linux)
  • Python version: 3.6.4
  • Sphinx version: 3.0.1
  • Sphinx extensions: sphinx.ext.autodoc, sphinx.ext.autosummary
  • Extra tools: -
@tk0miya
Copy link
Member

tk0miya commented May 26, 2020

I can't reproduce the error. Could you make a small example, please?

@tk0miya tk0miya modified the milestone: 3.1.0 May 26, 2020
@gutiersa
Copy link

gutiersa commented Sep 7, 2020

I am using FreeBSD, same problem here, I am just updating my packages. This is my log:

 Sphinx version: 3.2.1
 Python version: 3.7.9 (CPython)
 Docutils version: 0.15.2 release
 Jinja2 version: 2.10.1
 Last messages:

 Loaded extensions:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sphinx/cmd/build.py", line 279, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/usr/local/lib/python3.7/site-packages/sphinx/application.py", line 240, in __init__
    self.setup_extension(extension)
  File "/usr/local/lib/python3.7/site-packages/sphinx/application.py", line 398, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/local/lib/python3.7/site-packages/sphinx/registry.py", line 409, in load_extension
    mod = import_module(extname)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/epub3.py", line 20, in <module>
    from sphinx.builders import _epub_base
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/_epub_base.py", line 25, in <module>
    from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 39, in <module>
    from sphinx.search import js_index
  File "/usr/local/lib/python3.7/site-packages/sphinx/search/__init__.py", line 125, in <module>
    from sphinx.search.en import SearchEnglish
  File "/usr/local/lib/python3.7/site-packages/sphinx/search/en.py", line 14, in <module>
    from sphinx.util.stemmer import get_stemmer
  File "/usr/local/lib/python3.7/site-packages/sphinx/util/stemmer/__init__.py", line 14, in <module>
    from Stemmer import Stemmer as _PyStemmer
SystemError: init function of Stemmer returned uninitialized object

@samlaf
Copy link

samlaf commented Nov 6, 2020

I'm getting the same mistake: https://readthedocs.org/projects/dymoesco/builds/12276491/
Would be really nice to have a fix for this.

@tk0miya
Copy link
Member

tk0miya commented Nov 8, 2020

@gutiersa It seems your error is not related to this issue. Please file a new one.

@tk0miya
Copy link
Member

tk0miya commented Nov 8, 2020

@samlaf Thank you for reporting. I found the reason of this error. I hope #8390 resolves your error.
Thanks,

tk0miya added a commit that referenced this issue Nov 9, 2020
Fix #7727: autosummary raises PycodeError for namespace python package
@tk0miya tk0miya closed this as completed Nov 9, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants