Opened 2 years ago

Closed 13 months ago

Last modified 13 months ago

#28000 closed task (fixed)

For Sage 9.2: Remove python 2 support from sagelib

Reported by: embray Owned by:
Priority: major Milestone: sage-9.2
Component: python3 Keywords: days101
Cc: gh-timokau, chapoton, dimpase Merged in:
Authors: Erik Bray Reviewers: Dima Pasechnik
Report Upstream: N/A Work issues:
Branch: f368e32 (Commits, GitHub, GitLab) Commit:
Dependencies: #26403, #28660 Stopgaps:

Status badges

Description (last modified by mkoeppe)

Python 3 support (#15530) was completed for Sage 9.0 (thanks in particular to the leadership of Frédéric Chapoton). Official support for Python 2.7 by the CPython core developers is ending January 1, 2020.

To enable major package upgrades and other changes that require Python 3.x (#29141), this ticket removes Python 2 support in Sage for Sage 9.2.

Change History (42)

comment:1 Changed 2 years ago by embray

  • Description modified (diff)

comment:2 Changed 2 years ago by gh-timokau

  • Cc gh-timokau added

comment:3 Changed 2 years ago by jhpalmieri

What needs to be done for this ticket?

comment:4 Changed 2 years ago by embray

Go through and remove all hacks related to supporting Python 2. It will be interesting to see how big a change it takes even now. It's rather early to go through and do that in earnest, but it would be fun to just try and see what it takes.

comment:5 Changed 2 years ago by slelievre

  • Keywords days101 added

comment:6 Changed 2 years ago by jhpalmieri

One example: #27696 (remove the doctesting hack for "long", which just converts it to "int" when using Python 3.

comment:7 Changed 2 years ago by slelievre

Also, this ticket can be set as a dependency for other tickets that depend on the removal of Python 2 support. Many dependency upgrades will depend on that.

Might it make sense to migrate the whole Jupyter part to Python3-only versions before completely removing Python 3 support? Even when building Sage for Python 2, we ship Python 3 too anyway.

comment:8 Changed 2 years ago by embray

I made some progress at days101 removing all dependency on the six module for Python 2/3 support and that alone was a HUGE change (and not even quite finished yet). Will post a branch once I'm done with that.

comment:9 Changed 22 months ago by embray

  • Authors set to Erik Bray
  • Branch set to u/embray/python3/ticket-28000

Here's some of my progress on this so far: Probably one of the biggest, most pervasive steps, being complete removal of dependency on six.

Of course, this step is optional--we can keep using six while otherwise dropping support for Python 2. But this makes it quite explicit.

It's pretty hard to avoid making a patch bomb of this. It's not all bad though--I started this months ago, and then once I got it finished I rebased on current develop and only had about a dozen minor merge conflicts.

comment:10 Changed 22 months ago by git

  • Commit set to 8f3cacb0c658f7fa5eb66fdf799b33096292cd1f

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

8f3cacbTrac #28000: Remove sagelib dependency on six

comment:11 Changed 22 months ago by git

  • Commit changed from 8f3cacb0c658f7fa5eb66fdf799b33096292cd1f to 736c7a288a18fec38a76d51b1982caf747b34fa0

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

736c7a2One Python 2-specific block that did not use six.PY2.

comment:12 Changed 21 months ago by jhpalmieri

Other tasks:

  • remove or revise the doctests labeled # py2. Ideally, all such tests should be evaluated on a case-by-case basis, some should just be removed, but perhaps some should be modified to work with Python 3.
  • #28426: with a Python 3 build, do not build Python 2.
  • remove some packages which are only necessary with Python 2: typing (#28499) is the only one I know of currently, but I wouldn't be surprised if there were others.
  • remove the legacy Sage notebook — at least, I don't think it works with Python 3 now, and I don't think anyone is working on it. This means we should deprecate it ASAP. (#25837)

comment:13 Changed 21 months ago by embray

My branch for this has some other in-progress changes that it seems I haven't pushed yet. I'll do so next time I rebase this branch.

comment:14 Changed 21 months ago by embray

Oh right, one of the changes I started was to remove unnecessary from __future__ imports, but it seems until we have #26403, to my slight surprise, some of them are still needed in Cython modules, e.g. to have the print() function by default.

comment:15 Changed 21 months ago by embray

  • Dependencies set to #26403

comment:16 Changed 21 months ago by git

  • Commit changed from 736c7a288a18fec38a76d51b1982caf747b34fa0 to 50b8951838bccf334eb1bbcc6175c97f72e3ad84

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

d2c4427Trac #28000: Remove sagelib dependency on six
aab5d3bOne Python 2-specific block that did not use six.PY2.
50b8951Trac #28000: Get rid of most __nonzero__ references and/or replace them with __bool__

comment:17 Changed 21 months ago by embray

Rebased, but no guarantee there are no new bugs or new uses of six I didn't miss. I didn't check yet.

comment:18 Changed 21 months ago by git

  • Commit changed from 50b8951838bccf334eb1bbcc6175c97f72e3ad84 to 1f6a41d6ef8ea07cf35c94bef5439d31f9f22943

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

972f431Trac #28000: Remove sagelib dependency on six
4c35164One Python 2-specific block that did not use six.PY2.
1f6a41dTrac #28000: Get rid of most __nonzero__ references and/or replace them with __bool__

comment:19 Changed 21 months ago by embray

Updated again after removing two new uses of six that have since appeared.

comment:20 Changed 20 months ago by slelievre

  • Dependencies changed from #26403 to #26403, #28660

comment:21 Changed 19 months ago by jhpalmieri

Do we remove all doctests tagged # py2 here or on a separate ticket?

comment:22 Changed 19 months ago by embray

You could do it here, or a separate ticket (and make it a dependency of this ticket). It's going to be a patch bomb no matter what, but I don't see the harm in trying to split it up wehre possible.

comment:23 Changed 18 months ago by git

  • Commit changed from 1f6a41d6ef8ea07cf35c94bef5439d31f9f22943 to 0e37a950824f824f06c184c50552888984e68f07

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b4fa8dbTrac #28000: Remove sagelib dependency on six
0ff5ac8Trac #28000: One Python 2-specific block that did not use six.PY2.
0e37a95Trac #28000: Get rid of most __nonzero__ references and/or replace them with __bool__

comment:24 Changed 18 months ago by embray

Rebased on 9.0

comment:25 Changed 17 months ago by mkoeppe

  • Description modified (diff)

comment:26 Changed 14 months ago by mkoeppe

  • Cc chapoton dimpase added
  • Description modified (diff)
  • Milestone changed from sage-wishlist to sage-9.2

comment:27 Changed 14 months ago by mkoeppe

Needs rebasing!

comment:28 Changed 14 months ago by mkoeppe

  • Summary changed from Remove python 2 support to For Sage 9.2: Remove python 2 support from sagelib

comment:29 Changed 13 months ago by jhpalmieri

Related: #27826

comment:30 Changed 13 months ago by jhpalmieri

  • Branch changed from u/embray/python3/ticket-28000 to u/jhpalmieri/python3/ticket-28000

comment:31 Changed 13 months ago by jhpalmieri

  • Commit changed from 0e37a950824f824f06c184c50552888984e68f07 to f368e3288aa51a7cb0eac7b28145986eb4baaa8a

Rebased. I haven't seen activity from embray for a while. Perhaps this is ready for review?


New commits:

f368e32trac 28000: rebase commits from Erik M. Bray <erik.bray@lri.fr>:

comment:32 Changed 13 months ago by mkoeppe

  • Status changed from new to needs_review

Let's see if this finds a reviewer

comment:33 Changed 13 months ago by dimpase

  • Reviewers set to Dima Pasechnik

testing.

comment:34 follow-up: Changed 13 months ago by dimpase

  • Status changed from needs_review to positive_review

OK, this makes sense and appears to work. A long, but straightforward patch, also touching quite a bit of whitespace (which probably could have waited for another place, but OK).

Should removing Python2 spkg be done elsewhere?

comment:35 in reply to: ↑ 34 Changed 13 months ago by mkoeppe

Replying to dimpase:

Should removing Python2 spkg be done elsewhere?

Yes, see #29141 (Meta-ticket: Remove Python 2 support for Sage 9.2; upgrades enabled by the removal)

comment:36 Changed 13 months ago by vbraun

  • Branch changed from u/jhpalmieri/python3/ticket-28000 to f368e3288aa51a7cb0eac7b28145986eb4baaa8a
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:37 Changed 13 months ago by gh-timokau

  • Commit f368e3288aa51a7cb0eac7b28145986eb4baaa8a deleted

\(^O^)/

Hopefully the divergence between sage-the-distribution and sage-on-distro will decrease now and packaging will become simpler again.

comment:38 Changed 13 months ago by embray

Thanks for finally getting this ticket merged! Sorry I haven't had much time to work on it. As others have noted this does not take care of all tasks related to dropping Python 2 support--it was just me doing as much as I could in one place. Took hours!

comment:39 Changed 13 months ago by vbraun

This breaks on Python 3.5, I've created #29753 for that

comment:40 Changed 13 months ago by jhpalmieri

Does anyone know of any docker setups from tox.ini that have Python 3.5?

comment:41 Changed 13 months ago by dimpase

Python 3.5 will be gone in Sept, why would wr spend time trying to support it?

comment:42 Changed 13 months ago by gh-mwageringel

This accidentally broke the Macaulay2 interface. Follow up at #29759 with a trivial fix.

Note: See TracTickets for help on using tickets.