Skip to content

Relative imports from Cython files in cuda_core cause duplicate imports #2023

@mdboom

Description

@mdboom

If you have code like

from . import typing

in a .pyx file, and another part of the system does:

from cuda.core.system import typing

it causes the typing module to be imported twice.

The first import places the module in sys.modules as cuda.core.cu13.system.typing, and the second import places the module in cuda.core.system.typing. It means that any isinstance checks on classes in this module will fail.

This is clearly a side effect of the "megapackage" approach handled by _import_versioned_module. It is not clear whether we can address it at that level.

At a minimum, maybe we can write a lint or an AGENT.md rule that relative imports should be avoided from Cython modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcuda.coreEverything related to the cuda.core moduletriageNeeds the team's attention

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions