Skip to content

Progdrasil/pyo3-buildozer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PYO3 on android

This is an example of building a PYO3 Library using buildozer.

Docker build

You can build the buildozer image with the following command:

docker build -t buildozer -f buildozer.Dockerfile .

You can then start a build from outside the container with the following command:

docker run --rm -v "$(pwd)":/home/user/hostcwd buildozer android debug

However the easiest way to deal with buildozer through docker is to run it interactivelly by entering it with bash. To run on a device from docker you need to mount the usb bus to the container in priviledged mode. Putting it all together looks like so:

docker run --rm -v "$(pwd)":/home/user/hostcwd -v /dev/bus/usb:/dev/bus/usb --privileged -it --entrypoint=bash buildozer

Now you can run any of the buildozer commands. The most usefull ones are to build

buildozer android debug

And to deploy run and print the debug logs. For debugging it is easiest to redirect to a file for later analysis.

buildozer android deploy run logcat > out.log

Troubleshooting

If you are getting a runtime error of ImportError: dlopen failed: cannot locate symbol "PyExc_BaseException" or the same but for _Py_NoneStruct there is a workaround while the issue is being treated upstream.

You must link to the m of libpython by either setting the rust flags in a .cargo/config or as the RUSTFLAGS environement variable at build time.

.cargo/config

[target.aarch64-linux-android]
rustflags = [ "-C", "link-args=-L<LD_LIBRARY_PATH> -lpythonX.Ym"]

[target.armv7-linux-androideabi]
rustflags = [ "-C", "link-args=-L<LD_LIBRARY_PATH> -lpythonX.Ym"]

Or as we do here, the RUSTFLAGs="-C link-args=-L<LD_LIBRARY_PATH> -lpythonX.Ym" variable is set in the Python for android recipe.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published