Qt for Python关于新6.3版本的详细信息

Qt for Python details on the new 6.3 release

Qt for Python关于新6.3版本的详细信息

Wednesday April 13, 2022 by Cristián Maureira-Fredes | Comments

​2022年4月13日星期三 克里斯蒂安·毛雷拉·弗雷德斯 | 评论

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

分而治之:新的包结构

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.  

从5.12版PySide的首次正式发布开始,我们决定将所有与Qt相关的模块打包在同一个包中。这很好,因为人们不必担心要安装什么,但却给试图部署应用程序的人带来了一点困难,因为他们需要过滤掉包含的许多二进制文件。

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.

​此外,PyPi服务器对控制盘大小和项目大小有一定的限制,这对于我们的包和未来的版本都是不够的。

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:

考虑到这些想法,我们决定将PySide轮子分为两部分:Essentials和Addons,但不要担心!您仍然可以运行pip安装pyside6并获得所有模块!我们刚刚提供了一个更细粒度的包分发,以改善当前的情况。这就是软件包的依赖关系和分布现在的样子:

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.

​我们在Qt Essential列表的顶部添加了一些额外的模块,这主要是由于我们在控制盘中部署的工具的依赖性。检查Essentials和Addons包中包含的模块列表。

Even with these changes in mind, the new size of the packages was not within the limit, and unfortunately we didn't get a green light in time for the release so we were unable to upload our wheels to PyPi. You can check the requests here and here. The PyPi team is always very busy, but we do expect to have an answer soon that will enable us to upload the releases to their servers.

​即使考虑到这些变化,软件包的新大小也不在限制之内,不幸的是,我们没有及时获得发布的绿灯,因此我们无法将轮子上载到PyPi。你可以在这里和这里查看请求。PyPi团队总是很忙,但我们确实希望很快能有一个答案,使我们能够将发布的内容上传到他们的服务器上。

However you can still install 6.3.0 by passing an extra argument to your installation command line, using the index-url option pointing to our servers.

但是,您仍然可以通过向安装命令行传递一个额外参数,使用指向我们服务器的index-url选项来安装6.3.0。

Now if you want to install only the essential modules, you will need to run:

现在,如果只想安装基本模块,则需要运行:

​
pip install pyside6_essentials --index-url=https://download.qt.io/official_releases/QtForPython/split-wheels/

 or if you need all the modules, the usual

或者如果你需要所有的模块

pip install pyside6 --index-url=https://download.qt.io/official_releases/QtForPython/split-wheels/

that will include PySide6_Essentials and PySide6_Addons

​这将包括PySide6_Essentials和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. 

如果我们看到需要,当前的结构将允许我们在未来改进包的粒度,同时保持相同的元包。

We will do a new announcement once the official wheels are uploaded into PyPi.

一旦官方车轮上传到PyPi,我们将发布新的公告。

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'

​注意:Linux控制盘现在使用的是PEP600,这意味着我们离开了“manylinux1”标签,开始使用glibc版本的平台:“manylinux_2_28”

Python Compatibility

Python兼容性

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.

​Python3.6已经走到了尽头,6.3发行版系列将是最后一个支持Python3.6的版本。从6.4.0开始,兼容性将被完全删除,而Python 3.7是最低要求的版本。

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.

​对于商业客户,M2M协议模块可在另一个名为PySide6_M2M的控制盘上使用,该控制盘可从您的Qt帐户页面获得。

A faster Qt for PyPython 

PyPython的更快Qt

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.

​如果您不知道,大多数人使用的“Python”是用C编写的标准实现,称为CPython。小心别以为这是另一个叫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. 

​在这个版本中,一个新的Python解释器被集成到我们支持的解释器列表中,它与CPython很不同:它是PyPy,专门用于高效的跟踪JIT。在我们的Mandelbrot示例中,PyPy的工作速度是CPython 3.10的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. 

PyPy兼容性的状态已经足够好,可以使用它了,而一些更深奥的测试还没有工作(只有2%)。几乎所有的例子都可以很好地使用它,安装后可以立即试用。

 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的兼容性在Python3.8版本(请查看Py3.8)。有几件事是不同的:

  • PyPy has no reference counting, which is the mechanism that CPython uses to keep track of object lives.

  • PyPy没有引用计数,这是CPython用来跟踪对象生命的机制。

  • PyPy cannot support the Limited API (it's impossible) 

  • PyPy无法支持有限的API(这是不可能的)

  • PyPy cannot support our switchable features (The __feature__ option), but they will probably be available in the next versions.

  • PyPy无法支持我们的可切换功能(__feature__选项),但它们可能会在下一个版本中提供。

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!

Python模块通常可以很好地与PyPy配合使用。然而,由于这些库可能具有的特殊情况,扩展模块可能工作,也可能不工作,这就是PySide情况,它是迄今为止支持PyPy的最大扩展模块。如果你喜欢数字应用,NumPy扩展模块在没有任何变化的情况下工作得很好!

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

​当然,您可以像使用python一样构建PySide,但是使用pypy并自己尝试,但是如果您想尝试我们的控制盘,可以在这里下载它们。 

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.

这是PySide第一次适应不同的Python实现,我们需要改进PySide的几个部分,使其不那么特定于CPython。

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) 

Linux嵌入式系统的交叉编译(技术预览)

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

