入门指南¶
从源代码构建¶
此步骤专注于从源代码构建Shiboken,包括生成器和Python模块。 请注意,当您从源代码构建PySide时,这些也会被构建,因此如果您已经构建了PySide,则无需继续。
一般要求¶
Python: 3.7+
Qt: 6.0+
libclang: 推荐使用libclang库,版本10适用于6.0及以上版本。预构建版本可以在这里下载。
CMake: 需要3.1及以上版本。
简单构建¶
如果你只需要Shiboken生成器,一个简单的构建运行将如下所示:
# For the required libraries (this will also build the shiboken6 python module)
python setup.py install --qtpaths=/path/to/qtpaths \
--build-tests \
--verbose-build \
--internal-build-type=shiboken6
# For the executable
python setup.py install --qtpaths=/path/to/qtpaths \
--build-tests \
--verbose-build \
--internal-build-type=shiboken6-generator
同样可以用于模块,将internal-build-type的值更改为
shiboken6-module。
警告
如果你也计划使用PySide,例如像‘scriptableapplication’这样的例子,你也需要构建它。主要问题是你的PySide和Shiboken需要使用来自Qt和libclang的相同依赖项来构建。
使用轮子¶
从 pip 安装 pyside6 或 shiboken6 不会 安装 shiboken6_generator,因为 wheels 不在 PyPi 上。
你可以从Qt服务器获取shiboken6_generator的wheels文件,并且你仍然可以通过pip安装它:
pip install \
--index-url=https://download.qt.io/official_releases/QtForPython/ \
--trusted-host download.qt.io \
shiboken6 pyside6 shiboken6_generator
whl 包无法自动发现您系统中以下内容的位置:
Clang 安装,
Qt 位置(由
qtpaths工具的路径指示),其版本/构建与 wheel 中描述的相同,具有相同包版本的Qt库。
因此,使用此过程需要您手动修改变量:
CLANG_INSTALL_DIR必须设置为库所在的位置,PATH必须包含与包相同 Qt 版本的qtpaths工具的位置版本与包相同,
LD_LIBRARY_PATH包含 Qt 库和 Clang 库的路径。