Bug#852780: [sage-packaging] Cantor sage backend

2017-06-01 Thread Ximin Luo
Ximin Luo:
> Ximin Luo:
>> Antonio Rojas:
>>> El lunes, 22 de mayo de 2017 23:59:00 (CEST) Ximin Luo escribió:
>>>  
 Thanks for the info. I had a play around, unfortunately --simple-prompt 
 won't be sufficient.
>
 REPLs generally support multiline input (e.g. Python itself) so unless the 
 GSoC student specifically wants Cantor+Sage to work, we'll have to try to 
 figure out how to push ipython to fix their simple-prompt...

>>>
>>> Thanks, I've added this info to the upstream report 
>>> https://bugs.kde.org/show_bug.cgi?id=375467
>>>
>>
>> I think I've managed to fix it in IPython with this patch (2 commits):
>>
>> https://github.com/ipython/ipython/pull/10606
>>
>> Can you confirm? You also need to patch sage/repl/configuration.py as I 
>> mentioned earlier, as well as patch cantor_sagebackend.so if its version is 
>> < 16.12.
>>
> 
> Unfortunately this broke some Sage doctests.
> 
> To get Cantor to detect Sage properly, I modified IPython's simple-prompt to 
> not use "In [x]" as the prompt, but to use whatever was configured by the 
> application (i.e. Sage).
> 
> However, Sage's own doctests assume that IPython would output "In [x]" in 
> simple-prompt mode. I'm having trouble finding the place in the code where it 
> does this however, any tips? I confirm that if I patch IPython to hard-code 
> "In [x]" as the prompt again (whilst also *not* reverting the multi-line fix) 
> then the sage doctests work again.
> 

Fixed: https://trac.sagemath.org/ticket/23125

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



Bug#852780: [sage-packaging] Cantor sage backend

2017-06-01 Thread Ximin Luo
Ximin Luo:
> Antonio Rojas:
>> El lunes, 22 de mayo de 2017 23:59:00 (CEST) Ximin Luo escribió:
>>  
>>> Thanks for the info. I had a play around, unfortunately --simple-prompt 
>>> won't be sufficient.

>>> REPLs generally support multiline input (e.g. Python itself) so unless the 
>>> GSoC student specifically wants Cantor+Sage to work, we'll have to try to 
>>> figure out how to push ipython to fix their simple-prompt...
>>>
>>
>> Thanks, I've added this info to the upstream report 
>> https://bugs.kde.org/show_bug.cgi?id=375467
>>
> 
> I think I've managed to fix it in IPython with this patch (2 commits):
> 
> https://github.com/ipython/ipython/pull/10606
> 
> Can you confirm? You also need to patch sage/repl/configuration.py as I 
> mentioned earlier, as well as patch cantor_sagebackend.so if its version is < 
> 16.12.
> 

Unfortunately this broke some Sage doctests.

To get Cantor to detect Sage properly, I modified IPython's simple-prompt to 
not use "In [x]" as the prompt, but to use whatever was configured by the 
application (i.e. Sage).

However, Sage's own doctests assume that IPython would output "In [x]" in 
simple-prompt mode. I'm having trouble finding the place in the code where it 
does this however, any tips? I confirm that if I patch IPython to hard-code "In 
[x]" as the prompt again (whilst also *not* reverting the multi-line fix) then 
the sage doctests work again.

X

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



Bug#852780: [sage-packaging] Cantor sage backend

2017-05-25 Thread Ximin Luo
Ximin Luo:
> Antonio Rojas:
>> El lunes, 22 de mayo de 2017 23:59:00 (CEST) Ximin Luo escribió:
>>  
>>> Thanks for the info. I had a play around, unfortunately --simple-prompt 
>>> won't be sufficient.

>>> REPLs generally support multiline input (e.g. Python itself) so unless the 
>>> GSoC student specifically wants Cantor+Sage to work, we'll have to try to 
>>> figure out how to push ipython to fix their simple-prompt...
>>>
>>
>> Thanks, I've added this info to the upstream report 
>> https://bugs.kde.org/show_bug.cgi?id=375467
>>
> 
> I think I've managed to fix it in IPython with this patch (2 commits):
> 
> https://github.com/ipython/ipython/pull/10606
> 
> Can you confirm? You also need to patch sage/repl/configuration.py as I 
> mentioned earlier, as well as patch cantor_sagebackend.so if its version is < 
> 16.12.
> 

On my end, it works only half-reliably, but I think the remaining issues are 
problems with Cantor and the fact it might be trying to use old Sage APIs; not 
problems with our patched Sage/IPython.

>>> integrate(1/(1-x^2), x)
- works fine

>>> plot(sin(x), (x, 0,2*pi))
- works fine

>>> plot(x^3, (x, 0, 5))
- sometimes works fine
- sometimes generates an incorrect plot, looks like a scatter plot with random 
points instead of a cubic curve
- sometimes gives "AttributeError: must give both plot endpoints"

>>> x = PolynomialRing(RationalField(), 'x').gen()
f = (x^3 - 1)^2-(x^2-1)^2
f.factor()
- works fine

>>> R = PolynomialRing(GF(97),'x')
x = R.gen()
S = R.quotient(x^3 + 7, 'a')
a = S.gen()
S
- outputs a bunch of unformatted raw latex, even though other examples such as 
the integrate one above work. in the console where cantor is running, one sees:
[..]
running:  "/usr/bin/dvips" -E -o "/tmp/cantor_tex-V26836.eps" 
"/tmp/cantor_tex-V26836.dvi"
This is dvips(k) 5.996 Copyright 2016 Radical Eye Software (www.radicaleye.com)
/usr/bin/dvips: DVI file can't be opened: /tmp/cantor_tex-V26836.dvi: No such 
file or directory
rendered file  "/tmp/cantor_tex-V26836.eps"
rendered a result to  "/tmp/cantor_tex-V26836.eps"
settting result to a type  1  result
update Entry
update result
error rendering latex:  "something is wrong"
[..]

