Qt for Python details on the new 6.3 release
April 13, 2022 by Cristián Maureira-Fredes | Comments
Finally the time has come! we are really excited to let you know everything we have been working on for this release 🎉 so let's dive into the details 🐍
Divide and Conquer: new package structure
Update: The new wheels are available on PyPi starting from 16.04.2022
From the initial official release of PySide in 5.12, we decided to package all the Qt-related modules on the same package. This was good because people did not have to worry about what to install but created a bit of a struggle for people trying to deploy applications, because they needed to filter out many binaries that were included.
Additionally, the PyPi servers have a certain limit related to wheel sizes, and project sizes, which were not enough for our packages, nor future releases.
With these ideas in mind, we decided to split the PySide wheel into two, Essentials and Addons, but do not worry! You still can run pip install pyside6
and get all the modules! We have just provided a more fine-grained package distribution to improve the current situation. This is how the dependency and distribution of packages looks like now:
We included a few extra modules on top of the Qt Essential list, mainly due to dependencies from the tools we deploy within the wheel. Check the list of the modules that are included in the Essentials and Addons packages.
Now if you want to install only the essential modules, you will need to run:
pip install pyside6_essentials
or if you need all the modules, the usual
pip install pyside6
that will include PySide6_Essentials and PySide6_Addons.
The current structure will allow us in the future to improve the granularity of the packages if we see the need, while keeping the same meta packages in place.
In case you are updating your 6.2.x install, make sure the PySide6_Essentials
and PySide6_Addons
wheels are getting installed, otherwise, uninstall and install PySide6
to get the new structure.
Note: the Linux wheels are now using PEP600, meaning that we left the 'manylinux1'
tag and started to use the glibc version of the platform: 'manylinux_2_28'
Python Compatibility
Python 3.6 reached its end-of-life, and with that the 6.3 release series will be the last one supporting Python 3.6. The compatibility will be fully removed starting from 6.4.0, leaving Python 3.7 as the minimum required version.
Commercial Wheels
For commercial customers, the M2M Protocol modules are available on a different wheel called PySide6_M2M
that can be obtained from your Qt account page.
A faster Qt for PyPython
In case you were not aware, the "Python" most people use is the standard implementation that's written in C, and that's called CPython. Be careful not to think it's another project called Cython.
On this release, a new Python interpreter was integrated into our list of supported interpreters that is quite different from CPython: It is PyPy, which is specialized on a tracing JIT of high efficiency. In our Mandelbrot example, PyPy works 10 times faster than CPython 3.10.
The status of the PyPy compatibility is good enough to use it already, while some more esoteric tests are not working, yet (just 2%). Almost all examples are working fine with it and can be tried immediately after installing.
It's important to note that the PyPy compatibility is at Python 3.8 version (Check PyPy3.8). There are a few things which are different:
-
PyPy has no reference counting, which is the mechanism that CPython uses to keep track of object lives.
-
PyPy cannot support the Limited API (it's impossible)
-
PyPy cannot support our switchable features (The
__feature__
option), but they will probably be available in the next versions.
Python modules generally work great with PyPy. However, extension modules may or may not work due to the special cases those libraries might have, which was the PySide case, which is the biggest extension module that has PyPy support so far. If you are into numerical application, the NumPy extension module works great without any changes!
You can of course build PySide as you would do with python
, but with pypy
and try it by yourself, but in case you want to try our wheels, they are available for download here.
This is the first time that PySide was adapted to a different Python implementation, and we needed to improve several parts of PySide to be less CPython specific.
We really hope you can give it a try, and let us know if you found a corner case that's not properly working.
Cross compilation for Linux embedded systems (Technical Preview)
Embedded support has been one of the most requested features since the release of Qt for Python, and we are really happy to tell you that now it's a reality!.
The motivations and use cases for this support were mainly two:
-
many people out there with embedded systems like Raspberry Pi that are doing really cool projects that require a nice UI, and
-
people with different platforms and architectures are trying to get PySide and Shiboken to work, without compiling on the devices.
Historically, many people attempted it in the past, and we have some old issues in the Qt Bug Reports system describing partially working processes, which even included patches to our build system, which was not prepared for such task, not at a CMake
, nor a setuptools
level.
With the help of the Qt Build System team, the whole build infrastructure was upgraded, cleaned and improved, so we could finally cross compile Qt for Python.
To cross compile the project, you just need to adjust a bit the typical setup.py
call. The command might look like this:
python setup.py bdist_wheel \
--parallel=16 --ignore-git --reuse-build --standalone --limited-api=yes \
--cmake-toolchain-file=/opt/toolchain-aarch64.cmake \
--qt-host-path=/opt/Qt/6.3.0/gcc_64 \
--plat-name=linux_aarch64
We are releasing this functionality as a Technical Preview, because we are aware of some limitations that we are currently working on:
-
Yocto support,
-
testing other embedded systems platforms, and
-
packaging the sources for projects like piwheels to be able to distribute Shiboken and PySide,
As a starting point, we used a couple of Raspberry Pi devices, and relied on rolling release Linux distributions like Archlinux ARM and Manjaro ARM which already provide Qt packages. However, one of our main goals here is to provide Python packages for Raspberry Pi OS, which will involve more effort from people to get a proper Qt 6 packaging story in Debian, but that's a topic for another time 😉.
You can find the guide we created here, and we hope you can successfully give it a try and get Python wheels for your Raspberry Pi ✨
Long live to pyside6-project!
Are you familiar with the .pyproject files you can see inside our examples? If not, those files are the reason we can open Qt for Python projects in QtCreator, and allow us to keep information about the files that belong to each project.
We felt that we could do more with that information, so we decided to automate some of the processes users encounter often, like the generation of ui
and qrc
files into Python classes.
An experimental version of a new build tool called pyside6-project
was added. As described before, you just need to rely on a .pyproject
file to do the generation automatically.
But that's not all, if your project is using QML and have your own types, it will also create .qmltypes
files which are required in case you want to use qmllint
. That's right, you can check your QML code now as well!, which lead us to the next topic.
Better QML support
After the initial implementation we got in 6.0 for the QmlElement
decorator that replaces the QML_ELEMENT
from C++, it was natural for us to continue exposing more and more decorators to improve the QML support of the project.
Starting from 6.3 you can also use QmlAnonymous
, QmlAttached
, QmlExtended
, QmlForeign
, QmlNamedElement
and QmlUncreatable
. New examples under examples/declarative/referenceexamples/ demonstrate their use. Remember that you can also navigate the examples in our examples gallery.
For people that use Shiboken to create bindings, or link against the libpyside
library for any project, please notice that starting from 6.3.0 the QML related functionality was moved to a new library called libpysideqml
. The library libpyside
no longer has a dependency on QtQml, reducing the runtime dependencies for widget applications.
A new look for our documentation
The Qt for Python documentation is built with the help of many tools, and require more steps than the Qt Documentation. In a nutshell, we need to parse the official Qt docs, adapt the content to the typesystem
definitions we have for each module, and output that data in a format that could easily be picked up by Sphinx, to properly create the whole documentation. For the last releases, we had an ad-hoc theme that was a bit similar to the Qt documentation, but with the new visual changes we needed to find a proper solution.
Instead of hacking around our own theme, we decided to look in the work the Sphinx community has been doing, and we decided to use one of the most popular themes out there, Furo. Furo was written by Pradyun Gedam mainly for the pip documentation, but it has been adopted by many projects like urllib3, attrs, psycopg3, black, and even the Python Developer’s Guide.
Next steps
Now that you know all the new features and options we are providing with this new release, our job is now improve them in the following releases to have a smoother Python experience.
For that, we need your help! Let's know what's not working filing reports on the Qt Bug Reports system. Your feedback is crucial for us, because you are the ones making Qt for Python so popular 🥳
Let's stay in touch on the Community Platforms we have available, people join every day, and more folks are keen to help newcomers and experienced users!
We are working hard planning to have a better presence in embedded systems, which will hopefully unlock our future steps in mobile platforms.
Finally, we just wanted to share with you that this release was possible by the work of Friedemann Kleint, Christian Tismer, Shyamnath Premnadh, and Cristián Maureira-Fredes. With the active support of Simo Fält, Venugopal Shivashankar, and Alexandru Croitor. Thanks to everyone involved!
tl;dr: With 6.3.0 we split the PySide6 wheels into Essentials and Addons. PySide is compatible with PyPy 3.8. It's possible to cross compile PySide/Shiboken for embedded systems like Raspbery Pi. More QML decorators were added, and a new tool that generates ui/qrc files including qmltypes is now included (pyside6-project) and the docs have a new theme.
Blog Topics:
Comments
Subscribe to our newsletter
Subscribe Newsletter
Try Qt 6.8 Now!
Download the latest release here: www.qt.io/download.
Qt 6.8 release focuses on technology trends like spatial computing & XR, complex data visualization in 2D & 3D, and ARM-based development for desktop.
We're Hiring
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.