Is sagecell python3-ready?

63 views
Skip to first unread message

Kwankyu Lee

unread,
Mar 7, 2019, 7:35:26 PM3/7/19
to sage-cell
Hi Andrey,

Sage itself is expected to switch to python3, perhaps in this year. What is the status of sagecell in this regard? Would it require much work?


Kwankyu 

Andrey Novoseltsev

unread,
Mar 7, 2019, 8:19:19 PM3/7/19
to sage-cell
I hope not and apart from interacts I am pretty sure that it will not be difficult for me. For interacts I just hope that there will be no hard issues, but it is the part that I didn't rewrite yet ;-)

Kwankyu Lee

unread,
Mar 7, 2019, 10:45:38 PM3/7/19
to sage-cell


On Friday, March 8, 2019 at 10:19:19 AM UTC+9, Andrey Novoseltsev wrote:
I hope not and apart from interacts I am pretty sure that it will not be difficult for me.

Nice.
 
For interacts I just hope that there will be no hard issues, but it is the part that I didn't rewrite yet ;-)

You may post here what are the hard issues, if you want others to help. 

Thank you as always.

kcrisman

unread,
Mar 21, 2019, 9:29:14 AM3/21/19
to sage-cell
Along these lines, it occurs to me that if/when Sage switches to Py3, there will be a lot of broken permalinks - especially if people used "print blah" instead of "print(blah)".  Is there any way to avoid this?  Alternately, what would a good way to warn people of this when a permalink is clicked on?  (I don't know what errors Py3 raises for stuff only valid in Py2; presumably one could watch the output for those errors.)
- kcrisman

William Stein

unread,
Mar 21, 2019, 9:51:34 AM3/21/19
to kcrisman, sage-cell
On Thu, Mar 21, 2019 at 6:29 AM kcrisman <kcri...@gmail.com> wrote:
>
> Along these lines, it occurs to me that if/when Sage switches to Py3,

"when", I hope! E.g., I personally always use the python3 version of
Sage, and it works well for me.

> there will be a lot of broken permalinks - especially if people used "print blah" instead of "print(blah)". Is there any way to avoid this?

It could be avoided using the preparser, with a deprecation warning
printed. There's probably a trac ticket about this somewhere.

William

kcrisman

unread,
Mar 21, 2019, 11:09:58 AM3/21/19
to sage-cell
Thanks, good point.  I forwarded this subtopic to sage-devel in case there is more commentary there. 

Andrey Novoseltsev

unread,
Mar 21, 2019, 11:48:20 AM3/21/19
to sage-cell
It is in no way specific to permalinks - all webpages with cells in Python2 will be broken. And things do get broken gradually with new versions of Sage as well. So it would be nice if Sage had good explanations and warnings for what is happening, if Python3 itself does not have it, but as far as SageMathCell is concerned I see my task only in transitioning smoothly to Python3 whenever Sage will do it.

Alternatively, we can let sagecell.sagemath.org run the last Python2 version for a year or so, while switching activity and all documentation for newcomers to sagecell3.sagemath.org. After a year sagecell. can redirect to sagecell3. so old stuff that does not depend on Python2 still works. But I am not at all convinced that there is much point in such efforts.

Unicode-wise permalinks handling was probably the trickiest, just because it is a bit convoluted how things are sent around, and it seems that I've succeeded in switching it to Python3. The rest should not be particularly difficult, I think, but switching to new Tornado will require some work. We are currently using version 4, 5 deprecated a bunch of stuff we rely on, and the current 6 has removed it, so while permalinks code worked with Python3, I had to stick to Tornado 5 for now.

kcrisman

unread,
Mar 21, 2019, 8:49:14 PM3/21/19
to sage-cell


On Thursday, March 21, 2019 at 11:48:20 AM UTC-4, Andrey Novoseltsev wrote:
It is in no way specific to permalinks - all webpages with cells in Python2 will be broken. And things do get broken gradually with new versions of Sage as well. So it would be nice if Sage had good explanations and warnings for what is happening, if Python3 itself does not have it, but as far as SageMathCell is concerned I see my task only in transitioning smoothly to Python3 whenever Sage will do it.

Too true, of course, but the difference with the links is that it is less likely that someone will check a link e.g. in a Stackoverflow or ask.sagemath question than if someone in theory owns a web page.  For instance, I hope PreTeXt will have some possible editing tool to help their books; but other cases will have to catch as catch can. 

Jorge Garcia

unread,
Mar 21, 2019, 8:58:14 PM3/21/19
to kcrisman, sage-cell
The switch from py2 to py3 on Sagecell is a concern of mine as well. I have lots of permalinks on the side bar of my blog,

These links are there for my students (notes from class) as well as participants in my conference presentations where I'm always encouraging Math teachers and professors to use Sage in class instead of graphing calculators.

Regards,
A. Jorge Garcia

--
You received this message because you are subscribed to the Google Groups "sage-cell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/ad381f14-9589-426e-a322-9a2db25111f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrey Novoseltsev

unread,
Mar 21, 2019, 11:40:41 PM3/21/19
to sage-cell
These are valid points, yet since maintaining Python2 site/kernel/version/whatever indefinitely is impossible and sooner or later we will have to break things, I am still not convinced that there is much benefit in delaying it as much as possible. I am, however, quite sure that the transition has to happen between the terms as much as possible. If Sage itself switches in the middle, then I'll just hold the public servers for a few months.

It is, however, possible to warn the users somehow, e.g. we can put some wording on the root page or even something under the output window (where we have "Help | Powered by SageMath" at the moment). Something to encourage people to write Python3 compatible code, be aware of the upcoming transition, and I can look into setting up a test server that will run current Sage in Python3 mode.

More concrete (and actionable ;-)) ideas are very welcome, as well as pull requests!

William Stein

unread,
Mar 21, 2019, 11:47:25 PM3/21/19
to Andrey Novoseltsev, sage-cell
What if

print "blah"

in Sage started showing a deprecation warning as of the next release?

Is there really much else besides print statements that people are
likely to write in the sage cell server that is Python2 only? I
can't think of anything else at all off the top of my head... I
realize that much of the Python2-->Python3 switch involves handling of
strings/unicode/bytes and change in the way rich comparison works.
However, I bet neither of those big landmines in the sage library are
used in typical applications of the sage cell server.

-- William

>
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/c274d897-4f3b-4fe2-9900-8ccf36b01d0b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
William (http://wstein.org)

Andrey Novoseltsev

unread,
Mar 22, 2019, 12:00:00 AM3/22/19
to sage-cell
On Thursday, 21 March 2019 21:47:25 UTC-6, William Stein wrote:
What if

  print "blah"

in Sage started showing a deprecation warning as of the next release?

Is there really much else besides print statements that people are
likely to write in the sage cell server that is Python2 only?    I
can't think of anything else at all off the top of my head...   I
realize that much of the Python2-->Python3 switch involves handling of
strings/unicode/bytes and change in the way rich comparison works.
However, I bet neither of those big landmines in the sage library are
used in typical applications of the sage cell server.

 -- William
 
That is also a very valid point and I think it is wise to do something in Sage itself to cover all interfaces and use cases.

Note that issues with print are somewhat similar to issues with "html(...)" which a few years back stopped displaying stuff by itself requiring "show(html(...))" or something similar. There were some complaints and problems with this, but we survived!

kcrisman

unread,
Mar 22, 2019, 8:53:15 PM3/22/19
to sage-cell
Yes, agreed here.  By far the greatest Py3 incompatibility will be print - though that will be a lot bigger of an issue than the pretty_print(html(...)) one.  I would certainly be in support of a deprecation of the print statement within Sage, if feasible, once we really have Sage-the-distribution working fully with Py3 and the transition is only a matter of time.  We'd probably want to have various pinned posts, FAQ updates - and so forth.  

Timing for the true switchover (i.e. no more Py2 in Sage cell)?  I would recommend it were over the Northern hemisphere summer.  Probably June 1 is a good date - I'd say 2020, but I know others are itching for earlier.  For people with high teaching loads, changing a lot of stuff over winter break is not feasible.  I know not every country has that academic schedule, many people in the States even teach summer courses ... but if there had to be a time, that probably should be it.

For Sage itself, ironically, people can just not upgrade.  Timing is part of it, but since we still get lots of requests for support of even 5.x and 6.x that won't be as bad.

William, would Sage pre-Py3 kernels be available on CoCalc for a while perhaps after a Sage switch?  Just curious.  Could be a useful use of an email blast to all your customers ...

All of this is train of thought, so if there are dumb ideas, no worries, just trying to unload all of them at the end of the week :) Thanks for always being so on top of this, Andrey.

William Stein

unread,
Mar 22, 2019, 10:47:54 PM3/22/19
to kcrisman, sage-cell
On Fri, Mar 22, 2019 at 5:53 PM kcrisman <kcri...@gmail.com> wrote:
>
>
>>>
>>> print "blah"
>>>
>>> in Sage started showing a deprecation warning as of the next release?
>>>
>>> Is there really much else besides print statements that people are
>>> likely to write in the sage cell server that is Python2 only? I
>>> can't think of anything else at all off the top of my head... I
>>> realize that much of the Python2-->Python3 switch involves handling of
>>> strings/unicode/bytes and change in the way rich comparison works.
>>> However, I bet neither of those big landmines in the sage library are
>>> used in typical applications of the sage cell server.
>>>
>>> -- William
>>
>>
>> That is also a very valid point and I think it is wise to do something in Sage itself to cover all interfaces and use cases.
>>
>> Note that issues with print are somewhat similar to issues with "html(...)" which a few years back stopped displaying stuff by itself requiring "show(html(...))" or something similar. There were some complaints and problems with this, but we survived!
>
>
> Yes, agreed here. By far the greatest Py3 incompatibility will be print - though that will be a lot bigger of an issue than the pretty_print(html(...)) one. I would certainly be in support of a deprecation of the print statement within Sage, if feasible, once we really have Sage-the-distribution working fully with Py3 and the transition is only a matter of time. We'd probably want to have various pinned posts, FAQ updates - and so forth.
>
> Timing for the true switchover (i.e. no more Py2 in Sage cell)? I would recommend it were over the Northern hemisphere summer. Probably June 1 is a good date - I'd say 2020, but I know others are itching for earlier.

Python 2 is officially "end of lifed" far before June 2020:
https://pythonclock.org/

This could have real impacts, e.g., pip will no longer be supported
(only pip3), and that will matter when some security exploit comes
along, or if pypi stops supporting the repos.

> For people with high teaching loads, changing a lot of stuff over winter break is not feasible. I know not every country has that academic schedule, many people in the States even teach summer courses ... but if there had to be a time, that probably should be it.
>
> For Sage itself, ironically, people can just not upgrade. Timing is part of it, but since we still get lots of requests for support of even 5.x and 6.x that won't be as bad.
>
> William, would Sage pre-Py3 kernels be available on CoCalc for a while perhaps after a Sage switch? Just curious. Could be a useful use of an email blast to all your customers ...

Yes. I think we will still have a few sage-8.x versions for a long
time, but with no updates. Right now, we have 8.2, 8.3, 8.4, 8.5,
8.6, etc., and it's not hard to just keep older versions around. It's
only hard when we upgraded from Ubuntu 18.04 to whatever big version
we upgrade to next and have to rebuild everything. Even then, we can
keep older 18.04-based images for a while...

--
William (http://wstein.org)

kcrisman

unread,
Mar 23, 2019, 9:48:14 PM3/23/19
to sage-cell

> Timing for the true switchover (i.e. no more Py2 in Sage cell)?  I would recommend it were over the Northern hemisphere summer.  Probably June 1 is a good date - I'd say 2020, but I know others are itching for earlier.

Python 2 is officially "end of lifed" far before June 2020:
https://pythonclock.org/

Hmm.  I wonder if Sage will be fully Py3 ready by no later than July this summer?  But that is not for this discussion forum. 

 
> William, would Sage pre-Py3 kernels be available on CoCalc for a while perhaps after a Sage switch?  Just curious.  Could be a useful use of an email blast to all your customers ...

Yes.  I think we will still have a few sage-8.x versions for a long
time, but with no updates.    Right now, we have 8.2, 8.3, 8.4, 8.5,
8.6, etc., and it's not hard to just keep older versions around.  It's
only hard when we upgraded from Ubuntu 18.04 to whatever big version
we upgrade to next and have to rebuild everything.   Even then, we can
keep older 18.04-based images for a while...


Good to know. 
Reply all
Reply to author
Forward
0 new messages