自Qt for Python发布以来,嵌入式支持一直是最受欢迎的功能之一,我们非常高兴地告诉您,现在它已成为现实!

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

  • 很多人都有像Raspberry Pi这样的嵌入式系统,他们正在做非常酷的项目,需要一个漂亮的UI,而且

  • people with different platforms and architectures are trying to get PySide and Shiboken to work, without compiling on the devices.

  • 拥有不同平台和架构的人们正试图让PySide和Shiboken在无需设备编译的情况下工作。

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.

从历史上看,过去有很多人尝试过,我们在描述部分工作过程的Qt Bug Reports系统中有一些旧问题,甚至包括构建系统的补丁,它没有为此类任务做好准备,不是在CMake级别,也不是在setuptools级别。

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.

在Qt构建系统团队的帮助下,整个构建基础设施得到了升级、清理和改进,因此我们最终可以交叉编译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:

要交叉编译该项目,只需稍微调整一下典型的setup.py调用。该命令可能如下所示:

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,

  • Yocto支持,

  • testing other embedded systems platforms, and

  • 测试其他嵌入式系统平台,以及

  • packaging the sources for projects like piwheels to be able to distribute Shiboken and PySide,

  • ​将piwheels等项目的资源打包,以便能够分发Shiboken和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 😉.

​作为起点,我们使用了两个Raspberry Pi设备,并依赖于滚动发布的Linux发行版,如Archlinux ARM和Manjaro ARM,它们已经提供了Qt包。然而,我们这里的主要目标之一是为Raspberry Pi OS提供Python包,这将需要人们付出更多努力,以在Debian中获得一个合适的Qt 6打包,但这是下一次的主题😉.

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 ✨

​你可以在这里找到我们创建的指南,我们希望你能成功地尝试一下,并为你的树莓Pi获取Python轮子✨

Long live to pyside6-project!

pyside6项目万岁!

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.

你熟悉例子中看到.pyproject文件吗?如果没有,这些文件就是我们可以在QtCreator中打开Qt for Python项目的原因,并允许我们保留属于每个项目的文件的信息。

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.

我们觉得我们可以利用这些信息做更多的事情,所以我们决定自动化处理用户经常遇到的一些问题,比如将ui和qrc文件生成到Python类中。

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.

添加了一个名为pyside6 project的新构建工具的实验版本。如前所述,您只需要依靠.pyproject文件自动生成。

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.

但这并不是全部,如果您的项目使用QML并且有自己的类型,那么它也会创建.qmltypes文件,如果要使用qmlint,则需要这些文件。没错,你现在也可以检查你的QML代码了!,这就引出了下一个话题。

Better QML support

更好的QML支持

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.

在最初的实现中,我们获得了6.0的QmlElement元素装饰器,它取代了C++中的QML_ELEMENT,这是自然的,我们将继续暴露越来越多的装饰器来改进项目的QML支持。

Starting from 6.3 you can also use QmlAnonymousQmlAttachedQmlExtendedQmlForeignQmlNamedElement and QmlUncreatable. New examples under examples/declarative/referenceexamples/ demonstrate their use.  Remember that you can also navigate the examples in our examples gallery.

​从6.3开始,您还可以使用QmlAnonymous、QmlAttached、QmlExtended、QmlForeign、QmlNamedElement和qmluncreateable。examples/declarative/referenceexamples/下的新示例演示了它们的用法。请记住,您也可以在我们的示例库中浏览示例。

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. 

对于使用Shiboken为任何项目创建绑定或链接libpyside库的人,请注意,从6.3.0开始,与QML相关的功能被移动到一个名为libpysideqml的新库。libpyside库不再依赖于QtQml,从而减少了widget应用程序的运行时依赖性。

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.

Qt for Python文档是在许多工具的帮助下构建的,需要比Qt文档更多的步骤。简而言之,我们需要解析正式的Qt文档,根据每个模块的typesystem定义调整内容,并以Sphinx可以轻松获取的格式输出数据,以正确创建整个文档。在上一个版本中,我们有一个特别的主题,有点类似于Qt文档,但随着新的视觉变化,我们需要找到一个合适的解决方案。

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 urllib3attrspsycopg3black, and even the Python Developer’s Guide.

​我们决定看看斯芬克斯社区一直在做的工作,而不是围绕我们自己的主题进行黑客攻击,我们决定使用最流行的主题之一,Furo。Furo是由Pradyun Gedam编写的,主要用于pip文档,但它已被许多项目采用,如urllib3、ATTR、psycopg3、black,甚至是Python开发者指南。​

 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.

既然您已经了解了我们在这个新版本中提供的所有新特性和选项,我们的工作就是在下面的版本中改进它们,以获得更流畅的Python体验。

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 🥳

​为此,我们需要你的帮助!让我们知道什么不起作用,在Qt Bug报告系统上提交报告。您的反馈对我们来说至关重要,因为您是让Qt for Python如此流行的人🥳

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!

最后,我们只想与大家分享,弗里德曼·克莱因、克里斯蒂安·蒂斯默、希亚姆纳特·普雷姆纳德和克里斯蒂安·莫雷拉·弗雷德斯的工作使这次释放成为可能。在Simo Fält、Venugopal Shivashankar和Alexandro Croitor的积极支持下。感谢所有参与的人!

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.

在6.3.0中,我们将PySide6轮子分为基本组件和附加组件。PySide与PyPy 3.8兼容。可以为Raspbery Pi等嵌入式系统交叉编译PySide/Shiboken。添加了更多的QML装饰器,现在包含了一个新工具(pyside6项目),该工具可以生成包含QML类型的ui/qrc文件,文档有了一个新的主题。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值