ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #17587
Re: Packaging Python app as click package
On Sat, January 9, 2016 2:29 pm, Sam Bull wrote:
> I'm trying to package a Python app as a click package, what do I need
> to make this work?
>
> Is it just a case of including the interpreter and libraries as part of
> the package, and setting my .desktop file to 'Exec=./python myapp.py'
> (assuming the Python binary to be in the root of the click package)?
>
> Also, what's the easiest way to get hold of the armhf binaries? I've
> been testing by just copying the files out of /usr/bin/python3 and
> /usr/lib/python3/ but obviously the binaries are amd64 on my laptop, so
> how would I get these files for armhf? Maybe copy them out of a VM?
>
> And, is the installed app location read-only? Specifically, is it
> better for me to include the __pycache__ in the package for
> performance, or will it be able to create it's own when it is run?
> (This saves about 6-7% of the package size)--
Hi Sam
I don't know what is best practice, but I've packaged GemRB, which is a C
and C++ program which calls python modules. I've taken the naive approach
and dumped an almost entire python runtime into a subdirectory of the
click and used a setup script ("run.sh") to set some environment variables
to point to the runtime. If I knew exactly what python libraries were
going to be called, I could probably trim the directory size
substantially. I would have to rethink the structure if I was going to
reformulate the .click as a "fat" package with AMD64 and i386 as well as
the ARM binaries.
To obtain the python files, I set up a full ARM chroot environment as per
https://adoptingubuntu.wordpress.com/2015/07/10/creating-an-emulated-armhf-chroot-for-development/
and simply copied the python runtime files across. I've found it is quite
difficult to install all the python runtime in a traditional click chroot
as there are a lot of dependency issues between the amrhf and the amd64
packages, so a full chroot (as linked) has been easier. I'm sure there
will be some way to trick apt-get into downloading the armhf files without
going to such lengths, but I have the chroot anyway so it is a shame not
to use it.
My app is called "bg1" and is up on the store. Feel free to have a poke
around: a click package can be expanded by running "dpkg-deb --extract
packagename.click .". If you find a better way to package python, let me
know. I'm sure my method could be improved.
Good luck
NMP
Follow ups
References