PDA

View Full Version : Python & Qt5 on Sailfish


rcolistete
2013-08-15, 20:45
***********************************************

See Sailfish/Python Development wiki page (https://wiki.merproject.org/wiki/Sailfish/Python_Development) and post#83 (http://talk.maemo.org/showpost.php?p=1424946&postcount=83) for recent news about Python 3, PyOtherSide and PyQt5 for Sailfish.

***********************************************

Here in this topic we can discuss programming with Python & Qt5 on Sailfish OS. Since Sailfish SDK alpha 2 it needs Qt5 and Wayland (no X11 at the moment), Python (with GUI) has to find some solution to run on Sailfish (XWayland, PySide / PyQt for Qt 5 or PyOtherSide).

Bringing some comments from other topic (http://talk.maemo.org/showpost.php?p=1360402&postcount=755) :
==========================================
The current situation for mobile developers from Maemo/MeeGo/Nemo Mobile to Sailfish pathway is IMHO :

1) softwares in C/C++/Qt 4.7-4.8 (Qt Quick 1) : about 80-90% of MeeGo Harmattan and Nemo Mobile softwares, just some % of Maemo 5 softwares. Anyway due to migration from GUI written in (Harmattan, etc) Qt Quick components to Sailfish Silica (Qt Quick components for GUI in Sailfish OS) (https://sailfishos.org/sailfish-silica/), there is a need of small-medium source code revision & rewrite. There are 2 options for Qt5/Wayland migration :

1.a) XWayland (X11 running as a Wayland client) (http://wayland.freedesktop.org/xserver.html) be available by Jolla and/or community, so all Qt 4/X11 softwares will remain compatible. Jolla said "just to clarify, while we don't support xwayland atm, we're not ruling out the possibility in future..." (https://twitter.com/JollaHQ/status/356349925543526401). It seems XWayland source code isn't long, just some hundreds of lines of code (http://www.phoronix.com/scan.php?page=news_item&px=MTEwNTc). So, as Jolla itself is open to include XWayland (with the community help, i.e., in Nemo Mobile Wayland effort) and XWayland is a lot smaller than Wayland, I think it is possible to have XWayland ready on Sailfish OS until the end of 2013 (but not included in the Sailfish SDK beta which is soon to be released);

1.b) migrate to Qt 5/Qt Quick 2, which seems to be easy, with minor source code revision & rewrite, then recompile. This work may be worth to also release Qt 5 versions for Ubuntu Touch, Android and iOS (changing from the Qt components from Silica to Qt Components for Ubuntu or Qt Quick Controls);

2) softwares in Python/PySide/Qt 4.7-4.8 (Qt Quick 1) : only about 10-20% of MeeGo Harmattan and Nemo Mobile softwares, just some small % of Maemo 5 softwares. But Python is important, allowing party-time developers to code on device (N900, N9, etc), anytime, anywhere, and contribute to the software diversity. The same migration from Harmattan (etc) Qt Quick components to Sailfish Silica is needed, with small-medium source code revision & rewrite. There are more options for Qt5/Wayland migration, none ready at the moment :

2.a) the same (1.a) option, i.e., release XWayland for Sailfish OS, so PySide and Qt 4.8 could be used in Sailfish as in Sailfish SDK alpha;

2.b) port PySide to Qt5/Qt Quick 2 (http://comments.gmane.org/gmane.comp.lib.qt.pyside/4549), which has no timeline and is a huge task needing contribution. This effort would benefit Sailfish, Ubuntu Touch, Android and iOS developing in Python/Qt5/Qt Quick 2. So it is expected that Jolla will not contribute (alone) for this huge work;

2.c) use a future PyQt 5 version, because the current one excludes Qt Quick 2 (http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html). There is also the issue of GPL license and release PyQt 5 for Mer/Nemo/Sailfish;

