Home

Awesome

Python for iOS -- with partial fork() and exec() ability

This project is a patch of Python-2.7.13, designed to make it compile on iOS. Python becomes a framework, and your programs call python_main(argc, argv) to execute python scripts.

This framework was designed to be used in conjunction with Blinkshell, OpenTerm or iVim, but it can be used independently.

Compilation:

This will download the Python-2.7.13 source code, and patch it. It will also download libffi-3.2.1, and patch it.

After patching, you have two Xcode projects:

Open the first one, build it, and move the product libffi.a to this directory.

For Python, you need openSSL.framework and libssh2.framework. They are available as part of Blink or in libssh2-for-iOS.

For python to make system calls, we use the ios_system framework. Download it, compile, and it will be linked with python.

The system commands available depend on a list of #define at the start of ios_system.m.

Installation (on your device)

Once you have compiled the Python-ios framework, you can link it with your favorite app (I've done it with Blinkshell, OpenTerm and iVim).

You will need to transfer the Python scripts to your device:

Also transfer the scripts:

Then, install a few useful modules:

(Other pip calls are up to you).

Inside Python, you can call the shell commands defined by the frameworks: ls, cat, grep...

In the shell, you can use all Python scripts: pydoc, which.py, diff.py...

Installing new packages

To install more packages, you have to try different options, in order of complexity:

Mercurial

To install mercurial:

(you can't use pip because pip will try to compile, so you have to do a "pure" install, using only Python).

Mercurial will use your SSH keys, stored in ~/Documents/.ssh/ You can create them using Blink "config", then save them to ~/Documents/.ssh/ using ssh-save-id [name-of-the-key]. You will also have to upload the public key on your server (e.g. Bitbucket). Finally, you will either need the CAcert certificates or disable mercurial "clonebundles" extension: hg --config ui.clonebundles=false

Your Mercurial configuration file is stored in ~/Documents/.hgrc (you don't have the right to write in ~/.hgrc in iOS, unless it's jailbroken). You can place it elsewhere if you change the value of the $HGRCPATH environment variable.

Once you've done that, you're done. Try hg clone your-repository.