maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Python & Qt5 on Sailfish (https://talk.maemo.org/showthread.php?t=91049)

rcolistete 2013-10-25 12:13

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by xerxes2 (Post 1382004)
I think that pyotherside works with python2 also but it's highly recommended to stick with three!

See post #3 about thp hint to use Python 2.x. I have myself modified PyOtherSide QML plugin to use Python 2.7 on Sailfish, just to test. But I am using Python 3.3 in my current project.

thp 2013-10-25 13:21

Re: Python & Qt5 on Sailfish
 
Some more example code to help you get you started with Python 3 + Qt 5 + PyOtherSide on Sailfish OS:

https://github.com/gpodder/gpodder-sailfish

This might be a bit confusing for newcomers, as gPodder's source tree is now split over multiple Git repositories. If there's interest, I might do a more minimalistic and self-contained example of packaging PyOtherSide apps with Sailfish OS.

As far as Python 2 vs Python 3 is concerned: For new projects on Sailfish OS, use Python 3, as Python 2 is slowly going away (also see PEP 404 and PEP 373 for an idea of how upstream Python sees it - the last planned maintenance release of 2.7 at the moment is May 2015, which is only one and a half years away). I won't make it harder than necessary to build PyOtherSide against Python 2, and patches to improve compatibility are welcome, as long as it doesn't make maintaining the Python 3 version more complicated.

Tools like 2to3 make it really easy to migrate existing Python 2 code to Python 3, and if you've read through python2sucks, you should actually be quite happy that we have Python 3.3 in mer-python3 now ;)

If you've ported your Python app to Sailfish OS already, feel free to post screenshots and a link to the Git repo or website (if available) here in this thread, and consider adding/forking it to https://github.com/sailfishapps so it's easily discoverable.

mattaustin 2013-10-25 14:35

Quote:

Originally Posted by thp (Post 1382374)
you should actually be quite happy that we have Python 3.3 in mer-python3 now

Thanks Thomas! Great to see gPodder leading the way!

I'm keen to make the switch to Python 3 as soon as it is practical. My code is now Python 2/3 compatible :).

However, I also feel where possible, it might be best to make use of the officially supported packages which are part of the target platform, and Sailfish is still on Python 2.7.

An example of this is the python-lxml package, which I require for my app. It's available on Sailfish, but for python 2.7. Do you have any tips on how to handle these situations when packaging for Sailfish?

For development purposes I set up a Python 3 virtualenv in the Sailfish emulator, and installed lxml manually.

Also, I have run in to ssl problems when using Python in mer-python3. It could be that I need to install some more libraries, but openssl is already installed.

Cheers!


Shameless screenshot:
https://pbs.twimg.com/media/BWnWMYVCQAAhf8a.png:large

xerxes2 2013-10-25 15:04

Re: Python & Qt5 on Sailfish
 
I can't seem to build python packages as user in the sdk. Anyone else noticed this?
Code:

+ /usr/lib/rpm/meego/brp-python-hardlink
ln: creating hard link `/home/mersdk/rpmbuild/BUILDROOT/sip-4.15.3-1.i386/usr/lib/python2.7/site-packages/sipdistutils.pyo' => `/home/mersdk/rpmbuild/BUILDROOT/sip-4.15.3-1.i386/usr/lib/python2.7/site-packages/sipdistutils.pyc': Operation not permitted

It must be possible to build packages as user right? Building as root seems to work just fine though. Been using linux since 1998 but can't recall ever having used a hard link before. :)

xerxes2 2013-10-25 15:23

Re: Python & Qt5 on Sailfish
 
@mattaustin

Yeah that is the problem with going with python3, that you will have to hunt down libs and bindings yourself. :) Do you mean pyopenssl?
https://launchpad.net/pyopenssl

They exist in sailfish for py2 but if you need them for py3 you'll probably have to build them yourself ... or hunt them down in some third party repo.

xerxes2 2013-10-27 16:58

Re: Python & Qt5 on Sailfish
 
The hard link problem seems to be an issue with vbox in your homedir. It's proably fixable somehow but for now I just switched to using symlinks instead in /usr/lib/rpm/meego/brp-python-hardlink :
Code:

ln -sf $(basename $pyc) "$pyo"
After that I ran into another problem that rpm whined about wrong owner/group but I manage to fix that so now I can happily build python packages as user. And I packaged pyqt for arm too:
Code:

zypper ar http://enlisy.org/~xerxes2/pkg/sailfish/armv7hl/xerxes2-sailfish-armv7hl.repo
zypper ref
zypper in pyqt

I have no working hardware to test arm packages, still waiting for sailfish image for the n950 :), so the packages are completely untested. But built with the same spec files as i586 so hopefully they work just fine.

rcolistete 2013-11-10 18:29

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by rcolistete (Post 1367517)
PyOtherSide for Qt5 and Python 3.3, from thp, was updated on August 8th 2013, has better documentation and 4 examples :
http://thp.io/2011/pyotherside/
https://github.com/thp/pyotherside
http://thp.io/2011/pyotherside/doc/classQPython.html
Read here the motivations of thp about PyOtherSide on Qt5.
To use Python 2.x instead of Python 3.3 with PyOtherSide, see thp hint.

So Python developing on Sailfish is again possible, using Qt 5/Qt Quick 2 for GUI and Python for computing, glued by PyOtherSide.

Thomas Perl presentation about PyOtherSide in Qt Developers Day 2013 (Berlin) is available :
"Python 3 and Qt 5 with QML" abstract
"Python 3 and Qt 5 with QML" PDF presentation

mikecomputing 2013-11-10 19:25

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by rcolistete (Post 1385507)

hmm no video recording from the event?

EmaNymton 2013-11-17 15:48

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by mattaustin (Post 1382385)
An example of this is the python-lxml package, which I require for my app. It's available on Sailfish, but for python 2.7. Do you have any tips on how to handle these situations when packaging for Sailfish?

For development purposes I set up a Python 3 virtualenv in the Sailfish emulator, and installed lxml manually.

I'm facing the same problem here, I need lxml for python 3. I'm not that expirienced in installing packages without using the repository. Is there any repo in the meantime, which I can use and if not, could you please describe a little more detailed what to do, so I can start coding? Thanks in advance!

rcolistete 2013-11-18 11:53

Re: Python & Qt5 on Sailfish
 
Any experience here to be shared about submitting Python software to Jolla Harbour ?


All times are GMT. The time now is 01:47.

vBulletin® Version 3.8.8