X

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



Bug#852780: [sage-packaging] Cantor sage backend

2017-05-25 Thread Ximin Luo
Antonio Rojas:
> El lunes, 22 de mayo de 2017 23:59:00 (CEST) Ximin Luo escribió:
>  
>> Thanks for the info. I had a play around, unfortunately --simple-prompt 
>> won't be sufficient.
>>>
>> REPLs generally support multiline input (e.g. Python itself) so unless the 
>> GSoC student specifically wants Cantor+Sage to work, we'll have to try to 
>> figure out how to push ipython to fix their simple-prompt...
>>
> 
> Thanks, I've added this info to the upstream report 
> https://bugs.kde.org/show_bug.cgi?id=375467
> 

I think I've managed to fix it in IPython with this patch (2 commits):

https://github.com/ipython/ipython/pull/10606

Can you confirm? You also need to patch sage/repl/configuration.py as I 
mentioned earlier, as well as patch cantor_sagebackend.so if its version is < 
16.12.

X

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



Bug#852780: [sage-packaging] Cantor sage backend

2017-05-23 Thread Antonio Rojas
El lunes, 22 de mayo de 2017 23:59:00 (CEST) Ximin Luo escribió:
 
> Thanks for the info. I had a play around, unfortunately --simple-prompt won't 
> be sufficient.
> > 
> REPLs generally support multiline input (e.g. Python itself) so unless the 
> GSoC student specifically wants Cantor+Sage to work, we'll have to try to 
> figure out how to push ipython to fix their simple-prompt...
> 

Thanks, I've added this info to the upstream report 
https://bugs.kde.org/show_bug.cgi?id=375467



Bug#852780: [sage-packaging] Cantor sage backend

2017-05-22 Thread Ximin Luo
(+CC the debian bug)

Antonio Rojas:
> El lunes, 22 de mayo de 2017 18:56:00 (CEST) Ximin Luo escribió:
>> Has anyone had any success in making this work? In Debian we're suffering 
>> from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=852780 at the moment.
>>
>> I'm not sure how Cantor is interfacing with Sage; and in Debian we do patch 
>> away a lot of CLI options relating to Sage-the-distro, similar to what 
>> Gentoo does.
>>
> 
> Hi,
>  I fixed the version detection in 16.12:
>  
> https://cgit.kde.org/cantor.git/commit/?id=8d3d07a683ca6758eada1cd8442047401c0fa83d
> 
>  However, interfacing with Sage is completely broken since the ipython 5.0 
> upgrade. Cantor uses KPtyProcess to read Sage's output, and the new ipython 
> highlighting confuses it (it can't interpret the ANSI codes). I guess the 
> easiest fix would be to add a flag to the sage command that would force 
> ipython to run in --simple-prompt mode, and make Cantor run sage with that 
> flag.
>  Also note that there is an ongoing Google SOC project about rewriting 
> Cantor's interface with its backends, so this may be fixed in the process.
> 

Thanks for the info. I had a play around, unfortunately --simple-prompt won't 
be sufficient.

1. I edited /usr/lib/python2.7/dist-packages/sage/repl/configuration.py to 
force _allow_ansi to always return False, which forces simple_prompt=True and 
term_title=False.

2. Then I binary-edited the regexp string in 
/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/backends/cantor_sagebackend.so to 
instead say '.[a-zA-Z\W].+\s+(\d+)\.(\d+)' - i.e. a hack that effectively 
removes the first parentheses so the broken code works "correctly" for 7.6.

Now cantor detects sage's version correctly, but then fails because of 
https://github.com/ipython/ipython/issues/9816


found version:  ("[.. banner ANSI codes and box drawing characters ..] SageMath 
version 7.6", "7", "6")
using the current set of commands
out:  "[..]  SageMath version 7.6, Release Date: 2017-03-25  [..]\r\nIn [1]: In 
[2]: In [3]: In [4]: In [5]: In [6]: In [7]: In [8]: In [9]: TMP_DIR 
/home/infinity0/.sage/temp/pdeb1/30547\r\nIn [10]: In [11]: In [12]:   File 
\"\", line 1\r\ndef 
__cantor_enable_typesetting(enable):\r\n
^\r\nSyntaxError: unexpected EOF while parsing\r\n\r\nIn [13]:   File 
\"\", line 1\r\nif(enable==true):\r\n
 ^\r\nSyntaxError: unexpected EOF while parsing\r\n\r\nIn [14]: In 
[15]:   File \"\", line 1\r\nelse:\r\n   
^\r\nSyntaxError: invalid syntax\r\n\r\nIn [16]: In [17]: In [17]: 
END_OF_INIT\r\nIn [18]: "


You get the same error when doing this manually with sage (with _allow_ansi 
hacked to be False as above):


$ sage
[.. banner ..]
In [1]: def __cantor_enable_typesetting(enable):
  File "", line 1
def __cantor_enable_typesetting(enable):
^
SyntaxError: unexpected EOF while parsing


REPLs generally support multiline input (e.g. Python itself) so unless the GSoC 
student specifically wants Cantor+Sage to work, we'll have to try to figure out 
how to push ipython to fix their simple-prompt...

X

-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git