This is a ctypes (back)port for Python for S60 (PyS60). Building has only been tested with an S60 3rd Edition SDK.
The idea here is simply to take the latest ctypes and try and get it to work with PyS60. This means both backporting a Python 2.5.1 module to (a modified) Python 2.2.2, and to get it running on Symbian OS.
Something works, or at least used to work on some devices (a lot
depends on the rather platform and architecture specific libffi
library, without which functions cannot be called). Callbacks to
Python are not supported. There are compiler warnings. Static
writables have not been removed. __init__.py
is not yet fully
ported, and hence some of the API is unavailable.
As with the Open C implementation of libdl
, address lookups are by ordinal, not by symbol name. This is limitation is due to Symbian OS. To determine ordinals in a Unix environment, you can say use the nm
command on the relevant library file. Ordinals can be passed in as a numeric string.
Open C includes libcrypto
, and it is possible to say use its message digest algorithm via ctypes, as shown below. This example could be made to look nicer if the library was fully working.
import ctypes import _ctypes h = _ctypes.dlopen("libcrypto.dll") try: sha = _ctypes.dlsym(h, "1491") data = "digestible message" result = ctypes.create_string_buffer(20) _ctypes.call_function(sha, (data, len(data), result)) print ctypes.sizeof(result), repr(result.raw) finally: _ctypes.dlclose(h)
The ported software was originally extracted from the Python 2.5.1 codebase, before modifications. Python 2.5.1 is covered by the PSF v2 license. The changes made for the port are minor, and are released under the original license.
A collection of release builds is available. The sisx
file without a version number is the latest release.
A tarball of the source code is also available.
This software is no longer being maintained (it never really was).
Depends on both Open C and Python for S60. Does not depend on non-public APIs or anything exotic. Also depends on libffi for Symbian OS. Open C, Python, and libffi must all be installed on the target device to run this software. Open C will be built in starting from S60 3rd FP2.
For building, an S60 3rd Edition SDK, the Open C plugin, and the PyS60 plugin is required. The libffi LIB and header files are required as well, and this is easiest to arrange by building the libffi library once on the development machine.
The port was done in the Services for All (E!2023 ITEA S4ALL) project at HIIT.
Tero Hasu
tero.hasu@hut.fi