first python3 build of sage

259 views
Skip to first unread message

Frédéric Chapoton

unread,
Apr 18, 2017, 3:25:44 PM4/18/17
to sage-devel
Dear all,

I just managed (using tricks to avoid a few remaining issues in cythonization and packages) to get make succeed in building sage with SAGE_PYTHON3=yes
Sadly, but not unexpectedly, sage then crashes at startup. Apparently, it cannot not find/import any cython extension..

Frédéric

Here is a snapshot of the end of compilation and tentative run:

real 61m21.708s
user
57m46.564s
sys
1m30.508s
Sage build/upgrade complete!
chapoton@icj
-laptop:~/sage3$ ./sage
┌────────────────────────────────────────────────────────────────────┐
SageMath version 8.0.beta2, Release Date: 2017-04-12              
Type "notebook()" for the browser-based notebook interface.        
Type "help()" for help.                                            
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Warning: this is a prerelease version, and it may be unstable.    
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Forcing sage-location, probably because a new package was installed.
Updating various hardcoded paths...
(Please wait at most a few minutes.)
DO NOT INTERRUPT THIS
.
Done updating paths.


**********************************************************************


Oops, Sage crashed. We do our best to make it stable, but...


For the curious people, the crash log ends with

---> 39 from sage.structure.sage_object import SageObject
       
global sage.structure.sage_object = undefined
       
global SageObject = undefined
     
40 from sage.repl.rich_output.output_basic import (
     
41     OutputPlainText, OutputAsciiArt, OutputUnicodeArt, OutputLatex,
     
42 )
     
43 from sage.repl.rich_output.preferences import DisplayPreferences
     
44
     
45
     
46 class DisplayException(Exception):
     
47     """
     48     Base exception for all rich output-related exceptions.
     49
     50     EXAMPLES::
     51
     52         sage: from sage.repl.rich_output.display_manager import DisplayException
     53         sage: raise DisplayException('foo')
     54         Traceback (most recent call last):


ImportError: No module named 'sage.structure.sage_object'

Eric Gourgoulhon

unread,
Apr 18, 2017, 3:36:00 PM4/18/17
to sage-devel

Le mardi 18 avril 2017 21:25:44 UTC+2, Frédéric Chapoton a écrit :

I just managed (using tricks to avoid a few remaining issues in cythonization and packages) to get make succeed in building sage with SAGE_PYTHON3=yes

Congratulations!!!
This is already an impressive achievement!
Sadly, but not unexpectedly, sage then crashes at startup. Apparently, it cannot not find/import any cython extension..
Sorry I cannot help at this point.

Best wishes,

Eric.

Vincent Delecroix

unread,
Apr 19, 2017, 4:58:53 AM4/19/17
to sage-...@googlegroups.com
Hi Frédéric,

Can you check what are inside

SAGE_ROOT/local/lib/python2.7/site-packages/sage
SAGE_ROOT/local/lib/python3.5/site-packages/sage

Vincent

Frédéric Chapoton

unread,
Apr 19, 2017, 7:11:08 AM4/19/17
to sage-devel
Hello,

I get nothing from "ls local/lib/python2.7/site-packages/sa*"

and what looks like a correct full sage in local/lib/python3.5/site-packages/sage

The problem may come from "./sage" calling a python2.7 version ?

Frederic

Le mercredi 19 avril 2017 10:58:53 UTC+2, vdelecroix a écrit :
Hi Frédéric,

Can you check what are inside local/lib/python3.5/site-packages/sage

Vincent Delecroix

unread,
Apr 19, 2017, 7:53:20 AM4/19/17
to sage-...@googlegroups.com
Indeed, could you try

$ sage -sh
(sage-sh) $ python3
>>> import sage.all

Vincent

Frédéric Chapoton

unread,
Apr 19, 2017, 8:57:14 AM4/19/17
to sage-devel
Here it is  (once again, the failure is related to a cython module):

(sage-sh) chapoton@pc-chapoton:sage3$ python3
Python 3.5.1 (default, Apr  7 2017, 12:17:26)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
Traceback (most recent call last):

 
File "<stdin>", line 1, in <module>
 
File "/home/chapoton/sage3/local/lib/python3.5/site-packages/sage/all.py", line 86, in <module>
   
import sage.misc.lazy_import
ImportError: No module named 'sage.misc.lazy_import'

Vincent Delecroix

unread,
Apr 20, 2017, 2:16:40 AM4/20/17
to sage-...@googlegroups.com
Do you have the corresponding (cython) library

SAGE_ROOT/local/lib/python3.5/site-packages/sage/misc/lazy_import.so

If so could you try (inside a python3 shell)

import sage.misc.lazy_import

that should give you a more precise error.

Vincent

Frédéric Chapoton

unread,
Apr 20, 2017, 2:35:46 AM4/20/17
to sage-devel
Salut,

There is no lazy_import.so in local/lib/python3.5/site-packages/sage/misc folder (and in fact no .so file at all there)

And I get

Python 3.5.1 (default, Apr 16 2017, 11:35:45)
Type "copyright", "credits" or "license" for more information.


IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python'
s own help system.
object?   -> Details about 'object', use 'object??' for extra details.


In [1]: import sage.misc.lazy_import
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-99e0dfbb667e> in <module>()
----> 1 import sage.misc.lazy_import


ImportError: No module named 'sage.misc.lazy_import'


but all .py modules are there:
In [1]: from sage.
               sage
.algebras        sage.calculus        sage.data_structures  
               sage
.all             sage.categories      sage.databases        
               sage
.all_cmdline     sage.coding          sage.docs            >
               sage
.all_notebook    sage.combinat        sage.doctest          
               sage
.arith           sage.crypto          sage.dynamics        


Vincent Delecroix

unread,
Apr 20, 2017, 2:40:33 AM4/20/17
to sage-...@googlegroups.com
Salut Frédéric,

Then this is the problem. Cython should generate .so files for each .pyx
present in the Sage source code (which should be in the site-packages of
Python3). If you provide an explicit branch with your "hacks" to get
Sage compiled I might be able to provide more help.

Vincent

Frédéric Chapoton

unread,
Apr 20, 2017, 2:52:40 AM4/20/17
to sage-devel
Salut,

you have to apply first : public/experimental_python3_v0

then the ticket 22775 (new conway_polynomial package) https://trac.sagemath.org/ticket/22775

Frederic

Vincent Delecroix

unread,
Apr 20, 2017, 2:57:30 AM4/20/17
to sage-...@googlegroups.com
Why do you have 355 commits on public/experimental_python3_v0?! It is
hard to find its way...

Vincent Delecroix

unread,
Apr 20, 2017, 3:02:19 AM4/20/17
to sage-...@googlegroups.com
Waiting for make... I have nothing to do in order that Python3 is used
instead of Python2?

On 20/04/2017 08:52, Frédéric Chapoton wrote:

Frédéric Chapoton

unread,
Apr 20, 2017, 3:02:54 AM4/20/17
to sage-devel
Really 355 ? More like 20, but I agree that it is a mess.

This is my own experimental branch, not for evereybody's eyes.. It is made from 22764, 22756, 22305 and 22775

plus one own commit that takes care (not in a good way) of the last two calls to cmp() in pyx files.

Frederic

Frédéric Chapoton

unread,
Apr 20, 2017, 3:07:30 AM4/20/17
to sage-devel
STOP ! you should export SAGE_PYTHON3=yes

Vincent Delecroix

unread,
Apr 20, 2017, 3:35:50 AM4/20/17
to sage-...@googlegroups.com
Can you look at SAGE_ROOT/src/build and try to find is there is a .so
there. For example

$ find $(sage -root)/src/build -name "*.so"

(normally there should be, the cythonization process put stuff there)

Frédéric Chapoton

unread,
Apr 20, 2017, 3:46:52 AM4/20/17
to sage-devel
~/sage3/src/build$ find -name "*.so"

returns nothing :(

VulK

unread,
Apr 20, 2017, 10:18:04 AM4/20/17
to sage-...@googlegroups.com
It looks to me that the various .so files get compiled but then removed just
before the build finishes. Here is a snippet of the log:

byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/stats/r.py to r.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/stats/hmm/__init__.py to __init__.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/stats/hmm/all.py to all.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/stats/all.py to all.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/finance/__init__.py to __init__.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/finance/easter.py to easter.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/finance/markov_multifractal.py to markov_multifractal.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/finance/stock.py to stock.cpython-35.pyc
byte-compiling /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/finance/all.py to all.cpython-35.pyc
running install_egg_info
Removing /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage-8.0.beta2-py3.5.egg-info
Writing /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage-8.0.beta2-py3.5.egg-info
Cleaning up stale installed files....
- cleaning /mnt/backup/sage-py3/local/lib/python3.5/site-packages
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/modular/modform_hecketriangle/__pycache__/abstract_space.cpython-35.pyc
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/rings/polynomial/polynomial_zmod_flint.cpython-35m-x86_64-linux-gnu.so
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/libs/gsl/array.cpython-35m-x86_64-linux-gnu.so
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/modular/quatalg/__pycache__/all.cpython-35.pyc
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/rings/__pycache__/infinity.cpython-35.pyc
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/manifolds/differentiable/__pycache__/chart.cpython-35.pyc
Cleaning up stale file: /mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/interacts/__pycache__/all.cpython-35.pyc


S.




* Frédéric Chapoton <fchap...@gmail.com> [2017-04-20 00:46:52]:
>--
>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+...@googlegroups.com.
>To post to this group, send email to sage-...@googlegroups.com.
>Visit this group at https://groups.google.com/group/sage-devel.
>For more options, visit https://groups.google.com/d/optout.

VulK

unread,
Apr 20, 2017, 10:29:46 AM4/20/17
to sage-...@googlegroups.com
Indeed if one comments line 847 in src/setup.py the files looks to be there.
Sage crashes anyway but now:


VulK@bunion /mnt/backup/sage-py3 (git)-[my_py3] % ./sage -sh

Starting subshell with Sage environment variables set. Don't forget
to exit when you are done. Beware:
* Do not do anything with other copies of Sage on your system.
* Do not use this for installing Sage packages using "sage -i" or for
running "make" at Sage's root directory. These should be done
outside the Sage shell.

Bypassing shell configuration files...

Note: SAGE_ROOT=/mnt/backup/sage-py3
(sage-sh) VulK@bunion:/mnt/backup/sage-py3$ python3
Python 3.5.1 (default, Apr 20 2017, 12:56:34)
[GCC 4.9.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/all.py", line 87, in <module>
from sage.misc.all import * # takes a while
File "/mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/misc/all.py", line 27, in <module>
from .html import html
File "/mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/misc/html.py", line 20, in <module>
from sage.misc.latex import latex
File "/mnt/backup/sage-py3/local/lib/python3.5/site-packages/sage/misc/latex.py", line 408, in <module>
long: str,
NameError: name 'long' is not defined






* Frédéric Chapoton <fchap...@gmail.com> [2017-04-20 00:46:52]:

Frédéric Chapoton

unread,
Apr 25, 2017, 3:14:35 PM4/25/17
to sage-devel, etn4...@gmail.com
Thanks for the hint, Salvatore !

Indeed, the line "self.clean_stale_files()" inside src/setup.py probably does something wrong, maybe confusing python2 and python3 ?

If somebody else feels concerned, please help to investigate the issue.

Frederic

Vincent Delecroix

unread,
Apr 26, 2017, 5:47:45 AM4/26/17
to sage-...@googlegroups.com
I don't think clean_stale_files is to blame. It is removing the build
files. What is wrong is that the relevant file are *not* installed
before. I guess it is a problem in the install.run() method.

Vincent
>> * Frédéric Chapoton <fchap...@gmail.com <javascript:>> [2017-04-20
>> email to sage-devel+...@googlegroups.com <javascript:>.
>>> To post to this group, send email to sage-...@googlegroups.com
>> <javascript:>.
Reply all
Reply to author
Forward
0 new messages