Skip to content

sage -docbuild: error building docs of single file with relative imports #30475

@mkoeppe

Description

@mkoeppe

Follow-up from #29651:

The approach of SingleFileBuilder, creating a symlink to the source file, is not compatible with from .module import.

Example:

$ ./sage -docbuild file=src/sage/geometry/polyhedron/base.py html 
[html     ] building [html]: targets for 1 source files that are out of date
[html     ] updating environment: [new config] 1 added, 0 changed, 0 removed
[html     ] WARNING: autodoc: failed to import module 'base'; the following exception was raised:
[html     ] attempted relative import with no known parent package
[html     ] writing additional pages...  searchdone
[html     ] copying static files... ... done
[html     ] dumping search index in English (code: en)... done
[html     ] The HTML pages are in ../../../../.sage/docbuild/base/output/html.
Error building the documentation.

Instead, we should infer the fully qualified module name from the file name (see for example #30452) and import this module.

See also:

CC: @jhpalmieri @DaveWitteMorris

Component: build

Issue created by migration from https://trac.sagemath.org/ticket/30475

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions