Ir para o conteúdo
ou

Software livre Brasil

 Voltar a Projeto Soft...
Tela cheia Sugerir um artigo

Filipe Saraiva: LaKademy results – starting development of Python backend to Cantor

2 de Maio de 2012, 0:00 , por Software Livre Brasil - 0sem comentários ainda | Ninguém está seguindo este artigo ainda.
Visualizado 49 vezes

LaKademy is over and I will report about the event in several themed posts. This is about I developed during the Latin American meeting of KDE developers. More posts in LaKademy tag.

In this year I submitted a proposal to Google Summer of Code to develop a Python backend for scientific programming in Cantor. In the last year, I developed a Scilab backend. Unfortunately my proposal was not accepted.

But that’s okay, life goes on. This does not discourage me to begin the project.

During the LaKademy, I put as a goal to make communication between Cantor and Python. My first idea was to make a fork of Sage backend, which is also a technology based in Python. But in the evaluation phase of proposal for Google Summer of Code, the Cantor main developer, Alex Rieder, suggested to me take a look in Python/C API.

I began studying this API and other resources on the web (like this one, based on Elmer). I realized that send Python commands from C/C++ code would be easy, however, capture the output of the Python interpreter would be the real challenge. All this communication could be simple if Python would use standard streams by default, which would allow to use kprocess. Scilab didn’t support, but I implemented this support and it allowed the use of kprocess approach. However, in Python I could not do that – or would be harder to do it.

After searches in internet and some studies, I implemented a Python class that redirects messages from the Python interpreter, both conventional outputs and error messages, to a variable that can later be retrieved in a string type by Python/C API. Voilà!

Using this recovered variable, I can say that the core of Python backend for Cantor is working and ready to implement more features. Let see some screenshots:

Computation of a simple counter in Python

Cantor + Python + matplotlib in a external plot

Python error message in Cantor

From this implemented part, the new features that will be added: append plot figure in Cantor workspace, syntax highlighting, auto-complete pre-defined functions, and more. I intend to support in particular for libraries numpy, scipy and matplotlib, which when added to Python make it an interesting tool for scientific programming, like others we have in the free world as GNU Octave, Scilab, Maxima, Sage.

The code is avaiable in python-backend branch of Cantor repository. But remember: it is a experimental version, and the main fatures will be develop yet. Only communication between C++ <-> Python, the core of application, is working for now.

Watch this blog (or follow python-backend tag) for more informations about this project. ;-)


Fonte: http://blog.filipesaraiva.info/?p=779

0sem comentários ainda

Enviar um comentário

Os campos são obrigatórios.

Se você é um usuário registrado, pode se identificar e ser reconhecido automaticamente.