Skip to content

sage.repl: Replace use of SAGE_EXTCODE by importlib.resources #31306

@mkoeppe

Description

@mkoeppe

We eliminate direct reading of files from the package directories of sagelib by using importlib.resources (available since python 3.7)

  • git grep 'SAGE_EXTCODE' src/sage
  • git grep '__file__' src/sage

This will help make sagelib zip_safe (https://setuptools.readthedocs.io/en/latest/userguide/miscellaneous.html#setting-the-zip-safe-flag)

In this ticket, we take care of sage.repl, moving data needed by its doctests from SAGE_EXTCODE (= src/sage/ext_data) into the package directory. (Thus, we avoid a dependency on support for resources in namespace packages brought by Python 3.10(?) or the backport package importlib-resources, see python/importlib_resources#196)

Follow-up tickets will deal with other parts of the library. In the end, the directory src/sage/ext_data will be eliminated.

References:

CC: @tobiasdiez @fchapoton @kiwifb @dimpase @soehms @tscrim

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: d925cd2

Reviewer: Dima Pasechnik

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions