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)

Dave999 2013-11-18 16:59

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by NokiaN9KickYourAss (Post 1387302)
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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by rcolistete (Post 1387260)
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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by EmaNymton (Post 1387076)
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,
Code:

zypper in python3-devel
download lxml-versionX.tar.gz, extract it via
Code:

tar xfz lxml-versionX.tar.gz
change into that directory and build with
Code:

python3.3 setup.py build
If everthings went well, install it
Code:

python3.3 setup.py install
Code:

[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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by EmaNymton (Post 1387076)
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'. 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

Re: Python & Qt5 on Sailfish
 
Thank you anyway, I tried that before, but got an ImportError when using
Code:

./pip install lxml
Code:

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

Re: Python & Qt5 on Sailfish
 
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
Quote:

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

Re: Python & Qt5 on Sailfish
 
Any tests on real Jolla smartphone with Python ???

xerxes2 2013-11-30 15:36

Re: Python & Qt5 on Sailfish
 
I made pyqt available for sailfish so anyone with a jphone can try it now with panucci:
http://talk.maemo.org/showpost.php?p...&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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by rcolistete (Post 1390685)
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 :
Code:

$ devel-su
# ssu ar mer-tools
# ssu ur
$ pkcon refresh

mer-tools has many tools, including more Python modules, see here and there.

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) :
PHP Code:

# 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) :
PHP Code:

# 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

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
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/Sai...on_Development

maluka 2013-12-27 01:40

Re: Python & Qt5 on Sailfish
 
Where can I find pyotherside-qml-plugin-python3-qt5

mattaustin 2013-12-27 02:04

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by maluka (Post 1400887)
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:

maluka 2013-12-27 03:08

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by mattaustin (Post 1400891)
You'll need to add the 'mer-python3' repo first, and then install pyotherside. I added instructions on the Mer wiki:

Thanks. I managed to install gPodder from here but it's not in a working state yet.

EmaNymton 2014-01-07 17:03

Re: Python & Qt5 on Sailfish
 
I don't know, if this is new, but I just searched for python packages on my jolla:

http://pastebin.com/DdDCnbX8


Code:

[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

Re: Python & Qt5 on Sailfish
 
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
Code:

>>> 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

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
lol. now read docs: https://github.com/thp/pyotherside

solbrit 2014-02-19 10:35

Re: Python & Qt5 on Sailfish
 
I have. Now what?

EmaNymton 2014-02-19 11:17

Re: Python & Qt5 on Sailfish
 
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/b...nts_example.py
https://github.com/thp/pyotherside/b...ts_example.qml


Change in the qml-file the line

Code:

addImportPath(Qt.resolvedUrl('.'));
to
Code:

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

Code:

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

Have fun!

solbrit 2014-02-19 11:34

Re: Python & Qt5 on Sailfish
 
Thankyou kindly! That got things going! :D

mattaustin 2014-02-23 04:03

Re: Python & Qt5 on Sailfish
 
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:
Code:

ImportError: No module named 'ssl_match_hostname'
2) When attempting to use the "requests" library:
Code:

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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by mattaustin (Post 1413878)
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:
Code:

ImportError: No module named 'ssl_match_hostname'
2) When attempting to use the "requests" library:
Code:

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

Code:

[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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by nieldk (Post 1413917)
at least python 2.7.5 on repos have

Code:

[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:

Code:

[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

Re: Python & Qt5 on Sailfish
 
i guess someone ;) needs to build Python 3.3.5 ...

Code:

[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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by nieldk (Post 1413937)
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

Re: Python & Qt5 on Sailfish
 
Among all the exciting warnings I get when I run an otherwise working pyotherside app:
Code:

[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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by solbrit (Post 1414343)
Among all the exciting warnings I get when I run an otherwise working pyotherside app:
Code:

[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, which is based on PyOtherSide. Then you can inspect its desktop file in:
Code:

/usr/share/applications/harbour-helsinki-transit-live.desktop
You can also check the structure of its application files in:
Code:

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

solbrit 2014-02-25 23:40

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
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

Re: Python & Qt5 on Sailfish
 
Tried to install pyotherside 1.2.0 according to instructions. "make" will give this error though:
Code:

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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by solbrit (Post 1414563)
Tried to install pyotherside 1.2.0 according to instructions. "make" will give this error though:
Code:

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/e...ng-pyotherside

"In case your system doesn’t provide python3-config, you might have to pass a suitable python-config to qmake at configure time:
Code:

qmake PYTHON_CONFIG=python3.3-config
make
make install

"

solbrit 2014-02-27 12:30

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by nieldk (Post 1414569)
From: http://pyotherside.readthedocs.org/e...ng-pyotherside

"In case your system doesn’t provide python3-config, you might have to pass a suitable python-config to qmake at configure time:
Code:

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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by solbrit (Post 1414602)
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

Re: Python & Qt5 on Sailfish
 
Quote:

Originally Posted by nieldk (Post 1414608)
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

Re: Python & Qt5 on Sailfish
 
since you are building apps, yes, you need the devel packages

solbrit 2014-02-27 16:02

Re: Python & Qt5 on Sailfish
 
I get dependency problems with devel packages though. qt5-qtquick1-devel for example:
Code:

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


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

vBulletin® Version 3.8.8