Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mkoeppe opened this issue Sep 10, 2021 · 21 comments
Closed

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Sep 10, 2021

(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

@mkoeppe mkoeppe added this to the sage-9.5 milestone Sep 10, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Sep 13, 2021

comment:6

A serious case:

$ cat src/sage/rings/polynomial/__init__.py
# Resolve a cyclic import
import sage.rings.convert.mpfi

We need to get rid of this one -- sage.rings.polynomial must become a namespace package

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Sep 13, 2021

comment:9

Replying to @mkoeppe:

A serious case:

$ cat src/sage/rings/polynomial/__init__.py
# Resolve a cyclic import
import sage.rings.convert.mpfi

We need to get rid of this one -- sage.rings.polynomial must become a namespace package

This one was added it #25848 ("Some preparations for binding=True") for a stalled effort in #22747/#26254

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Oct 20, 2021

comment:11

We can close this meta-ticket because it only tracks one open ticket.

@mkoeppe mkoeppe removed this from the sage-9.5 milestone Oct 20, 2021
@tscrim
Copy link
Collaborator

tscrim commented Oct 20, 2021

comment:12

I think it would be good to keep it open until the final ticket is done.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@orlitzky
Copy link
Contributor

orlitzky commented Dec 1, 2021

Author: Michael Orlitzky

@orlitzky
Copy link
Contributor

orlitzky commented Dec 1, 2021

comment:18

Everything in the "Tickets:" list has been closed: fixed.

@orlitzky
Copy link
Contributor

orlitzky commented Dec 1, 2021

Reviewer: Michael Orlitzky

@orlitzky
Copy link
Contributor

orlitzky commented Dec 1, 2021

Changed author from Michael Orlitzky to none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants