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

Call sympy_init() at sympy import #24067

Closed
rwst opened this issue Oct 19, 2017 · 45 comments
Closed

Call sympy_init() at sympy import #24067

rwst opened this issue Oct 19, 2017 · 45 comments

Comments

@rwst
Copy link

rwst commented Oct 19, 2017

sympy_init() enables conversion of SymPy objects. It is called with the first initialization of a SympyConverter, i.e. with Expression._sympy_(). Better is to only call it once with any import of SymPy.

We should also revert the patch added in #24238.

CC: @jdemeyer @isuruf @infinity0 @egourgoulhon

Component: interfaces

Stopgaps: #24238

Branch/Commit: u/fbissey/24067 @ 67e6156

Reviewer: François Bissey

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

@rwst rwst added this to the sage-8.1 milestone Oct 19, 2017
@rwst
Copy link
Author

rwst commented Oct 19, 2017

Branch: u/rws/24067

@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Oct 19, 2017

Commit: 40b3432

@rwst
Copy link
Author

rwst commented Oct 19, 2017

Last 10 new commits:

8215d37Merge branch 'develop' into tmp05
7899ea920204: convert SymPy abstract functions
b261ec323923: fix doctest
5010acfMerge branch 'u/rws/23923' of git://trac.sagemath.org/sage into t/20204/20204
14b1c5220204: more doctests
9c4119a16801: Conversion of psi(x,y) to/from SymPy
d5c60e324062: pkg version/chksum
1cbc23e24062: remove obsolote patches; adapt remaining
94f359f24062: doctest fixes
40b343224067: Call sympy_init() at sympy import

@rwst
Copy link
Author

rwst commented Oct 19, 2017

Dependencies: #24062

@rwst
Copy link
Author

rwst commented Oct 19, 2017

Author: Ralf Stephan

@jdemeyer
Copy link

Changed branch from u/rws/24067 to u/jdemeyer/24067

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@jdemeyer
Copy link

Changed dependencies from #24062 to none

@jdemeyer
Copy link

comment:4

Rebased to 8.1.rc2 for easier reviewing.


New commits:

a97c32f24067: Call sympy_init() at sympy import

@jdemeyer
Copy link

Changed commit from 40b3432 to a97c32f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 19, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

0d4f310Remove explicit sympy_init() calls
893b03dCheck that sympy is not imported

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 19, 2017

Changed commit from a97c32f to 893b03d

@jdemeyer
Copy link

comment:6

Positive review to your first commit. I added two follow-up commits, please review.

@kiwifb
Copy link
Member

kiwifb commented Nov 19, 2017

comment:7

I am concerned that the sympy patch cannot be sent upstream as is. It makes sage a dependency of sympy for it to even start. I doubt that's acceptable.

@tscrim
Copy link
Collaborator

tscrim commented Nov 19, 2017

comment:8

What about just adding sympy_init() to the end of the interface file?

@kiwifb
Copy link
Member

kiwifb commented Nov 19, 2017

comment:9

Replying to @tscrim:

What about just adding sympy_init() to the end of the interface file?

I would favor an all in sage solution to this. I am not against a push in sympy upstream but it has to be acceptable to them and that will certainly not be.

@rwst
Copy link
Author

rwst commented Nov 20, 2017

comment:10

Replying to @kiwifb:

I am concerned that the sympy patch cannot be sent upstream as is. It makes sage a dependency of sympy for it to even start. I doubt that's acceptable.

To make it work the __init__ file needs to know if it is imported from sage. I'm no Python expert but I doubt that's possible. A solution to the design problem would be not to have _sage_ member functions but a global sage(...) method.

Additions LGTM.

@rwst
Copy link
Author

rwst commented Nov 20, 2017

Changed reviewer from Jeroen Demeyer to Jeroen Demeyer, Ralf Stephan

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:11

What about guarding it with a try: expect: block so it can start gracefully if sage is not present (and therefore not used).

@jdemeyer
Copy link

comment:12

fbissey: I am assuming that this ticket would only be merged in some 8.2.beta of Sage. Since this branch here does solve the immediate problem of docbuilding, I suggest to merge this patch as-is and in the mean time work on a solution for upstream.

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:13

Replying to @jdemeyer:

fbissey: I am assuming that this ticket would only be merged in some 8.2.beta of Sage. Since this branch here does solve the immediate problem of docbuilding, I suggest to merge this patch as-is and in the mean time work on a solution for upstream.

I was hoping a more conciliatory attitude and hadn't removed the positive review. This is now back to need_work. This is just un-acceptable to sage-on-distro this close to release.

We would have to make our own version of the patch that does the "right thing" (TM) instead of a "sloppy job" (TM) just because we can and feel in too much of a hurry for 3 more lines of code, anyway so let's do it right now instead.

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

Changed commit from 893b03d to 67e6156

@infinity0
Copy link
Mannequin

infinity0 mannequin commented Nov 20, 2017

comment:16

@kiwifb, that last commit, while much better than what was before, will still force all users of sympy to import sage into their python program, as long as sage is installed.

A better method might be something like this instead:

if 'sage.XXXX' in sys.modules:
    from sage.interfaces.sympy import sympy_init
    sympy_init()

where XXXX is some module that sage always imports. So the patch is only activated if sage is already imported.

This might be more acceptable to upstream as well.

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:17

@infinity0 I agree that is not perfect - for exactly the reason you mention - but that's the best I could come up with without more complication. Feel free to improve it, that's one of the reason I called other packagers on this ticket.

@infinity0
Copy link
Mannequin

infinity0 mannequin commented Nov 20, 2017

comment:18

So what about using if ... in sys.modules?

If you additionally need to support the use-case where a third-party program/library really has to import sympy then later import sage (I can't imagine why), then the if ... in sys.modules logic needs to also be added to a sage module but in reverse - i.e. check if sympy is already imported, and activate the patch if so.

In any case, we're unlikely to patch sympy in Debian like this, unless they indicate that they would already accept it. (Someone else maintains it, the situation is outside of my control.) Could you/someone else file a upstream ticket before releasing this in Sage?

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:19

Replying to @infinity0:

So what about using if ... in sys.modules?

I can make that change, but I am calling it a night :)

If you additionally need to support the use-case where a third-party program/library really has to import sympy then later import sage (I can't imagine why), then the if ... in sys.modules logic needs to also be added to a sage module but in reverse - i.e. check if sympy is already imported, and activate the patch if so.

In any case, we're unlikely to patch sympy in Debian like this, unless they indicate that they would already accept it. (Someone else maintains it, the situation is outside of my control.) Could you/someone else file a upstream ticket before releasing this in Sage?

+1, @rwst do you have an upstream issue for this? There definitely should be.

@rwst
Copy link
Author

rwst commented Nov 20, 2017

comment:20

Replying to @kiwifb:

+1, @rwst do you have an upstream issue for this? There definitely should be.

I'll open one if this ticket has code that all agree on. Set at least needs review so we have the patchbots.

@jdemeyer
Copy link

comment:21

Replying to @kiwifb:

This is just un-acceptable to sage-on-distro

Even for a beta version of Sage? I agree that it would be unacceptable in a released version.

@jdemeyer
Copy link

comment:22

If we're going to submit a patch upstream, we shouldn't rush.

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

Stopgaps: #24238

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:24

Replying to @jdemeyer:

Replying to @kiwifb:

This is just un-acceptable to sage-on-distro

Even for a beta version of Sage? I agree that it would be unacceptable in a released version.

Come on. We are at rc2. We are just ironing bugs, that would end up in the released 8.1 unless you moved the milestone to 8.2.

@tscrim
Copy link
Collaborator

tscrim commented Nov 20, 2017

comment:25

I would be surprised if this was positively reviewed it would make it into 8.1 (unless we set it as a blocker).

@kiwifb
Copy link
Member

kiwifb commented Nov 20, 2017

comment:26

Because of the troubles building the documentation reported on sage-release, one of #24238 or this ticket has to be a blocker in my opinion. I came to this ticket after Jeroen commented on #24238 that this ticket should be the one with the fix.

@rwst
Copy link
Author

rwst commented Nov 21, 2017

comment:27

The third option would be a revert ticket for the manifolds changes that introduced it.

@jdemeyer
Copy link

comment:28

Replying to @kiwifb:

Because of the troubles building the documentation reported on sage-release, one of #24238 or this ticket has to be a blocker in my opinion. I came to this ticket after Jeroen commented on #24238 that this ticket should be the one with the fix.

#24238 is a blocker. That ticket is also simple enough that it shouldn't cause problems.

@jdemeyer
Copy link

comment:29

Replying to @kiwifb:

We are just ironing bugs, that would end up in the released 8.1 unless you moved the milestone to 8.2.

No. I'm pretty sure that the release manager only merges "blocker" tickets once an rc has been released. The whole point of an "rc" is that it should be close to a release and you don't want to merge random tickets at that point.

Anyway, that doesn't matter anymore for this ticket.

@mkoeppe
Copy link
Member

mkoeppe commented Jul 6, 2021

Changed author from Ralf Stephan to none

@mkoeppe
Copy link
Member

mkoeppe commented Jul 6, 2021

Changed reviewer from Jeroen Demeyer, Ralf Stephan to none

@mkoeppe
Copy link
Member

mkoeppe commented Jul 6, 2021

comment:31

Time to close this bizarre ticket

@mkoeppe mkoeppe removed this from the sage-8.1 milestone Jul 6, 2021
@kiwifb
Copy link
Member

kiwifb commented Jul 6, 2021

comment:32

I am not remembering much about it but obviously it didn't make the cut then.

@kiwifb
Copy link
Member

kiwifb commented Jul 6, 2021

Reviewer: François Bissey

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

5 participants