Packaging Kivy app for Android

263 views
Skip to first unread message

srini

unread,
Apr 24, 2013, 7:25:40 PM4/24/13
to kivy-...@googlegroups.com
I have a small Kivy app that runs well on my Linux host. I have packaged it following the instruction that came with Kivy documentation. When I launch the application on my handset it crashes and the reason for the crash is 'pytz module not found'. In my app I am importing swisseph, math, collections, time, pytz, datetime and difflab modules. Do I specify all these modules when I run the 'distribute.sh' command or am I to do something else? BTW, I tried specifying the 'pytz' module in '-m' while executing the 'distribute.sh' command and it complained that there is no recipe. Any help here is much appreciated.

Gabriel Pettier

unread,
Apr 24, 2013, 8:06:46 PM4/24/13
to kivy-...@googlegroups.com
Hi

for each dependencies, you have to consider the situation:

if it's a pure python module, you can just drop it in your app dir, it
will be able to be imported just like this.

if it needs compilation, you need to write a recipe to download and
build the module automatically, look into the recipes directory in
python-for-android, and the online doc, it should give you indications
on how to do that, they aren't very detailed, but there are the other
recipes as examples. When your recipe is done, you can use it with -m as
you tried.

Good luck.
> --
> You received this message because you are subscribed to the Google Groups "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

srini

unread,
Apr 24, 2013, 8:13:30 PM4/24/13
to kivy-...@googlegroups.com
Thanks for the quick response. It is very helpful. Which of the modules I am using (swisseph, math, collections, time, pytz, datetime and difflab) would you consider as a pure python module? What makes any module a pure python module?

Niko Skrypnik

unread,
Apr 25, 2013, 3:21:17 AM4/25/13
to kivy-...@googlegroups.com
Hi srini!

Pure python module means that this module is written only on python language, but some modules may be written with using Cython e.g. or partly on C. So the idea is that you may use pure python modules in your app just putting it into your app directory(it will be packaged then and your app may reach it on android device). But modules which are not "pure" should be compiled first for target platform to make possible use it(but compilation for android may be non-trivial in fact and some python libs should be patched before building).

In that list you wrote many modules(math, collections, time, datetime and difflab) are included in python distribution which is compiled while you are making package, so it's not a problem to use it in your app, cause your package always has compiled python interpreter with its modules, but for swisseph and pytz you should check whether thees modules contains any C extension should be compiled before using.

четверг, 25 апреля 2013 г., 3:13:30 UTC+3 пользователь srini написал:

Gabriel Pettier

unread,
Apr 25, 2013, 3:38:26 AM4/25/13
to kivy-...@googlegroups.com
math/collections/time/datetime are in the stdlib, so you don't need to
do anything about them, they are already shipped.

Now, for swisseph, pytz and difflab, you need to look at the way they
need to be installed, if all of their code is python code, their
procedures doesn't require starting a compilator, you should be safe in
just adding them (provided they don't have themselves any dependency
that's not there already, or you need to do the same with the
dependencies).

swisseph (https://pypi.python.org/pypi/pyswisseph) lists C in its
programming language used, so i guess it needs compilation, it's not
pure-python.

pytz (https://pypi.python.org/pypi/pytz/), on the other hand, only lists
python, and declare itself os-independant, so i guess it only uses
things already in python.

I wasn't able to find a "difflab" module in my quick search, but if you
are talking about difflib, it's in python standardlib already.

I guess your main issue will be swisseph, that you need to look at how
to build and do a recipes that do that.

good luck.
> > an email to kivy-users+...@googlegroups.com <javascript:>.

Niko Skrypnik

unread,
Apr 25, 2013, 3:55:12 AM4/25/13
to kivy-...@googlegroups.com
The fastest way to see if module is pure python or not - have a look in setup.py. If module have some C extension you may see appropriate instructions in setup.py to build thees extensions. So fast look at setup.py says that pytz is pure python, but swisseph is not due to this code:

# Extension
swemodule = Extension(
    'swisseph',
    include_dirs = ['src', 'swephelp'],
    extra_compile_args= ['-std=gnu99'],
    sources = [
        'pyswisseph.c',
        'swephelp/swhdatetime.c',
        'swephelp/swhformat.c',
        'swephelp/swhsearch.c',
        'swephelp/swhraman.c',
        'swephelp/swhgeo.c',
        'swephelp/swhutil.c',
        'src/swecl.c',
        'src/swedate.c',
        'src/swehel.c',
        'src/swehouse.c',
        'src/swejpl.c',
        'src/swemmoon.c',
        'src/swemplan.c',
        #swemptab.c
        'src/swepcalc.c',
        'src/sweph.c',
        'src/swephlib.c'
        ]
    )

So good luck to port this code to android ;-).

четверг, 25 апреля 2013 г., 2:25:40 UTC+3 пользователь srini написал:

srini

unread,
Apr 25, 2013, 8:53:05 AM4/25/13
to kivy-...@googlegroups.com
Thank you very much providing detailed guidance. Any hints on how to port the segment you have identified to Android?

Niko Skrypnik

unread,
Apr 25, 2013, 10:31:03 AM4/25/13
to kivy-...@googlegroups.com
Uhm, sorry, but I didn't such thing, only know that you should follow Gabriel's instructions.


--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/6s_gSEgBek4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards. Niko Skrypnik.
Reply all
Reply to author
Forward
0 new messages