Closed ohanar closed 4 years ago
First attempt to get scons
to install polybori
as a python 3.4 thing failed. SConstruct
is relying on the version of python running scons
as being the version you should use I think. That leads to a number of odd behavior and misdetections very fast.
Description changed:
---
+++
@@ -16,8 +16,8 @@
14. #15807 - upgrade mpmath to version 0.18
15. #15980 - meta-ticket for python3 compatibility of the sage library (stage 1)
16. #16052 - meta-ticket for python3 compatibility of the sage library (stage 2)
-17. upgrade scons to a version that supports python3 (does not yet exist) or get rid of scons (assuming #17854, scons is only used by polybori)
-18. upgrade polybori to a version that supports python3 (does not yet exist)
+17. #17854 - remove c_lib
+18. #18437 - fix polybori and python 3
19. #17607 - add python 3 package
---
fyi, I started working on an autotools based build system for polybori at https://github.com/ohanar/PolyBoRi/tree/autotools. I'll probably work on it a bit more next weekend during SD 64.25, but the important bits (the c++ libraries) are currently working with only a couple of hacks. What remains (for sage at least) is just a little cleanup and throwing in the bit of the python bindings we use. I've created #18437 for future discussion of polybori and python 3.
Changed dependencies from #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, pynac-0.3.8 to #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, #18537
Does now every standard package except polybori support Python 3?
I think so. The current pexpect
would be the other problematic one but the current has been patched to use six
to support python 3 if we don't upgrade it to 3.3 + patch (#10295).
Replying to @a-andre:
Replying to @jdemeyer:
Does now every standard package except polybori support Python 3?
The Sphinx release notes for 1.3b1 mention
Add support for Python 3.4.
So I assume this version is not supported by the Sphinx 1.2.2 which is currently shipped with Sage. #18497
That's odd, Gentoo permits you to build and install sphinx 1.2.2 against python 3.4 without any patch. It is a stable version so I'll assume that it passes its test suite at least with python 3.4. But going to 1.3.1 would be good anyway.
Replying to @jdemeyer:
Does now every standard package except polybori support Python 3?
Pynac doesn't really support Python 3 (it builds against Python 3, but it is almost certainly broken, since it can only really be tested when sage can be built against Python 3).
Changed dependencies from #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, #18537 to #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, #18537, #16052, #18437
Description changed:
---
+++
@@ -18,7 +18,8 @@
16. #16052 - meta-ticket for python3 compatibility of the sage library (stage 2)
17. #17854 - remove c_lib
18. #18437 - fix polybori and python 3
-19. #17607 - add python 3 package
+19. #18537 - fix Pynac at least building against python 3
+20. #17607 - add python 3 package
---
Description changed:
---
+++
@@ -26,9 +26,3 @@
Possibly relevant timeline from [PEP 373](https://www.python.org/dev/peps/pep-0373/):
Being the last of the 2.x series, 2.7 will have an extended period of maintenance. The current plan is to support it for at least 10 years from the initial 2.7 release. This means there will be bugfix releases until 2020.
-
-Planned future release dates:
-
-* 2.7.10 June 2015
-* beyond this date, releases as needed
-
Description changed:
---
+++
@@ -22,6 +22,15 @@
20. #17607 - add python 3 package
---
+How to try to make sage with python3:
+
+```
+export SAGE_PYTHON3=yes
+make build
+```
+(preferably inside a python3 virtualenv)
+
+---
Possibly relevant timeline from [PEP 373](https://www.python.org/dev/peps/pep-0373/):
Description changed:
---
+++
@@ -28,7 +28,6 @@
export SAGE_PYTHON3=yes
make build
-(preferably inside a python3 virtualenv)
Description changed:
---
+++
@@ -1,4 +1,4 @@
-In order to support python 3.3, the following needs to be fixed:
+In order to support python 3.6, the following needs to be fixed:
1. #15510 - upgrade to a newer version of setuptools
2. #15511 - upgrade to a newer version of rpy2
Changed ticket title since we're now targeting Python 3.6 at a minimum (though most of the Python 3 work could probably go back to older Python 3's since everything is still compatible with Python 2.7).
I guess we can leave this open as there are still 2 meta-tickets associated with it that are open...
Description changed:
---
+++
@@ -22,10 +22,11 @@
20. #17607 - add python 3 package
---
-How to try to make sage with python3:
+How to build sage with python3:
-export SAGE_PYTHON3=yes +make configure +./configure --with-python=3 make build
I recently ran the doctests on my python3 branch (which contains many fixes not in develop yet, though I've yet to incorporate all the existing open tickets for python3 which might lead to more improvements). I got roughly 540 failing modules.
Out of curiosity I thought I'd try a little experiment and ran the test log through the following:
$ sort logs/ptest.log | uniq -c | sort -nr
This just gives the text that appears most frequently in the test output. Obviously the top examples are generic things like "6461 Traceback (most recent call last):"
But beyond that there are some interesting things that might help prioritize things to fix (and maybe some of these are already fixed in open tickets). The top 20 error messages this brings up (excluding NameError
s) are:
470 TypeError: unhashable type: 'NCPolynomialIdeal'
360 TypeError: unhashable type: 'HyperellipticCurve_g2_rational_field_with_category'
229 TypeError: expected bytes, str found
196 TypeError: object of type 'map' has no len()
176 TypeError: 'dict_values' object does not support indexing
176 AttributeError: attribute '__dict__' of 'type' objects is not writable
(this one I know is #24786, so I'm going to try merging that into my python3 branch and see what that helps)122 TypeError: '>' not supported between instances of 'float' and 'NoneType'
115 TypeError: unhashable type: 'HyperellipticCurve_padic_field_with_category'
104 AttributeError: 'list' object has no attribute 'items'
94 TypeError: sequence item 0: expected str instance, bytes found
90 TypeError: unhashable type: 'ChowGroup_class_with_category'
72 TypeError: <class 'sage.schemes.hyperelliptic_curves.hyperelliptic_g2_rational_field.HyperellipticCurve_g2_rational_field_with_category'> is not hashable and does not implement _cache_key()
58 ValueError: Polyomino must be non empty
58 TypeError: 'dict_keys' object is not subscriptable
46 KeyError: ((<class 'sage.algebras.lie_algebras.classical_lie_algebra.LieAlgebraChevalleyBasis'>, Rational Field, ['A', 2]), ())
45 TypeError: must be str, not bytes
44 AttributeError: 'function' object has no attribute '__func__'
44 AttributeError: 'dict' object has no attribute 'iteritems'
40 KeyError: ((0, False), ())
39 IndexError: tuple index out of range
Of course, from this experiment there's often no easy way to see what the context is to these errors, an some of them might just occur hundreds of times in one module and not have a wide-reaching effect. But it's worth looking into. Grepping the test log for individual error messages helps give a better idea of where they might come from.
Another potentially interesting heuristic, though I haven't tested how effective this is yet is something like:
$ grep 'doctest.*failed' logs/ptest.log | sort -k 5 -nr | head -20
showing me the modules with the most failures.
On my latest python3 branch (which has all the currently open python3 tickets merged in, as well as some other fixes) I have:
sage -t src/sage/misc/explain_pickle.py # 71 doctests failed
sage -t src/sage/calculus/riemann.pyx # 67 doctests failed
sage -t src/sage/libs/lcalc/lcalc_Lfunction.pyx # 58 doctests failed
sage -t src/sage/combinat/free_dendriform_algebra.py # 50 doctests failed
sage -t src/sage/combinat/words/finite_word.py # 47 doctests failed
sage -t src/doc/en/thematic_tutorials/sandpile.rst # 45 doctests failed
sage -t src/sage/matrix/compute_J_ideal.py # 44 doctests failed
sage -t src/sage/graphs/generic_graph.py # 41 doctests failed
sage -t src/sage/schemes/riemann_surfaces/riemann_surface.py # 36 doctests failed
sage -t src/sage/sandpiles/sandpile.py # 34 doctests failed
sage -t src/sage/combinat/hillman_grassl.py # 34 doctests failed
sage -t src/sage/combinat/cluster_algebra_quiver/quiver.py # 33 doctests failed
sage -t src/sage/combinat/finite_state_machine.py # 32 doctests failed
sage -t src/sage/rings/polynomial/real_roots.pyx # 29 doctests failed
sage -t src/sage/coding/source_coding/huffman.py # 26 doctests failed
sage -t src/sage/combinat/diagram_algebras.py # 25 doctests failed
sage -t src/sage/matroids/matroid.pyx # 23 doctests failed
sage -t src/sage/combinat/rigged_configurations/kr_tableaux.py # 23 doctests failed
sage -t src/sage/combinat/cluster_algebra_quiver/cluster_seed.py # 22 doctests failed
sage -t src/sage/graphs/graph.py # 20 doctests failed
With the exception of "explain_pickle" which is kind of a special case (and one I'm not sure what to do with), my guess is that modules with many failing tests indicate something that is deeply broken enough which, if fixed, might have far reaching consequences both within that module itself, and other modules that depend on it.
Of course this isn't always going to be the case--sometimes the failures might be very localized. But this gives some idea of where the most effort is needed.
Well, based on the example above, I found one one-line bug in sage.calculus.riemann
(#25974) which fixed all the tests in that module, as well as 7 other modules. Still very anecdotal, but at least one good result from that heuristic.
In sage-on-gentoo I get in the following trouble a lot with python3
File "sage/libs/gap/util.pyx", line 199, in sage.libs.gap.util.initialize (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_6/build/cythonized/sage/libs/gap/util.c:4452)
s = str_to_bytes(gap_root(), FS_ENCODING, "surrogateescape")
File "sage/libs/gap/util.pyx", line 171, in sage.libs.gap.util.gap_root (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python3_6/build/cythonized/sage/libs/gap/util.c:4232)
gapdir = filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh)[0]
TypeError: 'filter' object is not subscriptable
But I am guessing that it is not seen in vanilla sage because I apply the following patch
diff --git a/sage/libs/gap/util.pyx b/sage/libs/gap/util.pyx
index 97703ff..48dc617 100644
--- a/sage/libs/gap/util.pyx
+++ b/sage/libs/gap/util.pyx
@@ -23,7 +23,7 @@ from .element cimport *
from sage.cpython.string import FS_ENCODING
from sage.cpython.string cimport str_to_bytes, char_to_str
from sage.interfaces.gap_workspace import prepare_workspace_dir
-from sage.env import SAGE_LOCAL, GAP_ROOT_DIR
+from sage.env import SAGE_LOCAL
############################################################################
@@ -167,9 +167,6 @@ def gap_root():
'/home/vbraun/opt/sage-5.3.rc0/local/gap/latest'
"""
import os.path
- if os.path.exists(GAP_ROOT_DIR):
- return GAP_ROOT_DIR
- print('The gap-4.5.5.spkg (or later) seems to be not installed!')
gap_sh = open(os.path.join(SAGE_LOCAL, 'bin', 'gap')).read().splitlines()
gapdir = filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh)[0]
gapdir = gapdir.split('"')[1]
vanilla never shows the problem because it uses GAP_ROOT_DIR
, which I find an hindrance as it presuppose a way of installing gap
, the alternate code that comes after works well enough - at least with python2. But obviously not with python3.
Any suggestions on fixing this?
replace
gapdir = filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh)[0]
by
gapdir = next(dir for dir in gap_sh if dir.strip().startswith('GAP_DIR'))
? Please make a ticket.
OK will try that and create a ticket when I can. This has escaped detection so far because it is not doctested.
Replying to @kiwifb:
OK will try that and create a ticket when I can. This has escaped detection so far because it is not doctested.
Perhaps it should be?
Replying to @fchapoton:
replace
gapdir = filter(lambda dir:dir.strip().startswith('GAP_DIR'), gap_sh)[0]
by
gapdir = next(dir for dir in gap_sh if dir.strip().startswith('GAP_DIR'))
? Please make a ticket.
That works, but to be complete, it will also need some doctest. It is now #26665.
Description changed:
---
+++
@@ -1,3 +1,5 @@
+For progress on making all doctests pass, see #26212
+
In order to support python 3.6, the following needs to be fixed:
1. #15510 - upgrade to a newer version of setuptools
Changed dependencies from #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, #18537, #16052, #18437 to #15510, #15511, #15512, #15531, #15532, #15537, #15539, #15540, #15541, #15807, #15980, #18537, #16052, #18437, #27024
Description changed:
---
+++
@@ -22,6 +22,7 @@
18. #18437 - fix polybori and python 3
19. #18537 - fix Pynac at least building against python 3
20. #17607 - add python 3 package
+21. #27024 - make sagetex python3 compatible
---
How to build sage with python3:
Shouldn't this ticket maintain a branch of with all the positively reviewed py3-related tickets?
That might be useful: I do something like that manually anyways.
Description changed:
---
+++
@@ -30,7 +30,7 @@
make configure ./configure --with-python=3 -make build +make
---
Description changed:
---
+++
@@ -32,6 +32,7 @@
./configure --with-python=3
make
+Beware that the configure step above should be redone after every make distclean
.
Description changed:
---
+++
@@ -1,3 +1,15 @@
+---
+How to build sage with python3:
+
+```
+make configure
+./configure --with-python=3
+make
+```
+Beware that the second step above should be redone after every `make distclean`.
+
+---
+
For progress on making all doctests pass, see #26212
In order to support python 3.6, the following needs to be fixed:
@@ -24,18 +36,6 @@
20. #17607 - add python 3 package
21. #27024 - make sagetex python3 compatible
----
-How to build sage with python3:
-
-```
-make configure
-./configure --with-python=3
-make
-```
-Beware that the configure step above should be redone after every `make distclean`.
-
----
-
Possibly relevant timeline from [PEP 373](https://www.python.org/dev/peps/pep-0373/):
Being the last of the 2.x series, 2.7 will have an extended period of maintenance. The current plan is to support it for at least 10 years from the initial 2.7 release. This means there will be bugfix releases until 2020.
Description changed:
---
+++
@@ -10,9 +10,9 @@
---
-For progress on making all doctests pass, see #26212
+For progress on making all doctests pass, see #26212 and #28298
-In order to support python 3.6, the following needs to be fixed:
+In order to support python 3.7, the following needs to be fixed:
1. #15510 - upgrade to a newer version of setuptools
2. #15511 - upgrade to a newer version of rpy2
What are we going to do with animation support on Python 3? It seems it is broken - the only (non-console, not sure about console though) possibility seems to be via jupyter+j(s)mol, and this has not moved far: https://github.com/jupyter/notebook/issues/1872
See also the recent where people complain about broken animation on 8.9. https://groups.google.com/d/msg/sage-devel/OepzKdldklU/uf2eRVWuDAAJ
Dima, can you provide more details? For the second paragraph, the sage-devel thread gives an example of something which doesn't work in the legacy Sage notebook (their example starts with the command notebook()
). So that's not a Python 3 problem. It also doesn't seem to be discussing animation, but maybe I'm missing something. The problem in the first paragraph is about the Jupyter notebook, and I see the same problem with both Python 2 and Python 3.
yes, the sage-devel thread discusses mostly sagenb, but the question is how to do the job in jupyter instead, and this appears to be a blocker, as this is a serious regression.
Disclaimer: I do not know how to do animations in Sage. If someone who knows looked into this, it would be great.
Okay, it still feels like a Jupyter and/or JMol/threejs issue rather than a Python 3 issue.
it is a Python 3 issue, as one does not have sagenb there, while sagenb (at least before Sage 8.9) was able to do animations.
Regarding the animation issue, see my tests on the sage-devel thread just now. It does somehow seem to be an integration between sagenb and new j(s)mol thing. As for "how to do animations", all they meant was "make a 3d graphic, and then try to make it movable by clicking the little circle in jmol", not using an actual animation command. I'd encourage a few others to try using viewer='jmol'
in Jupyter in the 9.0 series to see what happens.
Is anything left to be done here or can the ticket be closed?
see #30053 for a blocker for 3.x, for x<7.
Let's close this metaticket to signal the completion of the Python 3 transition.
ok, done
Reviewer: Dima Pasechnik
How to build sage with python3:
Beware that the second step above should be redone after every
make distclean
.For progress on making all doctests pass, see #26212 and #28298
In order to support python 3.7, the following needs to be fixed:
15510 - upgrade to a newer version of setuptools
15511 - upgrade to a newer version of rpy2
15512 - upgrade to a newer version of sympy
14854 - upgrade to a newer version of pycrypto
15532 - upgrade to a newer version of networkx
15537 - fix csage to work with python3
15539 - switch from using PIL to Pillow
15540 - trivial python3 fixes to a few spkgs
15541 - fix sage-location and sage-download-file for python3
15593 - remove sqlalchemy
17591 - remove gdmodule
15620 - Stop using
StandardError
15755 - upgrade cython to version 0.20.1
15807 - upgrade mpmath to version 0.18
15980 - meta-ticket for python3 compatibility of the sage library (stage 1)
16052 - meta-ticket for python3 compatibility of the sage library (stage 2)
17854 - remove c_lib
18437 - fix polybori and python 3
18537 - fix Pynac at least building against python 3
17607 - add python 3 package
27024 - make sagetex python3 compatible
Possibly relevant timeline from PEP 373:
Being the last of the 2.x series, 2.7 will have an extended period of maintenance. The current plan is to support it for at least 10 years from the initial 2.7 release. This means there will be bugfix releases until 2020.
Depends on #15510 Depends on #15511 Depends on #15512 Depends on #15531 Depends on #15532 Depends on #15537 Depends on #15539 Depends on #15540 Depends on #15541 Depends on #15807 Depends on #15980 Depends on #18537 Depends on #16052 Depends on #18437 Depends on #27024
Component: python3
Reviewer: Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/15530