Am I understanding correctly that "import mpmath" should behave differently when called in a sage context rather than in a straight python context, and that (in case of a system python) it may be possible that within the same python installation both behaviours are desirable on occasion?
>From what I understand, python packages upon import may sometime probe availability of certain other packages (by trying to import them) and may fall back on other options if they are not. This allows certain "optional dependencies". In this case, it doesn't sound like an optional dependencies, but really as two different modes for mpmath. It seems to me one should select between those modes explicitly; whether through an environment variable or some flag inside python. Design-wise this causes another problem: if a python package relies on mpmath in non-sage mode, then you can now not use it inside sage. That's an unfortunate incompatibility and something one might generally want to avoid. On Thursday, March 18, 2021 at 12:30:46 AM UTC-7 François Bissey wrote: > Hi all, > > I was wondering if there was a way to figure if a module from one > package is imported from another one and which one at that. > > This is quite relevant to sage-on-distros. mpmath-1.2.0+ tries > to figure out if it is called from sage by detecting if SAGE_ROOT > is defined. Assuming that if it is this is a sage install. > Some reasoning at > https://github.com/fredrik-johansson/mpmath/pull/466 > the reasoning in question disregarded the fact that a sage-on-distro > package would also likely use a system mpmath. > > But mpmath developers don’t want to just use sage if it is installed. > Only if it is explicitly required and available or because they > mpmath is called from sage. > > MPMATH_SAGE could be set in the sage executable or sage-env but > that would cover the case where you import sage directly from > python. Something that has been doable on sage-on-(some)-distros > for years and is quite doable in villa sage these days. > > So I am wondering if there is a python way to say to mpmath, you > have been imported from sage. > > Cheers, > François -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/bf623741-2045-4493-aef5-949ee85d1cb2n%40googlegroups.com.