I did pip install passagemath-graphs and when I then run
from sage.all__sagemath_graphs import *
g = Graph({
0: [1, 2],
1: [0, 2],
2: [0, 1, 3],
3: [2]
})
aut = g.automorphism_group()
print(aut.order())
I get ModuleNotFoundError: No module named 'sage.groups.perm_gps.permgroup'
This code works when I do pip install passsagemath-standard.
Is this intended behavior? If yes, is there a way to automatically determine which additional pip install’s I have to do? I am trying to minimize the amount of installed packages (that is, avoid installing passsagemath-standard).
Great question. Several complementary answers:
1 Like
Thanks a lot from this prompt answer, and great to see this getting more user friendly. Great!
So, if I understand correctly, pip install passagemath-graphs[groups] should work for this example. However, it doesn’t for me. I also tried pip install passagemath-graphs[groups, test].
I get:
File "sage/groups/perm_gps/permgroup_element.pyx", line 137, in init sage.groups.perm_gps.permgroup_element
ImportError: cannot import name libgap
This is the list of passagemath packages that are installed now:
passagemath-categories 10.5.42
passagemath-environment 10.5.42
passagemath-gap 10.5.42
passagemath-graphs 10.5.42
passagemath-groups 10.5.42
passagemath-modules 10.5.42
passagemath-nauty 10.5.42
passagemath-objects 10.5.42
passagemath-repl 10.5.42
Confirmed; I’ll post a workaround.
This works with the current release; note the extra import.
$ pipx run --pip-args="--prefer-binary" --spec "passagemath-graphs[gap,test]" python
Python 3.11.8 (main, Feb 6 2024, 21:21:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.all__sagemath_graphs import *
>>> from sage.all__sagemath_gap import *
>>> g = Graph({
... 0: [1, 2],
... 1: [0, 2],
... 2: [0, 1, 3],
... 3: [2]
... })
>>> aut = g.automorphism_group()
>>> print(aut.order())
2
1 Like
Thanks a lot!
Strange (to me) that the extra import is not needed if I install ‘passagemath-standard’.
Thanks for the report. Well, these effects of import cycles in the Sage library are quite complex.
More specifically, the main purpose of modules such as sage.all__sagemath_graphs is to set up the global namespace for the purpose of doctesting; these modules use try…except to load sage.all__... packages of various relevant extras. When passagemath-standard is installed, this can lead to the preloading of sage.all__sagemath_gap.
Thanks for clarifying. So sage.all__sagemath_graphs finds some package X installed by passagemath-standard, which gets imported, which in turn imports sage.all__sagemath_gap.
I am grateful you are embarking on the huge task of disentangling Sage. I guess this issue of required imports depending on what is installed just means this disentangling is not yet fully complete.
EDIT: Ah, I see that this is exactly what PR 1027 resolves for this case.
Yes, there’s some remaining technical debt from 20 years of monolithic development, even after 5 years of modularization work.
pip install passagemath-graphs[groups] now works
The original example doesn’t yet work for me. I get
ModuleNotFoundError: No module named 'sage.misc.sage_eval'
This is the output of pip list
Package Version
----------------------- -------
cysignals 1.12.3
Cython 3.1.2
gmpy2 2.2.1
memory_allocator 0.1.4
mpmath 1.3.0
passagemath-categories 10.5.43
passagemath-environment 10.5.43
passagemath-gap 10.5.43
passagemath-graphs 10.5.43
passagemath-groups 10.5.43
passagemath-modules 10.5.43
passagemath-nauty 10.5.43
passagemath-objects 10.5.43
pip 23.0.1
setuptools 65.5.0
Only after manually installing passagemath-repl it works.
Thanks for testing! I was just fighting against similar sage_eval-related issues, I’ll investigate.
Edit: I’ve opened Eliminate use of `sage_eval` · Issue #1041 · passagemath/passagemath · GitHub
1 Like