2.d) use PyOtherSide from thp, which will have a version for Qt5/Qt Quick 2 released soon (http://thpmaemo.blogspot.co.at/2013/07/the-way-forward-with-python-on-qt-5.html). It is not a Qt 5 full binding for Python, but it seems a way to code (the GUI) in Qt Quick 2 and call Python from it (so Qt5 is not available from Python, only Python is available from Qt5/Qt Quick 2). As advantages, PyOtherSide is smaller, faster to load and is/will be multiplataform (Symbian, Android, MeeGo, Sailfish, Ubuntu Touch, etc).

So, non-Python developers have a migration path currently available to Qt5/Wayland on Sailfish. Only Python developers are in a wait-to-see/code situation, the easier one seems to be PyOtherSide (2.d).

About the change from Sailfish SDK alpha (with Qt 4.8 & X11) to Sailfish SDK beta (Qt 5 & Wayland) : yes, it is a bad surprise for developers who have already ported/created softwares using Sailfish SDK alpha. But currently there are a very small number (10-20) of softwares written for Sailfish, see the app list in Sailfish - Mer Wiki (https://wiki.merproject.org/wiki/Sailfish). So this 'collateral effect' is small.

I trust the Linux/Maemo/MeeGo/Mer/Nemo/Sailfish community efforts so that more than one good solution will be available for developing Sailfish softwares.

I hope XWayland will be released on Sailfish, so X11 legacy will be available : ssh -X, chrooting Debian/etc, many Linux desktop softwares not Wayland compatible, etc.
==========================================

Other comments (http://talk.maemo.org/showpost.php?p=1360774&postcount=782) :
==========================================
More news about PyQt 5 and Qt 5/Qt Quick 2 support :
- PyQt 5.0.1 (next release) will have Qt Quick 2 support, and PyQt 5.1 will have Qt 5.1 support, see
PyQt and Qt 5.1 discussion (http://comments.gmane.org/gmane.comp.python.pyqt-pykde/25604).

So, in theory, PyQt 5.1 will give Python access to develop softwares (with GUI) for Sailfish, Ubuntu Touch, Android, iOS, etc. Obviously somebody needs to compile PyQt for them.

PyQt 5.0 was released in June 16th, I haven't found any estimate date for PyQt 5.0.1 and 5.1. But PyQt 5.0.1 is the current development snapshot (http://www.riverbankcomputing.co.uk/software/pyqt/download5), see the change logs which says "Completed the initial implementation of the QtQuick module" in July 20th (http://www.riverbankcomputing.co.uk/static/Downloads/PyQt5/ChangeLog-5.0.1-snapshot-2a99e59669ee).

We Python developers (for Sailfish, etc) should pay attention to PyOtherSide and PyQt 5.x developments.
==========================================

rcolistete
2013-08-15, 20:47
Python (modules) on Mer/Nemo (http://talk.maemo.org/showthread.php?t=88881) topic is also useful, citing Python modules available for Mer / Nemo, those which don't use X11 and Qt4 are usually compatible with Sailfish.

rcolistete
2013-08-15, 20:55
PyOtherSide for Qt5 and Python 3.3, from thp, was updated (https://twitter.com/thp4/status/365199488014487552) 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 (http://thpmaemo.blogspot.co.at/2013/07/the-way-forward-with-python-on-qt-5.html).
To use Python 2.x instead of Python 3.3 with PyOtherSide, see thp hint (https://twitter.com/thp4/status/365380484420747265).

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

rcolistete
2013-08-15, 21:00
An application of PyOtherSide to Sailfish is Khertan's ownNotes (http://talk.maemo.org/showthread.php?t=91003).
It has source code (in Python 2.7, QML and C/C++) for MeeGo Harmattan and Sailfish :
https://github.com/khertan/ownNotes
Khertan has made a PyOtherSide fork, using Python 2.7 :
https://github.com/khertan/pyotherside

mikecomputing
2013-08-15, 21:08
"2.d) use PyOtherSide from thp, which will have a version for Qt5/Qt Quick 2 released soon. It is not a Qt 5 full binding for Python, but it seems a way to code (the GUI) in Qt Quick 2 and call Python from it (so Qt5 is not available from Python, only Python is available from Qt5/Qt Quick 2). As advantages, PyOtherSide is smaller, faster to load and is/will be multiplataform (Symbian, Android, MeeGo, Sailfish, Ubuntu Touch, etc). "

For me this is the path to go in case of python+QML on embedded. I dont see any reason to have full access to QtWidgets bindings in python. If people want full QtWidgets, well time to learn C++ because QtWidget is only for "hiend applications" anyway and not something that runs on embedded.

And the rest of the goodies in Qt C++ can be replaced with other good librarys in python anyway.

And about Qt4 vs 5 my guess is keeping backward compability in this area is bad idea better let harmattanui die in favour of qt controls (less fragmentation). Qt5 is now moving incredible fast forward (soon 5.2 is out). So I think alot apps on linux desktop will also move to Qt5 2014.

Yes there will be alot of porting issues but not as big as between 3 => 4 it seems...

MartinK
2013-08-15, 23:41
I've checked out the updated PyOtherSide and can confirm that it looks very very well & all the examples work just fine (using Python 3.3 and Qt 5.1.2 on a PC). So I'll say PyOtherSide is most probably the future for Python & Qt5.

Basically the only thing missing in PyOtherSide for my use cases at the moment is image loading from Python data objects. So I've written a detailed feature request (https://github.com/thp/pyotherside/issues/1) and posted it at the Github issue tracker. :)
Looks like THP likes it, so it will hopefully soon be added to PyOtherSide.

Regarding my current development plans for Python & Qt5, I'm going to start working a PyOtherSide based Qt5 GUIs for modRana and Mieru, using the QtQuick Controls components. Like this the resulting GUIs should run just fine on Sailfish, Android, Ubuntu-Touch, Tizen, desktop Linux and once it gets Qt5 also on BB10.

Fremantle, Harmattan and other platforms (there are still people using up-to-date modRana on the Neo FreeRunner (http://en.wikipedia.org/wiki/Neo_FreeRunner), seriously! :) ) will be covered by the existing GTK and Qt4 GUIs (I'm not dropping those). Of course the Qt5 GUI will also run there, provided at least Qt5.1 (QtQuick Controls were added in Qt5.1) is available.

rcolistete
2013-08-16, 00:22
Regarding my current development plans for Python & Qt5, I'm going to start working a PyOtherSide based Qt5 GUIs for modRana and Mieru, using the QtQuick Controls components. Like this the resulting GUIs should run just fine on Sailfish, Android, Ubuntu-Touch, Tizen, desktop Linux and once it gets Qt5 also on BB10.

Do you think QQC components will work on Sailfish OS instead of using Silica components ?

MartinK
2013-08-16, 09:06
Do you think QQC components will work on Sailfish OS instead of using Silica components ?
They are a built-in part of Qt since 5.1, so they should be available. I hope they won't start stripping built-in Qt functionality any time soon. :)

Also, there is the AbstractUI (https://github.com/sailfishapps/AbstractUI-for-Sailfish-Silica) project, that should make it possible to write a single GUI that will use the native components of the given platform.

gianko
2013-08-16, 11:44
maybe you read already, but is an interesting post about

http://thpmaemo.blogspot.it/2013/07/the-way-forward-with-python-on-qt-5.html

"Lightweight can be achieved by not binding all the Qt classes, but only the ones you really need for creating QML applications. And responsive can be achieved by making sure that the interface between QML and Python is asynchronous, so the UI never blocks even if Python is working hard in the background to fulfill the requests of the user interface."

rcolistete
2013-09-27, 05:34
PyQt 5.0.1 was released in 21 August 2013 with support for QML and Qt Quick2 :
http://www.riverbankcomputing.co.uk/news/pyqt-501
* Added the QtQuick module including the ability to create Python Quick items from QML.
* Added the QtQml module including the ability to create Python objects from QML.

The current PyQt5 download is for v5.0.1 :
http://www.riverbankcomputing.co.uk/software/pyqt/download5
The "Development Snapshots" PyQt5 v5.1 is also available, compatible with Qt 5.1.

So, PyQt 5.1 will give Python access to develop softwares (with GUI) for Sailfish, Ubuntu Touch, Android, iOS, etc. Obviously somebody needs to compile & package PyQt for them.

Elleo
2013-09-27, 12:07
PyQt 5.0.1 was released in 21 August 2013 with support for QML and Qt Quick2 :
http://www.riverbankcomputing.co.uk/news/pyqt-501


The current PyQt5 download is for v5.0.1 :
http://www.riverbankcomputing.co.uk/software/pyqt/download5
The "Development Snapshots" PyQt5 v5.1 is also available, compatible with Qt 5.1.

So, PyQt 5.1 will give Python access to develop softwares (with GUI) for Sailfish, Ubuntu Touch, Android, iOS, etc. Obviously somebody needs to compile & package PyQt for them.

The issue is that PyQT is only available under either the GPL or a commercial license, so can't be used for non-GPL applications without paying for a commercial license, which is why PySide was created in the first place. That doesn't just mean it can't be used freely by commercial developers, but also that applications licensed under other open source (but not GPL compatible) licenses can't use it.

marmistrz
2013-09-27, 13:17
The issue is that PyQT is only available under either the GPL or a commercial license, so can't be used for non-GPL applications without paying for a commercial license, which is why PySide was created in the first place. That doesn't just mean it can't be used freely by commercial developers, but also that applications licensed under other open source (but not GPL compatible) licenses can't use it.
But, if you're a commercial dev, just stick with C++. You'd probably create python binaries too, and these are slower than c++ binaries. And coding on-device is not for commercial devs who are closed source. pyqt would be ok.

rcolistete
2013-09-27, 13:19
But, if you're a commercial dev, just stick with C++. You'd probably create python binaries too, and these are slower than c++ binaries. And coding on-device is not for commercial devs who are closed source. pyqt would be ok.

PyOtherSide is another option for commercial developers using Python and Qt5.

marmistrz
2013-09-27, 13:21
PyOtherSide is another option for commercial developers using Python and Qt5.

Yep, it's an option too.

xerxes2
2013-09-28, 16:38
PyQt 5.0.1 was released in 21 August 2013 with support for QML and Qt Quick2 :
http://www.riverbankcomputing.co.uk/news/pyqt-501


The current PyQt5 download is for v5.0.1 :
http://www.riverbankcomputing.co.uk/software/pyqt/download5
The "Development Snapshots" PyQt5 v5.1 is also available, compatible with Qt 5.1.

So, PyQt 5.1 will give Python access to develop softwares (with GUI) for Sailfish, Ubuntu Touch, Android, iOS, etc. Obviously somebody needs to compile & package PyQt for them.

Hey thanks for the heads up man. I just built the current snapshot of pyqt5 and it seems to work just fine with qtquick2. So for all you python coders out there it's just to start port to qt5/sailfish. :) Btw, anyone knows if Sailfish is still using python2?

xerxes2
2013-09-28, 16:44
I was using pyside before with my app panucci but porting to pyqt5/qtquick2 was not that hard. So far it's only namespace changes, haven't noticed anything else yet. And the rendering is ULTRA SMOOTH and this is under X. With Wayland on Sailfish it'll be even smoother if even possible. :)

mikecomputing
2013-09-28, 16:45
Hey thanks for the heads up man. I just built the current snapshot of pyqt5 and it seems to work just fine with qtquick2. So for all you python coders out there it's just to start port to qt5/sailfish. :) Btw, anyone knows if Sailfish is still using python2?

Not if you prefer LGPL over fanatic communist GPL3 license

xerxes2
2013-09-28, 16:48
I'm using gpl3 so no problem for me. If you want to make non open source apps you should use native code anyway. Pyside seems to be more or less dead so for me pyqt will do the trick on Sailfish.

mikecomputing
2013-09-28, 16:53
I'm using gpl3 so no problem for me. If you want to make non open source apps you should use native code anyway. Pyside seems to be more or less dead so for me pyqt will do the trick on Sailfish.

My apps is open too but thing is I don't like licenses that restricts other todo what they want with my code cause of facists licenses like GPL3. Its just as stupid as fully closed source.

Anyway just my opinion. Let go back to ontopic. There also is pyotherside :)

xerxes2
2013-09-28, 17:03
Yes please stay on topic. Pyqt is not likely to switch license so we will have to live with gpl. I'm using some other stuff of qt outside of qml so I'd rather use pyqt than pyotherside. But yes, I could probably use pyotherside too without too much work. I'm using lots of qactions though so I guess I'd have to replace those with something else.

rcolistete
2013-09-28, 18:05
Hey thanks for the heads up man. I just built the current snapshot of pyqt5 and it seems to work just fine with qtquick2. So for all you python coders out there it's just to start port to qt5/sailfish. :) Btw, anyone knows if Sailfish is still using python2?

Have you built PyQt5 for Mer/Sailfish ? I am very interested to have it available in some Mer repository.

Yeah, Sailfish uses Python 2.7.3, see :
http://talk.maemo.org/showthread.php?t=89294

xerxes2
2013-09-28, 18:34
No I've only built it for my own x86 box with python2 under X. I'm only using raw qml so now I only have to figure out what Sailfish's top window is called and wrap it in that. But yes as far as I can tell the pyqt-5.1 snapshot works just fine with qt-5.1 and qtquick2 so the Sailfish package maintainer for pyqt might as well update it.

Edit: Sailfish's top level window is called ApplicationWindow.

rcolistete
2013-09-30, 13:44
thp posted about PyOtherSide in SailfishOS Devel mailing list :
https://lists.sailfishos.org/pipermail/devel/2013-September/000782.html

Hi,

On Sep 30, 2013, at 1:08 PM, Matt Austin <mail at mattaustin.me.uk> wrote:
> It looks like we might now have a couple of possible options with Python apps on Sailfish with Qt5:
>
> 1) PyOtherSide: http://thp.io/2011/pyotherside/
>
> 2) PyQt 5.0.1: http://www.riverbankcomputing.com/news/pyqt-501
>
> I've been playing around today, and unfortunately was unable to get either installed nicely on the Sailfish VM. PyOtherSide requires Python 3 (which as far as I can tell is not available in the Sailfish VM), and I thought I managed to get PyQt to make/install, but then I just got symbol errors when I tried to import the modules.
>
> Obviously I'm not very good at compilation/linking/dependencies/flags/headers etc. (I am a python user after all :P ). So I was wondering if there are any plans to add either PyOtherSide or PyQt5 to the sailfish repos?


I can't say too much about PyQt, as I haven't used it myself. For PyQt, you might have to package it yourself, but be aware of PyQt's licensing: http://www.riverbankcomputing.com/software/pyqt/license

The rest of this mail deals with PyOtherSide:

It's available in the mer-python3 repository:
https://build.merproject.org/project/show?project=mer-python3

In the sb2 target and on a device, you can add that repo using:
zypper ar http://repo.merproject.org/obs/mer-python3/latest_armv7hl/mer-python3.repo

In the Emulator, you can add that repo using:
zypper ar http://repo.merproject.org/obs/mer-python3/latest_i486/mer-python3.repo

After that (and a possible "zypper ref"), you can install the QML Plugin in the emulator using:
zypper in pyotherside-qml-plugin-python3-qt5

If you are packaging an application, you should also add this to the RPM .spec file (as QML dependencies are not auto-detected):
Requires: pyotherside-qml-plugin-python3-qt5

Be aware that this is a run-time dependency, so you don't really need to install the QML plugin in your SDK target (it doesn't need to be available at build-time), only on the emulator and on the device where you actually run the application.

The sources are available here:
https://github.com/mer-python3/

The API documentation is here:
http://thp.io/2011/pyotherside/doc/classQPython.html

Some basic usage examples are here:
https://github.com/thp/pyotherside/tree/master/examples

If you're coming from PySide on Harmattan, it's a totally different setup -- instead of launching a Python interpreter that then loads the PySide bindings, which then resolve all Qt symbols that have bindings (takes a long time), you start out with a normal QML application (startup speed = same as C++ QML application) and then import the PyOtherSide QML plugin there (only loads libpython), and once the UI is up (i.e. the user can see your application window), you can then start loading Python modules, etc..

Also, try to avoid the synchronous functions, and use the asynchronous API instead (see PyOtherSide's documentation for examples). Think of your Python code as the "data backend implementation" for your QML UI, and think of your QML code as your main application. Or in other words, "QML uses the services of Python for its backend", instead of "Python uses the services of QML for its frontend".

Also, it's Python >= 3.3 only at this point. See http://www.python.org/dev/peps/pep-0404/ and https://github.com/thp/python2sucks to figure out why this is a very good idea and why you want to have that.

Protip: If you want to have a Python 3 interpreter to play with on the command line, install "python3-base" from that repository.

HTH :)
Thomas

xerxes2
2013-10-02, 21:29
Pyqt-5.1 was released today.
http://riverbankcomputing.co.uk/news/pyqt-51d

Seems to work just fine so far. Had some rendering problems earlier but that turned out to be a gpu driver problem but I upgraded my graphics stack, and now it runs smooth as silk. :) Qml2 runs in opengl, on linux at least, so your drivers must support that.

Outside of namespace changes the only problem I've run into so far has been that you have to use super() with multiple inheritance in pyqt5. And I can't for my life get my friggin imageprovider to work. The requestPixmap method somehow takes one parameter less than it should and then qml just spits out "TypeError: invalid result type from ImageProvider.requestPixmap()". I've tried anything I can possibly think of in my own code ... could be a bug in qt or pyqt. Other than that it seems to work just fine. Hopefully it works good on arm/wayland too on Sailfish.

MartinK
2013-10-08, 19:30
PyOtherSide side now supports Python image providers ! :)
About three days ago, THP added support for Python image providers, based on my initial proposal (https://github.com/thp/pyotherside/issues/1). :)

It is now possible to register an image provider in the Python part of the code that handles the standard "image://" image URIs used in QtQuick.

Once a URI in the form of "image://python/*" is used, the Python provider is called and Python code can provide image data for the given URL.
The data might among others:

come from a file a file loaded by Python
come from a file like object extracted from an archive (zipfile, tarfile, etc.)
come from a blob stored in a sqlite database
be manipulated by some library before being passed to QtQuick
or be outright generated on the spot by Python


As QtQuick without a C++ backend can only load images from files, QtResource files or from Network, this adds quite some flexibility to PyOtherSide applications. :)

The Python-side image provider
Taken from a source code comment, the Python image provider might look like this:

#Image provider implementation in Python:

import pyotherside

def image_provider(image_id, requested_size):
if requested_size == (-1, -1):
requested_size = 100, 200 # some sane default size
width, height = requested_size
pixels = ... # get the image data from somewhere
format = pyotherside.format_argb32 # or some other format
return (bytearray(pixels), (width, height), format)

pyotherside.set_image_provider(image_provider)


The QtQuick side might then look like this (for clarity not showing the QML code needed to load the needed Python code):

import QtQuick 2.0

Image {
id: image
width: 300
height: 300
source : "image://python/foo"
}



Examples
For more detailed source code examples, check the various THPs image provider examples:
image_loader (https://github.com/thp/pyotherside/tree/master/examples/image_loader)
imageprovider (https://github.com/thp/pyotherside/tree/master/examples/imageprovider)
imageprovider_data (https://github.com/thp/pyotherside/tree/master/examples/imageprovider_data)
mandelbrot (https://github.com/thp/pyotherside/tree/master/examples/mandelbrot)

The mandelbrot fractal example is actually very clever. :)

http://modrana.org/images/misc/pyotherside_madelbrot.png

The fractal image in the qmlscene window can be both panned and zoomed in and is fully generated by Python code, based on coordinates passed as part of the image:// URI.

MartinK
2013-10-12, 17:11
You can use PyOtherSide and PDB !

I kinda wondered how to debug the Python part of a PyOtherSide application - I expected it would be difficult as the Python "backend" is loaded and started from Qt.

Then I got an idea - what about PDB (http://docs.python.org/3.3/library/pdb.html) ?

I though: "No way it would work out of the box, the input/output will probably end in /dev/null or worse."

But, well, it works just fine ! :D

Just create a file named, say, pdb.qml:


import QtQuick 2.0
import io.thp.pyotherside 1.0

Rectangle {
color : "green"
width : 640
height : 480
Text {
text : "hello PDB!"
}

Python {
id : python
Component.onCompleted: {
importModule('pdb', function() {
call('pdb.set_trace()')
})
}
onError: {
// when an exception is raised, this error handler will be called
console.log('python error: ' + traceback);

}
}
}


And run it with qmlscene:
qmlscene pdb.qml

And voila, pdb will be started in the shell you just used to start qmlscene. :)

Khertan
2013-10-14, 09:26
And here a little pull request to import python module from Qt Resources :

https://github.com/thp/pyotherside/pull/4

:)

xerxes2
2013-10-17, 12:34
Pyqt-5.1.1 was released yesterday. :) This is the first stable release that works with gcc-4.6.x but it doesn't build with Sailfish' sdk unless you update a few Qt packages from the qt devel repo. It seems to run just fine without upgrading in the emulator though. I made packages if you want to try it in the emulator:

zypper ar http://enlisy.org/~xerxes2/pkg/sailfish/i586/xerxes2-sailfish-i586.repo
zypper ref
zypper in pyqt
That should get you started. I may have missed a few deps though as there's a lot of them ... There's also python gstreamer bindings and a mp3 codec for gstreamer if you're developing audio apps.

xerxes2
2013-10-23, 17:05
I rebuilt pyqt with the new sdk update and now it builds without fuss at all. Just use the same repo as in the previous post. And if you rather want to use pyotherside you have this repo:
zypper ar http://repo.merproject.org/obs/mer-python3/latest_i586/mer-python3.repo
zypper ref
zypper in pyotherside-qml-plugin-python3-qt5
I think that pyotherside works with python2 also but it's highly recommended to stick with three!

jcharpak
2013-10-24, 20:57
I think that pyotherside works with python2 also but it's highly recommended to stick with three!

Nope thp hates python2.

rcolistete
2013-10-25, 12:13
I think that pyotherside works with python2 also but it's highly recommended to stick with three!

See post #3 (http://talk.maemo.org/showpost.php?p=1367517&postcount=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
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 (http://www.python.org/dev/peps/pep-0404/) and PEP 373 (http://www.python.org/dev/peps/pep-0373/) 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 (https://github.com/thp/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
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
I can't seem to build python packages as user in the sdk. Anyone else noticed this?
+ /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
@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
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 :
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:
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
PyOtherSide for Qt5 and Python 3.3, from thp, was updated (https://twitter.com/thp4/status/365199488014487552) 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 (http://thpmaemo.blogspot.co.at/2013/07/the-way-forward-with-python-on-qt-5.html).
To use Python 2.x instead of Python 3.3 with PyOtherSide, see thp hint (https://twitter.com/thp4/status/365380484420747265).

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) (http://devdays.kdab.com/?page_id=382) is available :
"Python 3 and Qt 5 with QML" abstract (https://devdays.kdab.com/?page_id=225#3)
"Python 3 and Qt 5 with QML" PDF presentation (http://devdays.kdab.com/wp-content/uploads/2013/10/Python3AndQt5_QtDD13_Jolla.pdf)

mikecomputing
2013-11-10, 19:25
Thomas Perl presentation about PyOtherSide in Qt Developers Day 2013 (Berlin) (http://devdays.kdab.com/?page_id=382) is available :
"Python 3 and Qt 5 with QML" abstract (https://devdays.kdab.com/?page_id=225#3)
"Python 3 and Qt 5 with QML" PDF presentation (http://devdays.kdab.com/wp-content/uploads/2013/10/Python3AndQt5_QtDD13_Jolla.pdf)

hmm no video recording from the event?

EmaNymton
2013-11-17, 15:48
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
Any experience here to be shared about submitting Python software to Jolla Harbour ?

Dave999
2013-11-18, 16:59
Thank you for this thread. I love python but I feel it's hard to create application UIs for Sailfish. Do I really have to use Cute/QML?

thp
2013-11-18, 17:37
Thank you for this thread. I love python but I feel it's hard to create application UIs for Sailfish. Do I really have to use Cute/QML?

Yes, to be able to use the native Sailfish Silica UI elements, you have to use Qt and QML. However, if you don't care that much about native integration, using something like OpenGL ES directly or PySDL2 or something would probably also work - but you'd be on your own there atm :)

mikecomputing
2013-11-18, 18:00
Any experience here to be shared about submitting Python software to Jolla Harbour ?

Python is in the emulator However it only python2 so there is no pyotherside and so on :/

But I really Hope jolla adds pyhon3 and pyotherside as "public" in some update.

EmaNymton
2013-11-18, 19:44
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!

To answer my own question, if anybody got the same problem.
Install python3-devel via zypper,
zypper in python3-devel
download lxml-versionX.tar.gz, extract it via
tar xfz lxml-versionX.tar.gz
change into that directory and build with
python3.3 setup.py build
If everthings went well, install it
python3.3 setup.py install

[root@SailfishEmul nemo]# python3
Python 3.3.2 (default, Aug 11 2013, 23:05:29)
[GCC 4.6.4 20130412 (Mer 4.6.4-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> lxml
<module 'lxml' from '/usr/lib/python3.3/site-packages/lxml/__init__.py'>
>>>

But the question remains: Will there be a python3, pyotherside, python3-lxml package in the standard repos or will it be necessary to ship it separately?

mattaustin
2013-11-24, 07:58
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!

Sorry for the late reply. I see you managed to install lxml anyway :)

The way I was installing lxml was using 'virtualenv (https://pypi.python.org/pypi/virtualenv)'. Once installed, a virtualenv for python3 can be created using 'virtualenv --python=python3'. Once activated, packages can be installed inside the virtualenv using pip (e.g. pip install lxml). More info at: http://www.virtualenv.org/en/latest/

EmaNymton
2013-11-24, 09:52
Thank you anyway, I tried that before, but got an ImportError when using
./pip install lxml


ImportError: No module named 'ssl_match_hostname'

After searching a little bit without finding a solution I build lxml from source.

rcolistete
2013-11-29, 14:50
About Python softwares running on Sailfish OS (with PyOtherSide or PyQt), the Jolla Harbour policy doesn't accept them for the moment :
https://harbour.jolla.com/faq
Can I submit Python applications?
Currently not, there are some enablers missing for that. But we are working on it, to make that happen. You can support us with that effort, please ask in Nemo project how to help with Python.

I think thp's PyOtherSide will be promoted to a default Mer/Nemo/Sailfish repository so it will be available for any Python software.

I also support PyQt 5 to be available in Mer/Nemo/Sailfish repository, as well as many Python tools (IPython, including notebook) and modules (NumPy, SymPy, etc). I will try to contact the Mer/Nemo community about this issue in the weekend.

rcolistete
2013-11-29, 14:51
Any tests on real Jolla smartphone with Python ???

xerxes2
2013-11-30, 15:36
I made pyqt available for sailfish so anyone with a jphone can try it now with panucci:
http://talk.maemo.org/showpost.php?p=1391142&postcount=563

Pyqt is very easy to build and the only dep it needs that is not available in sailfish already is sip so it wouldn't be much work to put it in a semi-official repo. Just poke me if you need working spec files for sip and pyqt.

rcolistete
2013-12-15, 17:59
Any tests on real Jolla smartphone with Python ???

Tested on Sailfish @ Nokia N9 :

1) Python is not installed by default, but it is simple to install v2.7.5 using Terminal :
$ pkcon install python

2) mer-tools repository is not enabled by default, but can be :
$ devel-su
# ssu ar mer-tools
# ssu ur
$ pkcon refresh
mer-tools has many tools, including more Python modules, see here (http://releases.sailfishos.org/sdk/latest/mer-tools/builds/armv7hl/packages/armv7hl/) and there (http://releases.sailfishos.org/sdk/latest/mer-tools/builds/armv7hl/packages/noarch/).

3) adding repositories is done with "zypper ar -G", because without the option "-G" (--no-gpgcheck, Disable GPG verification for this repository) the Jolla Store stops working (it can't install any software).
For example, mer-python3 (with Python 3.3 and PyOtherSide) :
# zypper ar -G http://repo.merproject.org/obs/mer-python3/latest_armv7hl/mer-python3.repo
# zypper ref
# zypper in python3-base pyotherside-qml-plugin-python3-qt5
Or my rcolistete repository with Python tools and modules (IPython, SymPy, NumPy, Uncertainties) :
# zypper ar -G http://repo.merproject.org/obs/home:/rcolistete/latest_armv7hl/ rcolistete
# zypper ref
# zypper in ipython python-sympy python-numpy
IPython shows a warning saying PySide is not available (needed for IPython Qt console), you can force installation by choosing "2", so "ipython" (terminal console) and "ipython notebook" will work (the Sailfish web browser works very well with IPython Notebook).
SymPy and NumPy also work well on Sailfish.

xerxes2
2013-12-15, 19:33
I will get my hands on a jp1 in a few days and will happily test both pyqt and pos apps. The sailfish python scene seems to be a bit dead atm so it can only get better from here. :) Will also check if openrepos work with the jp1.

xerxes2
2013-12-20, 21:41
Ok, I just got my jphone a few hours ago and after some fiddling with enabling dev mode I finally got zypper to work properly and installed pyqt and I can confirm that it works just fine. Now I'm thinking of creating a repo on openrepos called "sailfish-lib" as a place where we could put libs that are well tested and used by many different apps. Openrepos would be the right place for that yes/no?

Edit: So there's absolutely no excuse anymore for not porting all those opensource maemo/meego python apps to sailfish.

xerxes2
2013-12-21, 23:28
Ok, I made an account on openrepos called sailfish_lib (dash doesn't seem to work) and put pyqt there.

https://openrepos.net/user/876/repository

Anyone that knows what they're doing and want to add quality libs that are used by many apps can just pm me and I'll give you the password.

mattaustin
2013-12-22, 09:35
I've started a Sailfish Python Development page over on the Mer wiki to try and collate the information/tools we've now got:

https://wiki.merproject.org/wiki/Sailfish/Python_Development

maluka
2013-12-27, 01:40
Where can I find pyotherside-qml-plugin-python3-qt5

mattaustin
2013-12-27, 02:04
Where can I find pyotherside-qml-plugin-python3-qt5

You'll need to add the 'mer-python3' repo first, and then install pyotherside. I added instructions on the Mer wiki:


https://wiki.merproject.org/wiki/Sailfish/Python_Development#Python_3
https://wiki.merproject.org/wiki/Sailfish/Python_Development#PyOtherSide

maluka
2013-12-27, 03:08
You'll need to add the 'mer-python3' repo first, and then install pyotherside. I added instructions on the Mer wiki:


https://wiki.merproject.org/wiki/Sailfish/Python_Development#Python_3
https://wiki.merproject.org/wiki/Sailfish/Python_Development#PyOtherSide


Thanks. I managed to install gPodder from here (http://wiki.gpodder.org/wiki/Sailfish_OS) but it's not in a working state yet.

EmaNymton
2014-01-07, 17:03
I don't know, if this is new, but I just searched for python packages on my jolla:

http://pastebin.com/DdDCnbX8



[nemo@localhost ~]$ zypper info python-lxml
Loading repository data...
Reading installed packages...


Information for package python-lxml:

Repository: jolla
Name: python-lxml
Version: 3.2.0-1.1.1
Arch: armv7hl
Vendor: meego
Installed: Yes
Status: up-to-date
Installed Size: 22.8 MiB
Summary: ElementTree-like Python bindings for libxml2 and libxslt
Description:
lxml provides a Python binding to the libxslt and libxml2 libraries.
It follows the ElementTree API as much as possible in order to provide
a more Pythonic interface to libxml2 and libxslt than the default
bindings. In particular, lxml deals with Python Unicode strings
rather than encoded UTF-8 and handles memory management automatically,
unlike the default bindings.


Installed python-lxml, little test-script worked, so I think time is near to get python-apps into harbour ;)

solbrit
2014-02-19, 00:00
Okay, I'm used to pyside but I thought I'd give pyotherside a go. Didn't start out well. Installed pyotherside-qml-plugin-python3-qt5 from repos, but now what? A simple
>>> import pyotherside
won't work for starters ("No module named pyotherside") so I'm obviously missing something basic here...

solbrit
2014-02-19, 09:25
Tried different python versions (although 3.3 should be the one) on both device and emulator, and nothing, no pyotherside module in sight. Can anyone help?

coderus
2014-02-19, 09:50
lol. now read docs: https://github.com/thp/pyotherside

solbrit
2014-02-19, 10:35
I have. Now what?

EmaNymton
2014-02-19, 11:17
You don't have to import pyotherside in the interpreter.

Just install the packages python3-base, pyotherside-qml-plugin-python3-qt5, qt5-qtdeclarative-qmlscene

Then use some of the examples from the github repo to get starting, for example the events:

https://github.com/thp/pyotherside/blob/master/examples/events_example.py
https://github.com/thp/pyotherside/blob/master/examples/events_example.qml


Change in the qml-file the line

addImportPath(Qt.resolvedUrl('.'));

to
addImportPath(Qt.resolvedUrl('.').substr('file://'.length));

otherwise the path is incorrect (afaik this is fixed in version >1.1, but jolla repo has 1.1)

Then you can start it with

/usr/lib/qt5/bin/qmlscene events_example.qml


Have fun!

solbrit
2014-02-19, 11:34
Thankyou kindly! That got things going! :D

mattaustin
2014-02-23, 04:03
Anyone else experiencing SSL/cert related problems with python3 on Sailfish OS?

I've now encountered problems in two different situations:

1) When creating a python3 virtualenv, I can't use pip to install anything:
ImportError: No module named 'ssl_match_hostname'

2) When attempting to use the "requests" library:
from _implementation import CertificateError, match_hostname
ImportError: No module named '_implementation'


I'm attempting to write a NewsBlur client, and need to use the requests library, so this has me a bit stumped :(.


EDIT 1: Possibly related: https://github.com/shazow/urllib3/issues/320
So it looks like the Python version in the repos might be compiled without SSL :(.

EDIT 2: Looks like this pull request has been merged which will allow ssl: https://github.com/thp/mer-python3/issues/1 and https://github.com/nemomobile-packages/python3/pull/1. I'm not sure how to track when this reaches the mer/nemo/sailfish repos though - anyone have any tips?

nieldk
2014-02-23, 12:04
Anyone else experiencing SSL/cert related problems with python3 on Sailfish OS?

I've now encountered problems in two different situations:

1) When creating a python3 virtualenv, I can't use pip to install anything:
ImportError: No module named 'ssl_match_hostname'2) When attempting to use the "requests" library:
from _implementation import CertificateError, match_hostname
ImportError: No module named '_implementation'
I'm attempting to write a NewsBlur client, and need to use the requests library, so this has me a bit stumped :(.


EDIT 1: Possibly related: https://github.com/shazow/urllib3/issues/320
So it looks like the Python version in the repos might be compiled without SSL :(.

EDIT 2: Looks like this pull request has been merged which will allow ssl: https://github.com/thp/mer-python3/issues/1 and https://github.com/nemomobile-packages/python3/pull/1. I'm not sure how to track when this reaches the mer/nemo/sailfish repos though - anyone have any tips?

at least python 2.7.5 on repos have

[nemo@localhost ~]$ python
Python 2.7.5 (default, May 09 2013, 12:34:56)
[GCC 4.6.4 20130412 (Mer 4.6.4-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> hasattr(socket, "ssl")
True
>>>

mattaustin
2014-02-23, 12:56
at least python 2.7.5 on repos have

[nemo@localhost ~]$ python
Python 2.7.5 (default, May 09 2013, 12:34:56)
[GCC 4.6.4 20130412 (Mer 4.6.4-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> hasattr(socket, "ssl")
True
>>>

Yep, looks like that's missing from python3 in the 1.0.3.8 repos:

[nemo@localhost ~]$ python3
Python 3.3.3 (default, Jan 20 2014, 16:21:36)
[GCC 4.6.4 20130412 (Mer 4.6.4-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> hasattr(socket, 'ssl')
False
>>>

nieldk
2014-02-23, 14:54
i guess someone ;) needs to build Python 3.3.5 ...

[nemo@localhost ~]$ python3
Python 3.3.5rc1 (default, Feb 23 2014, 21:01:14)
[GCC 4.6.4 20130412 (Mer 4.6.4-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> import sys
>>> sys.modules.keys()
dict_keys(['collections.abc', 'textwrap', 'signal', 'ssl', 'zipimport', '_warnings', 'copyreg', 'encodings.utf_8', 'abc', 'stat', '__main__', 'os', 'site', 'errno', 'keyword', 'encodings.latin_1', 'sys', 'readline', 'sre_parse', 'heapq', 'encodings', '_io', '_ssl', 'posix', 'encodings.aliases', 'os.path', '_codecs', 'traceback', '_frozen_importlib', 'genericpath', '_thread', '_socket', 'io', 'operator', '_imp', 'marshal', '_struct', '_sysconfigdata', 'pprint', 'sre_constants', '_sre', 'posixpath', '_collections', 'collections', 'base64', 'reprlib', 'sysconfig', 'codecs', 'functools', 'sre_compile', 'builtins', 'binascii', 'token', 'weakref', 'socket', 'linecache', 'struct', '_weakref', 'tokenize', '_functools', '_heapq', '_weakrefset', 'itertools', 're'])
>>>

mattaustin
2014-02-24, 04:50
i guess someone ;) needs to build Python 3.3.5 ...

https://openrepos.net/content/nieldk/python3-0

Thanks! That will at allow me to continue development and testing on-device whilst (hopefully) an updated python3 is released as in the official repos.

solbrit
2014-02-25, 22:18
Among all the exciting warnings I get when I run an otherwise working pyotherside app:
[W] DeclarativeCoverWindow::DeclarativeCoverWindow:62 - DeclarativeCoverWindow: You should be calling QQuickWindow::setDefaultAlphaBuffer(true) before creating windows. Failing to do so will result in suboptimal performance.
[W] DeclarativeCoverWindow::DeclarativeCoverWindow:63 - DeclarativeCoverWindow: You also won't have cover transparency.

Now the interesting thing is that, while on the device i don't have cover transparency, in the emulator I do. Why is this and how can I set DefaultAlphaBuffer (or whatever needs to be done) to obtain transparency on device?

MartinK
2014-02-25, 23:07
Among all the exciting warnings I get when I run an otherwise working pyotherside app:
[W] DeclarativeCoverWindow::DeclarativeCoverWindow:62 - DeclarativeCoverWindow: You should be calling QQuickWindow::setDefaultAlphaBuffer(true) before creating windows. Failing to do so will result in suboptimal performance.
[W] DeclarativeCoverWindow::DeclarativeCoverWindow:63 - DeclarativeCoverWindow: You also won't have cover transparency.

Now the interesting thing is that, while on the device i don't have cover transparency, in the emulator I do. Why is this and how can I set DefaultAlphaBuffer (or whatever needs to be done) to obtain transparency on device?
I think those warnings go away if you launch the QML using the sailfish-qml launcher, but they can imho be pretty much ignored for development with the much more flexible qmlscene.

As to how sailfish-qml works for Python applications, just install Helsinky Transit Live application from OpenRepos (https://openrepos.net/content/otsaloma/helsinki-transit-live), which is based on PyOtherSide. Then you can inspect its desktop file in:

/usr/share/applications/harbour-helsinki-transit-live.desktop


You can also check the structure of its application files in:

/usr/share/harbour-helsinki-transit-live/

solbrit
2014-02-25, 23:40
Interesting reading, honestly, but the problem is the Helsinky Transit Live app won't launch, and setting up the desktop file my app uses with sailfish-qml will make it not launch either. It'll only launch okay with qml-scene but I can't get the cover transparency to work...
AFAICT the Helsinky app doesn't seem to use transparent cover anyway.

solbrit
2014-02-26, 09:27
Hmm, it's weird, in emulator I get a transparent cover every time, on the device sometimes I get a black cover, sometimes I get no cover at all.

solbrit
2014-02-27, 08:53
Tried to install pyotherside 1.2.0 according to instructions. "make" will give this error though:
Project MESSAGE: PYTHON_CONFIG = python3-config
sh: python3-config: command not found
sh: python3-config: command not found
Project ERROR: Unknown module(s) in QT: quick qml gui core
make: *** [sub-src-make_first] Error 3
Why is that?

nieldk
2014-02-27, 09:22
Tried to install pyotherside 1.2.0 according to instructions. "make" will give this error though:
Project MESSAGE: PYTHON_CONFIG = python3-config
sh: python3-config: command not found
sh: python3-config: command not found
Project ERROR: Unknown module(s) in QT: quick qml gui core
make: *** [sub-src-make_first] Error 3
Why is that?

From: http://pyotherside.readthedocs.org/en/latest/#building-pyotherside

"In case your system doesn’t provide python3-config, you might have to pass a suitable python-config to qmake at configure time:
qmake PYTHON_CONFIG=python3.3-config
make
make install"

solbrit
2014-02-27, 12:30
From: http://pyotherside.readthedocs.org/en/latest/#building-pyotherside

"In case your system doesn’t provide python3-config, you might have to pass a suitable python-config to qmake at configure time:
qmake PYTHON_CONFIG=python3.3-config
make
make install"

I tried that, gives the same error (but with the new python version)....

nieldk
2014-02-27, 13:12
I tried that, gives the same error (but with the new python version)....

If you installed my 3.3.5rc1 version, the python3-config is present.
You should also install the remaining QT files
eg. do a
zypper se for the missing QT files
quick, qml, gui, core
and install those

solbrit
2014-02-27, 14:40
If you installed my 3.3.5rc1 version, the python3-config is present.
You should also install the remaining QT files
eg. do a
zypper se for the missing QT files
quick, qml, gui, core
and install those

Yes, installing your 3.3.5rc1 got me further, and as you predicted now I get that quick, qml, gui and core are missing. Which packages are we talking about, the devel ones? (Because I allready have the other ones installed...)

nieldk
2014-02-27, 15:43
since you are building apps, yes, you need the devel packages

solbrit
2014-02-27, 16:02
I get dependency problems with devel packages though. qt5-qtquick1-devel for example:
Problem: qt5-qtquick1-devel-5.1.0+git3-1.2.17.armv7hl requires pkgconfig(Qt5Gui), but this requirement cannot be provided
uninstallable providers: qt5-qtgui-devel-5.1.0+git30-1.11.2.armv7hl[jolla]

Solutions are uninstalling 23 packages (which I sense would be a bad idea uninstalling) or breaking qtquick (which doesn't seem like a good idea either).

Edit: And ofcourse now the apps I've allready made won't run anymore :D

m4r0v3r
2014-04-01, 13:39
QMAKE_CXXFLAGS += -I/usr/local/include/python3.4m -I/usr/local/include/python3.4m

With that set I receive a Python.h: No such file or directory when attempting to build pyotherside.

I've tried different versions of Python and none work, I've had to explicitly give it the command since no matter what I set :

PYTHON_CONFIG = python3.4m-config

Doesn't work, it never ever finds the command

rcolistete
2014-05-11, 19:56
Some more updated information about :

1) Python on Sailfish :
- it has a wiki Sailfish/Python Development page (https://wiki.merproject.org/wiki/Sailfish/Python_Development);
- Python 3.3.3 (and later 3.4.0) is in Sailfish official repositories since Sailfish v1.0.3.8 (31/01/2014);
- it can be installed as a dependency for other software (gPodder, etc) or by manual installation with :
$ pkcon install python3-base
- it is expected to be accepted in Jolla Harbour "soon" (https://together.jolla.com/question/6116/python-application-support-in-jolla-store-harbour/).

2) PyOtherSide (http://thp.io/2011/pyotherside/) (http://thp.io/2011/pyotherside/) :
- is in Sailfish official repositories since Sailfish v1.0.3.8 (31/01/2014);
- it can be installed as a dependency for other software (gPodder, etc) or by manual installation with :
$ pkcon install pyotherside-qml-plugin-python3-qt5
- has newer versions 1.1 and 1.2 released in 2014;
- is being used by more than 10 Sailfish softwares, and by BlackBerry (10) softwares;
- it is expected to be accepted in Jolla Harbour "soon" (https://together.jolla.com/question/6116/python-application-support-in-jolla-store-harbour/);
- it as available in Arch Linux repositories and Ubuntu PPA;
- it is cited by the wiki Sailfish/Python Development page (https://wiki.merproject.org/wiki/Sailfish/Python_Development#PyOtherSide).

3) PyQt 5.1.1 :
- is available in OpenRepos.net, with version for Python 2.7 (pyqt) (https://openrepos.net/content/sailfishlib/pyqt) and version for Python 3 (python-pyqt) (https://openrepos.net/content/sailfishlib/python-pyqt);
- it is cited by the wiki Sailfish/Python Development page (https://wiki.merproject.org/wiki/Sailfish/Python_Development#PyQt).

So Python 3 & Qt 5 development is well supported in Sailfish, so it is time for Python developers to release their softwares for Sailfish. :cool:

evk
2014-05-15, 20:35
As far as I understand, PyOtherSide is only available for python 3. That's fine, I like python 3. But there aren't many more python 3 packages, so you're restricted to python-base?

rcolistete
2014-05-15, 22:52
As far as I understand, PyOtherSide is only available for python 3. That's fine, I like python 3. But there aren't many more python 3 packages, so you're restricted to python-base?

There are only few Python 3 modules at the moment for Sailfish, but they are being ported, look at Mer COBS (https://build.merproject.org/) and OpenRepos.net (https://openrepos.net/) for Python 3. Today I've packaged Uncertainties (https://openrepos.net/content/rcolistete/uncertainties-python-3-sailfishos) and SymPy (https://openrepos.net/content/rcolistete/sympy-python-3-sailfishos) for Python 3, by the way.

evk
2014-05-16, 15:45
OK, great. It's not a big problem for right now since I'm mostly playing around and can always use C++ if I do something serious.

And I'm getting a bit impressed by QML, some rather powerfull stuff can be done.

xerxes2
2014-05-19, 08:32
Some more updated information about :
- Python 3.3.3 (and later 3.4.0) is in Sailfish official repositories since Sailfish v1.0.3.8 (31/01/2014);


Hey thanks for the heads up. :) I just made a PyQt package for py3 too. So on ORN pyqt is for py2 and python-pyqt is for py3. As mentioned earlier there is not that much support yet for py3 in sailfish so I'll keep supporting pyqt for py2 as long as upstreams does, probably a few more years.

rcolistete
2014-05-19, 17:01
Hey thanks for the heads up. :) I just made a PyQt package for py3 too. So on ORN pyqt is for py2 and python-pyqt is for py3. As mentioned earlier there is not that much support yet for py3 in sailfish so I'll keep supporting pyqt for py2 as long as upstreams does, probably a few more years.

Excellent, so we have 3 options for Python-Qt bindings : PyQt for Python 2.7 & 3, PyOtherSide for Python 3.

Could you make it more explicit that python-pyqt on OpenRepos.Net (https://openrepos.net/content/sailfishlib/python-pyqt) is for Python 3 ? The only mention is the 1st line after the "%build".

I've updated the post #83 (http://talk.maemo.org/showthread.php?p=1424946#post1424946).

xerxes2
2014-05-19, 17:33
I updated the wikipage now with regards to pyqt and also added a software section where we could list all available python apps for sailfish, I found six so far. And hopefully plenty in the oven too. :)

https://wiki.merproject.org/wiki/Sailfish/Python_Development#Software

rcolistete
2014-05-22, 19:14
I updated the wikipage now with regards to pyqt and also added a software section where we could list all available python apps for sailfish, I found six so far. And hopefully plenty in the oven too. :)

https://wiki.merproject.org/wiki/Sailfish/Python_Development#Software

Thanks, I've followed your work and inserted more Python applications (14 until now) for Sailfish :
https://wiki.merproject.org/wiki/Sailfish/Python_Development#Software
Source-code (GitHub) links were placed when available, they are very useful to other developers to see other softwares as code examples.

xerxes2
2014-05-23, 20:19
Yeah it looks good ... and so many Python apps already. 13-1 in favor of pos vs pyqt. :) And I added a little bit more info about the differences between pos and pyqt. Feel free to edit/add more info if you like. I never really used pos so I don't know that much about it.

And does anyone know about the situation of introspection in Sailfish? I can't seem to find it so it may not exist at all. If not we must get Jolla to add introspection support for packages they maintain in core Sailfish. I can make an example already that I'll need and that is Gstreamer-1. But the whole G stack with Glib, Gio, Cairo, Pango, Telepathy and possibly some more are only supported from Python with introspection and it would be nice if Jolla would support these with -intro packages.

And if anyone is missing Python libs just ask and I'll try to package them for you. They must be compatible with core Sailfish though as I'll not upgrade such packages.

Khertan
2014-05-28, 06:33
You can add ownNotes too :

http://github.com/khertan/ownNotes

rcolistete
2014-06-11, 03:43
Updated 1st post, citing the Sailfish/Python Development wiki page (https://wiki.merproject.org/wiki/Sailfish/Python_Development). This wiki page now lists Python 2/3 modules available for Sailfish.

rcolistete
2014-09-08, 01:17
PyOtherSide (http://thp.io/2011/pyotherside/) was updated in July to version 1.3.0.

PyOtherSide is now available in Debian and Ubuntu repositories.

rcolistete
2014-12-01, 12:23
Python 3.4 and PyOtherSide will soon be available in Jolla App Store :
#mer-meeting: SailfishOS, open source, collaboration: 25-November @ 15:00 UT (http://merproject.org/meetings/mer-meeting/2014/mer-meeting.2014-11-25-15.00.html)
Full logs (http://merproject.org/meetings/mer-meeting/2014/mer-meeting.2014-11-25-15.00.log.html) :
15:10:31 <cybette> #info Starting with Update 10, a few new APIs will be allowed in Harbour. For details see log and above link
15:17:03 <M4rtinK_jolla_> what about Python ?
15:17:44 <kontio> M4rtinK_jolla_: pyotherside w/ python will be allowed too

rcolistete
2014-12-25, 18:36
Softwares using Python/PyOtherSide as dependencies will be accepted by Jolla Harbour Store from 7th January 2015 :

- Jolla Harbour Store has since 15/12/2014 the long pending multiversion support, needed by PyOtherSide (in Sailfish repositories only since 1.0.3.8) :
[SailfishDevel] Changes in Harbour Web UI - Fri Dec 12 15:41:09 UTC 2014 (https://lists.sailfishos.org/pipermail/devel/2014-December/005385.html)
We mentioned earlier that in order to allow more libraries and e.g. Python support we need Harbour to be able to accept submissions for certain Sailfish OS versions aka. "multiversion support".
We will deploy that feature on Monday 15. December 2014, starting 08:00 UTC. For local time run on a Linux system:
date -d '2014-12-15 08:00 UTC'
- the new Sailfish SDK from 5th January 2015 and new RPM validator (to be used by Harbour team from 7th January 2015) will allow Python/PyOtherSide as dependencies :
[Release notes] Software version 1.1.1.27, Vaarainjärvi (https://together.jolla.com/question/71741/release-notes-software-version-11127-vaarainjarvi/).
The corresponding SDK release will be available on the 5th of January 2015. It will include the updated rpmvalidator which allows the new libraries to be used in Store as announced in the community meeting from 25th of November 2014.
Harbour testing team will start using the new rpmvalidator from 7th of January 2015 onwards (note that 6th of January 2015 is a public holiday in Finland).
[SailfishDevel] Harbour & Jolla Developer Care delays during holiday season (https://lists.sailfishos.org/pipermail/devel/2014-December/005407.html)
As mentioned in the release notes for Update 10[1], we will release the corresponding SDK on 5. Jan 2015 and Harbour testing will start using the new rpmvalidator allowing more libraries[2] 7. Jan 2015.

rcolistete
2015-01-05, 16:20
As said above, the Sailfish SDK Beta 1412 was released today (http://talk.maemo.org/showpost.php?p=1455372&postcount=274). So Python softwares can be built with it, and sent to Jolla Harbour next Wednesday (January 7th 2015).

rcolistete
2015-01-10, 18:39
Python/PyOtherSide support in Jolla Harbour Store since January 7th 2015 was confirmed in "#mer-meeting: SailfishOS, open source, collaboration meeting: 7-January 2015" (http://merproject.org/meetings/mer-meeting/2015/mer-meeting.2015-01-07-15.01.html) :
4.b continue: Starting from today 7. Jan 2015 our Harbour QA team allows new the following libraries: libssl, libcrypto, liblzma, libxml2, libogg, libvorbis, QtGraphicalEffects. Also allowed is now the QML import: io.thp.pyotherside which allows QML modules written in Python. (iekku, 15:46:42)

I've updated the Sailfish/Python Development wiki page (https://wiki.merproject.org/wiki/Sailfish/Python_Development).

The together.jolla.com topic "Python application support in Jolla store (Harbour)" (https://together.jolla.com/question/6116/python-application-support-in-jolla-store-harbour/?answer=23476#post-id-23476) was updated :
UPDATE: 09. Jan 2015
As mentioned in several places Harbour QA started on 07. Jan 2015 (with update 10, 1.1.1.27, Vaarainjärvi) to accept submissions which use Python QML plugins based on PyOtherSide.

gPodder and Perth Trains are among the first Python/PyOtherSide apps to be allowed in Harbour.

PS: We will update the Harbour FAQs soon :)

First Python softwares in Jolla Store, visible for all Sailfish users :
- gPodder 4.4.0 in January 8th 2015;
- Perth Trains 0.9.6 in January 9th 2015.

rcolistete
2015-01-10, 19:25
Tutorial "Create and build Python app for Sailfish" in german (http://blog.pohlers-web.de/python-app-fuer-sailfish-erstellen-und-bauen/).
With a "Dummy Project for Sailfish OS" source code in GitHub (https://github.com/Cermit/harbour-my-app) as a simple example of Python app for Sailfish OS.
It was announced in Twitter (https://twitter.com/Cermit3273/status/553969070232850433).

jcharpak
2015-01-10, 23:35
First Python softwares in Jolla Store, visible for all Sailfish users :
- gPodder 4.4.0 in January 8th 2015;
- Perth Trains 0.9.6 in January 9th 2015.

Congratulations Thp (and I'm guessing mattaustin)!

EmaNymton
2015-01-14, 16:16
Is there any way to offer translation for a pure PyOtherSide/QML application?

EmaNymton
2015-01-15, 10:45
Ok, I found a way that worked for me!

If you use sailfish-qml to start your PyOtherSide/QML application you have to place your qm-translation files in a folder called translations.

Translation files are supposed to be named "<appname>-<lang>.qm" in "/usr/share/<appname>/translations/"

That works for me, found it at the source code of sailfishlib project:
https://github.com/sailfish-sdk/libsailfishapp/blob/master/src/sailfishapp_priv.cpp

forestbird
2015-03-22, 21:14
Hello.

I've tried to install PyQt on Jolla, but got the error about failed dependencies:

"Qt5Multimedia.WIdgets.so.5 is needed by python-pyqt-5.1.1-1.armv7hl"

And the same error occurs while trying to install Panucci.

Is there a way to install the missing module?

MartinK
2015-07-18, 15:18
Any advice on how to handle translations of strings in Python code? In particular when doing string formatting in Python and the unformatted string should be subject to translation.

Is there a way to access ts-file data from Python without importing some huge PyQt? Or am I just wrong to put strings in Python and should move them all to QML? The whole Qt translation system seems very primitive compared to gettext.

https://github.com/otsaloma/poor-maps/issues/1
What about using gettext for the Python part and the Qt thing for the QML part ?

marmistrz
2016-08-07, 11:25
Why is Jolla so reluctant to support PyQt5 in Harbour?

MartinK
2016-08-07, 11:35
Why is Jolla so reluctant to support PyQt5 in Harbour?
Maybe because it's so much larger than PyOtherSide ? PyQt attepmts to wrap and make accessible all Qt 5 classes while PyOtherSide is just a light RPC interface for QML.

In any case it would be a good idea to raise the issue on the Community Meeting (https://together.jolla.com/question/54157/sailfishos-open-source-collaboration-meeting-planning/). :)

MartinK
2017-01-29, 23:11
I've just submitted a merge request for updating PyOtherSide in Sailfish OS from 1.4 to 1.5:
https://git.merproject.org/mer-core/pyotherside/merge_requests/2

If it is accepted by maintainers it these are the main features that will be available to Python application developers:


Support for OpenGL rendering in Python using PyOpenGL >= 3.1.0
New QML components: PyGLArea, PyFBO
pythonVersion() now returns the runtime Python version
Add the library to PYTHONPATH for standard library appended as .zip (except on Windows)
Call PyDateTime_IMPORT as often as necessary (Fixes #46)
Added pyotherside.format_svg_data for using SVG data in the image provider
Handle converting QVariantHash to Python dict type
Added .qmltypes file to provide metadata information for Qt Creator
New functions importNames() and importNames_sync() for from-imports

MartinK
2017-04-24, 14:15
My PyOtherSide update request (to version 1.5.1) has been merged, and should be (according to Larstiq on IRC) part of the Sailfish OS Update that comes after the next one (2.1.0 + 2 updates). So let's hope the Sailfish OS update cycle speeds up now that Qt 5.6 is in and we can soon make use of all the nice new features and fixes of the updated PyOtherSide. :)