Skip to content

4.1.1: build_sphinx fails when module sourvce code is not in <module_name/> directory #9517

@kloczek

Description

@kloczek

Describe the bug

Example agronholm/anyio#354
Currently many modules relocates its own source code to src/ directory. In most of the cases setup.py build_sphinx fails because looks like build_sphinx assumes that source code will be in `<module_name/> in project root directory.

Q: what should be kind of generic solution in such cases?

How to Reproduce

git clone https://github.com/agronholm/anyio/
cd anyio
python3 setup.py build_sphinx --build-dir build/sphinx

Expected behavior

sphinx-build should build documentation.

Your project

N/A

Screenshots

+ /usr/bin/python3 setup.py build_sphinx -b man --build-dir build/sphinx
running build_sphinx
Running Sphinx v4.1.1

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

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 327, in eval_config_file
    exec(code, namespace)
  File "/home/tkloczko/rpmbuild/BUILD/anyio-3.3.0/docs/conf.py", line 17, in <module>
    v = pkg_resources.get_distribution('anyio').parsed_version
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 482, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 358, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'anyio' distribution was not found and is required by the application

OS

Linux/x86_64

Python version

3.8.11

Sphinx version

4.1.1

Sphinx extensions

N/A

Extra tools

N/A

Additional context

I think that this is partially related to more generic case described in #9378
adding build/lib and build/lib-<os>.<arch> to sys.path could IMO solve both cases when module consist of DSOs are build and actual source code of the module is not <module_name/> directory.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions