我有Qt和PyQt的商业许可证,我正在尝试构建所有必需软件的静态版本,以生成我目前使用Python3和PyQt编写的独立可执行程序。我打算使用VirtualBox本地构建,可能会针对Linux和Windows。我目前正在尝试设置Linux构建环境。
完成此任务的第一步是构建系统根目录,如下所述:http://pyqt.sourceforge.net/Docs/pyqtdeploy/build_sysroot.html
我正在使用build-sysroot.py,此处显示:https://www.riverbankcomputing.com/hg/pyqtdeploy/file/tip/Developers/build-sysroot.py
按照第一个链接中的说明,我创建了一个根目录(sysroot-linux),其中包含一个名为src的目录,该目录包含用于Qt5,PyQt5,sip,PyQtChart和Python的g-zipped源代码文件夹。 p>
我在VBox中使用Xubuntu 16.04 64位,以及商用PyQt-5.8,商业PyQtChart-5.8,Python-3.6.1,商用Qt-5.8.0和sip-4.19.2。我将我的Qt许可证信息复制到位于/home/(user)/.qt-license的文件中。我将PyQt许可文件复制到g-zipped PyQt / sip目录中。
当我在终端中运行以下命令时:
python3 build-sysroot.py --build qt python sip pyqt5 pyqtchart --sysroot /home/(user)/(path-to)/sysroot-linux
其中(user)是用户名,(path-to)是系统根目录的路径。
在此过程中大约1.5小时,我在PyQt构建过程中收到错误
Makefile:953: recipe for target 'sipQtNetworkpart1.o' failed
make[1]: \*** [sipQtNetworkpart1.o] Error 1
make[1]: Leaving directory '/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork'
Makefile:414: recipe for target 'sub-QtNetwork-make_first-ordered' failed
make: \*** [sub-QtNetwork-make_first-ordered] Error 2
Traceback (most recent call last):
File "build-sysroot.py", line 1073, in <module>
build_pyqt5(host, target, args.all, args.debug)
File "build-sysroot.py", line 735, in build_pyqt5
host.run(host.make)
File "build-sysroot.py", line 313, in run
subprocess.check_call(args)
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('make',)' returned non-zero exit status 2
销售PyQt的公司告诉我,我的Qt版本不支持SSL,但是我的PyQt配置文件启用了它。
所以我尝试使用build-sysroot.py中的“disable = QtNetwork”禁用Pytt配置中的QtNetwork,“args”中的函数“build_pyqt5”(python列表类型;参见第1个链接的第721行),但无济于事 - 该选项似乎已被忽略,无论如何都会尝试构建QtNetwork。
我与销售PyQt的公司保持联系,但我希望与更广泛的编程社区联系,看看过去是否有人成功完成了这项工作,并且可能提供洞察力。非常感谢任何帮助。
谢谢你, 克里斯
编辑1 这是完整的错误输出,只修改了目录路径:
make[1]: Entering directory '/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork'
g++ -c -pipe -O2 -fPIC -std=gnu++11 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -D_REENTRANT -DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../../include/python3.6 -I../../../Qt/include -I../../../Qt/include/QtNetwork -I../../../Qt/include/QtCore -I. -I../../../Qt/mkspecs/linux-g++ -o sipQtNetworkpart1.o sipQtNetworkpart1.cpp
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp: In function ‘PyObject* meth_QNetworkReply_sslConfiguration(PyObject*, PyObject*)’:
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:1094:55: error: ‘const class QNetworkReply’ has no member named ‘sslConfiguration’
sipRes = new ::QSslConfiguration(sipCpp->sslConfiguration());
^
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:1094:73: error: invalid use of incomplete type ‘class QSslConfiguration’
sipRes = new ::QSslConfiguration(sipCpp->sslConfiguration());
^
In file included from ../../../Qt/include/QtNetwork/QNetworkRequest:1:0,
from ../../../Qt/include/QtNetwork/qnetworkreply.h:48,
from /home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/sip/QtNetwork/qnetworkreply.sip:18:
../../../Qt/include/QtNetwork/qnetworkrequest.h:52:7: note: forward declaration of ‘class QSslConfiguration’
class QSslConfiguration;
^
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp: In function ‘PyObject* meth_QNetworkReply_setSslConfiguration(PyObject*, PyObject*)’:
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:1120:21: error: ‘class QNetworkReply’ has no member named ‘setSslConfiguration’
sipCpp->setSslConfiguration(*a0);
^
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp: In function ‘PyObject* meth_QNetworkReply_ignoreSslErrors(PyObject*, PyObject*)’:
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:1162:40: error: no matching function for call to ‘QNetworkReply::ignoreSslErrors(const QList<QSslError>&)’
sipCpp->ignoreSslErrors(*a0);
^
In file included from /home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/sip/QtNetwork/qnetworkreply.sip:18:0:
../../../Qt/include/QtNetwork/qnetworkreply.h:154:18: note: candidate: virtual void QNetworkReply::ignoreSslErrors()
virtual void ignoreSslErrors();
^
../../../Qt/include/QtNetwork/qnetworkreply.h:154:18: note: candidate expects 0 arguments, 1 provided
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp: In function ‘PyObject* meth_QNetworkAccessManager_connectToHostEncrypted(PyObject*, PyObject*, PyObject*)’:
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:12735:45: error: incomplete type ‘QSslConfiguration’ used in nested name specifier
{sipName_PutOperation, static_cast<int>( ::QNetworkAccessManager::PutOperation), 55},
^
/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork/sipQtNetworkpart1.cpp:12747:21: error: ‘class QNetworkAccessManager’ has no member named ‘connectToHostEncrypted’
{"encrypted(QNetworkReply*)", "\1encrypted(self, QNetworkReply)", 0, 0},
^
Makefile:953: recipe for target 'sipQtNetworkpart1.o' failed
make[1]: *** [sipQtNetworkpart1.o] Error 1
make[1]: Leaving directory '/home/(user)/(path-to)/sysroot-linux/build/PyQt5_commercial-5.8/QtNetwork'
Makefile:414: recipe for target 'sub-QtNetwork-make_first-ordered' failed
make: *** [sub-QtNetwork-make_first-ordered] Error 2
Traceback (most recent call last):
File "build-sysroot.py", line 1073, in <module>
build_pyqt5(host, target, args.all, args.debug)
File "build-sysroot.py", line 735, in build_pyqt5
host.run(host.make)
File "build-sysroot.py", line 313, in run
subprocess.check_call(args)
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '('make',)' returned non-zero exit status 2
答案 0 :(得分:0)
我会继续并分享我的解决方法,以防其他人遇到此问题。
目前,build-sysroot.py脚本使用pyqtdeploycli生成用于构建PyQt的配置文件,其中包括无法静态构建的Qt模块,例如QtWebEngine。无论如何,我最终为PyQt5制作了配置文件,并将其放入PyQt5源的顶级g-zipped文件夹中:
/home/(user)/(path-to)/sysroot-linux/src/PyQt5_commercial-5.8.2.tar.gz/PyQt5_commercial-5.8.2/pyqt5-linux-64.cfg
PyQt5配置文件(pyqt5-linux-64.cfg):
# The configuration for building PyQt5 for Linux.
# The target Python installation.
py_platform = linux
py_inc_dir = %(sysroot)/include/python%(py_major).%(py_minor)
py_pylib_dir = %(sysroot)/lib
py_pylib_lib = python%(py_major).%(py_minor)m
# The target PyQt installation.
pyqt_module_dir = %(sysroot)/lib/python%(py_major).%(py_minor)/site-packages
pyqt_sip_dir = %(sysroot)/share/sip/PyQt5
# Qt configuration common to all versions.
qt_shared = False
[Qt 5.6]
pyqt_modules = QtCore QtGui QtWidgets
[Qt 5.5]
pyqt_modules = QtCore QtGui QtWidgets
[Qt 5.4]
pyqt_modules = QtCore QtGui QtWidgets
[Qt 5.3]
pyqt_modules = QtCore QtGui QtWidgets
[Qt 5.2]
pyqt_modules = QtCore QtGui QtWidgets
然后我修改了build-sysroot.py build_pyqt5函数,不再唤起pyqtdeploycli,而只是使用手动创建的配置文件,如下所示:
def build_pyqt5(host, target, optional, debug):
""" Build a target static PyQt5. """
source = host.sysroot.find_source('PyQt5_*', optional=optional)
if source is None:
return
host.sysroot.unpack_source(source)
license_path = os.path.join(host.sysroot.src_dir, 'pyqt-commercial.sip')
if os.path.isfile(license_path):
shutil.copy(license_path, 'sip')
configuration = 'pyqt5-' + target.name + '.cfg'
# Disable the call to pyqtdeploycli here
# host.run(host.pyqtdeploycli, '--package', 'pyqt5', '--output',
# configuration, '--target', target.name, 'configure')
args = [host.interpreter, 'configure.py', '--static', '--qmake',
host.qmake, '--sysroot', str(host.sysroot), '--no-tools',
'--no-qsci-api', '--no-designer-plugin', '--no-python-dbus',
'--no-qml-plugin', '--no-stubs', '--configuration', configuration,
'--sip', host.sip, '--confirm-license', '-c', '-j2']
if debug:
args.append('--debug')
host.run(*args)
host.run(host.make)
host.run(host.make, 'install')
我只是为QtCore,QtGui和QtWidgets工作,但其他人可能也可以。