安卓 python解释器_Android上的Python解释器

Pyonic interpreter

A Python interpreter interface for mobile devices. Pyonic interpreter is available for Android on Google Play, for Python 2 or Python 3. The app can also be run under Kivy on the desktop (Linux, OS X/macOS, Windows).

The Pyonic interpreter user interface is created in Python using Kivy. User input is passed to a second interpreter, run as a separate process via an Android service. The interpreter is packaged for Android using python-for-android. Pyonic interpreter is written for and tested with both Python 2 and Python 3.

Future targets include support for multiple interpreters, different kinds of Python tasks (app threads, background services), and editing/running Python files.

This app should in principle run on iOS with the addition of backend code to start the interpreter subprocess (although I don't know what the appropriate iOS mechanism would be). If anyone would like to try this, feel free to ask any questions about the process.

pyonic_android_small.png

Building

To run on a desktop, simply clone from github and run python pyonic/main.py from the cloned dir. You will need Kivy and argparse installed, but other dependencies are fairly minimal.

Installing with setup.py may work, but this hasn't been tested and this doesn't yet install a command line shortcut.

To build for Android, install python-for-android, modify the hardcoded ndk-dir in setup.py, and run:

python setup.py apk

You may need to install python-for-android from the github master branch for this to work.

Technical details

Pyonic interpreter runs as a Kivy application, starting a second process in the background (a subprocess on desktop, a service on Android) to run the Python code input. The output streams of this second process are redirected to be formatted in Kivy labels in the main app.

This method seems quite crude, although it works well. An immediate improvement will be to check how other similar projects do the same thing.

Communication between processes is achieved using osc (specifically, the implementation shipped with Kivy). There are probably much better ways to do this nowadays, such as zeromq. These will be investigated in the future.

Todo

Editor:

code completion

linting?

run code (different screen?)

abstract InterpreterInput and MenuButton for both usages

multiple file support (navigation drawer?)

Before next release:

Near future:

Add optional button rows (numbers, more symbols)

Improve message if interpreter is not responding on resume

Make initialising logo appear before unpacking

Check out keyboard issues

Unify handling of python2/python3 differences via a module

Eventually:

Halt thread on service exit

Save to file button

Add an 'About' page

Setting for scrollback length

Add linting

ctypes problem

Works on:

LG G4 (Android 6.0)

Moto E (Android 6.0)

Fails on:

Nexus 4

Galaxy Note 2

Sony xperia z1 compact

Samsung Galaxy J1 (Android 5.1.1)

crashes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值