Programming languages: Python apps might soon be running on Android

Python developers push for Python-built applications running on mobile devices, but big obstacles remain.
Written by Liam Tung, Contributing Writer

Thanks in part to the rise of machine learning, programming language Python is hugely popular with developers, but so far mobile devices have been no place for Python applications.  

Yet Python creator Guido van Rossum and some Python developers hope that apps written in Python may one day run natively on iOS and Android devices. That could happen thanks to BeeWare, an open-source project headed up Russell Keith-Magee, which is porting CPython to Android, so apps written in Python can run natively on Android.

In February, Keith-Magee announced the project's first major Android milestone after getting a 'pure' Python application to run on an Android device. He gave an update at the 2020 Python Language Summit, which was held online this year due to the coronavirus pandemic.

SEE: Six in-demand programming languages: Getting started (free PDF)

BeeWare is aiming to let developers write apps in Python and get that code running everywhere using user interface (UI) widgets. It wants to help developers write Python apps using the same codebase running on iOS, Android, Windows, macOS, Linux, browsers, and tvOS. 

CPython is the reference implementation of the open-source Python language used by other implementations such as Jython, which is written in Java that relies on a Java virtual machine (JVM). But Python is not cut out for mobile in the way it has been for desktop systems.

To address this shortcoming, last year the Python Software Foundation awarded the BeeWare project a $50,000 grant to bring its level of Android support up to par with its tools for iOS. The CPython Android port would have to support most modern Android hardware running version 4.4 or later.  

"BeeWare's Android strategy was to compile Python to Java bytecode, but Android devices are now fast enough, and the Android kernel permissive enough, to run CPython itself," said A Jesse Jiryu Davis, an engineer at MongoDB and a Python contributor

Davis said a major obstacle was the size of Android apps written in Python because they require their own copy of the Python runtime, meaning Python needed to be shrunk down for mobile. 

Some have suggested solving this problem by creating a stripped-back 'kernel' version of Python – an idea that Keith-Magee believes could solve many Python mobile challenges, in combination with a package installer (pip) that lets developers install packages for a target platform rather than just the system it's running on. 

"To regular Python programmers, the mobile environment is an alien planet," explains Davis.  "There are no subprocesses; sockets, pipes and signals all behave differently than on regular Unix; and many syscalls are prohibited. 

"TLS certificate handling on Android is particularly quirky. For the CPython test suite to pass on mobile, it must skip the numerous tests that use fork or spawn, or use signals, or any other APIs that are different or absent."

SEE: Data science interest spikes with COVID-19: Here are the online courses to get you started

Keith-Magee reckons more mature Android support means CPython contributors "can have a serious conversation about how we get these changes merged into CPython itself". So now the question is whether CPython developers will be interested in bringing mobile Python into the core.  

The good news is that van Rossum has endorsed mobile support in the long term, according to Davis. 

But there are big obstacles. According to Ned Deily, a Python core developer at PSF, delivering mobile support will require more money and people than many other Python initiatives. 

On top of this, Davis notes that Python has a chicken and egg problem on mobile: "There is no corporate funding for Python on mobile because Python doesn't support mobile, so there is no one relying on mobile Python who is motivated to fund it."

More on Python and programming languages

  • Programming languages: Python developers reveal what they use it for and their top tools  
  • Microsoft: Our new free Python programming language courses are for novice AI developers  
  • Goodbye Python 2 programming language: This is the final Python 2.7 release  
  • PyCharm: Here's what Python programming language developers get in new IDE update  
  • New programming language rankings: Python now as popular as Java, as TypeScript climbs  
  • Programming languages: Java developers flock to Kotlin and ditch Oracle JDK for OpenJDK  
  • Programming language popularity: Apple's Objective-C tumbles down the rankings  
  • Programming languages: Go and Python are what developers most want to learn  
  • Know Python language and up for a 'hardcore' coding test? Get in touch, says Tesla  
  • Java or C++, Full stack or Front end: The programming languages and developer jobs that pay you the most  
  • Google reveals new Python programming language course: Scholarships for 2,500  
  • Microsoft boosts programming language Python's popular VS Code extension  
  • Programming language of 2019? Python beaten by trusty old C  
  • Programming language Python's popular extension for Visual Studio Code revamped  
  • Programming language Python 2.7 code is now frozen: Last release coming in April  
  • Netflix: Our Metaflow Python library for faster data science is now open source  
  • Tech jobs: Python programming language and AWS skills demand has exploded  
  • Python programming language creator retires, saying: 'It's been an amazing ride'
  • Programming languages: How Instagram's taming a multimillion-line Python monster
  • Salesforce: Why we ditched Python for Google's Go language in Einstein Analytics  
  • Microsoft: We want you to learn Python programming language for free
  • JPMorgan's Athena has 35 million lines of Python code, and won't be updated to Python 3 in time TechRepublic
  • Mozilla's radical open-source move helped rewrite rules of tech CNET
  • Editorial standards