Skip to content

Meta-ticket: Clear out __init__.py files in preparation for namespace packages #32501

@mkoeppe

Description

@mkoeppe

(Part of the modularization effort, #29705)

Whenever there are two distribution packages that provide modules with a common prefix of Python packages, that prefix needs to be a native namespace package, i.e., there cannot be an __init__.py file.

For example,

  • sagemath-tdlib will provide sage.graphs.graph_decompositions.tdlib,
  • sagemath-rw will provide sage.graphs.graph_decompositions.rankwidth,
  • sagemath-graphs will provide all of the rest of sage.graphs.graph_decompositions (and most of sage.graphs).
    Then, none of
  • sage,
  • sage.graphs,
  • sage.graphs.graph_decomposition
    can be an ordinary Python package (with __init__.py file), but rather each of them has to be a native namespace package (no __init__.py file).

In this meta-ticket, we make sure that all such __init__.py files are empty. (The actual removal of empty __init__.py files will be done in #28925.)

Not all __init__.py files need to be empty. For example,

  • all of sage.cpython and sage.structure (after Move sage.structure.formal_sum to sage.modules #29870) is intended to be in one distribution package, sagemath-objects. Hence sage.cpython and sage.structure keep their nonempty __init__.py files, and we may even add a comment that documents that they are intended to stay ordinary packages. (Remove some monkey patching in src/sage/__init__.py #31420 clears sage.__init__ and adds such a comment to sage.cpython.__init__)
  • sage.libs.giac is intended to be in one distribution package, sagemath-giac. Hence sage.libs.giac will keep its nonempty __init__.py file (but sage.libs will not).

With positively-reviewed tickets #31420/#32479/#32506/#32507

$ find src/sage -name '__init__.py' | xargs wc -l | grep -v '^ *0'
       2 src/sage/crypto/__init__.py
       3 src/sage/crypto/mq/__init__.py
       3 src/sage/dynamics/__init__.py
       3 src/sage/dynamics/cellular_automata/__init__.py
      42 src/sage/combinat/words/__init__.py
      38 src/sage/combinat/designs/__init__.py            #32508
      13 src/sage/combinat/chas/__init__.py               #32508
      11 src/sage/combinat/path_tableaux/__init__.py      #32508
      49 src/sage/combinat/__init__.py                    #32508
      10 src/sage/combinat/cluster_algebra_quiver/__init__.py  #32508
      51 src/sage/combinat/species/__init__.py            #32508
      31 src/sage/combinat/sf/__init__.py                 #32508
      29 src/sage/combinat/crystals/__init__.py           #32508
      10 src/sage/combinat/ncsym/__init__.py              #32508
      35 src/sage/combinat/posets/__init__.py             #32508
      11 src/sage/combinat/ncsf_qsym/__init__.py          #32508
       7 src/sage/combinat/integer_lists/__init__.py            # OK, 1 distro
      36 src/sage/combinat/rigged_configurations/__init__.py  #32508
     127 src/sage/combinat/root_system/__init__.py        #32508, #32840
       9 src/sage/combinat/matrices/__init__.py
       3 src/sage/doctest/__init__.py                           # OK, 1 distro sagemath-repl
     826 src/sage/features/__init__.py                          # OK, 1 distro
       4 src/sage/repl/rich_output/__init__.py                  # OK, 1 distro sagemath-repl
      39 src/sage/__init__.py                             #32489
     359 src/sage/libs/giac/__init__.py                         # OK, 1 distro sagemath-giac
       2 src/sage/libs/ntl/__init__.py                          # OK, 1 distro
       1 src/sage/libs/gap/__init__.py                          # OK, 1 distro
     219 src/sage/libs/pari/__init__.py                         # OK, 1 distro
      55 src/sage/cpython/__init__.py                           # OK, 1 distro sagemath-objects
       2 src/sage/sat/converters/__init__.py
       4 src/sage/sat/solvers/__init__.py
       2 src/sage/matroids/__init__.py
     114 src/sage/rings/polynomial/pbori/__init__.py            # OK, 1 distro sagemath-brial
       2 src/sage/rings/polynomial/__init__.py            #32509
      10 src/sage/modules/with_basis/__init__.py                # OK, 1 distro sagemath-categories
       2 src/sage/structure/__init__.py                         # OK, 1 distro sagemath-objects
      29 src/sage/categories/__init__.py                  #32508
       2 src/sage/media/__init__.py                             # deprecated

Tickets:

Related:

CC: @tscrim @pjbruin @kiwifb @kliem @dcoudert

Component: refactoring

Reviewer: Michael Orlitzky

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

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