
рдирд┐рд╢реНрдЪрд┐рдд рд░реВрдк рд╕реЗ, рд╣рд░ рдХреЛрдИ рдЬреЛ рдХрдо рд╕реЗ рдХрдо рдПрдХ рдмрд╛рд░ рдкрд╛рдпрдерди рдореЗрдВ рдХреБрдЫ рд▓рд┐рдЦрддрд╛ рд╣реИ, рдмрд┐рдирд╛ рдХрд┐рд╕реА рд╕рд┐рд░рджрд░реНрдж рдХреЗ рдЕрдкрдиреЗ рдХрд╛рд░реНрдпрдХреНрд░рдо (рдпрд╛ рдпрд╣рд╛рдВ рддрдХ тАЛтАЛрдХрд┐ рдПрдХ рд╕рд░рд▓ рд╕реНрдХреНрд░рд┐рдкреНрдЯ) рдХреЛ рд╡рд┐рддрд░рд┐рдд рдХрд░рдиреЗ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рд╕реЛрдЪрддрд╛ рд╣реИ: рдЗрдВрдЯрд░рдкреНрд░реЗрдЯрд░ рдЦреБрдж рдХреЛ рд╕реНрдерд╛рдкрд┐рдд рдХрд░рдиреЗ рдХреЗ рдмрд┐рдирд╛, рд╡рд┐рднрд┐рдиреНрди рдирд┐рд░реНрднрд░рддрд╛рдПрдВ, рдХреНрд░реЙрд╕-рдкреНрд▓реЗрдЯрдлрд╝реЙрд░реНрдо, рддрд╛рдХрд┐ рдПрдХ рдлрд╝рд╛рдЗрд▓ -exe рдХрд╛ рдПрд╣рдиреЛрдо (рдЕрдВрддрд┐рдо рдЙрдкрд╛рдп, рдкреБрд░рд╛рд▓реЗрдЦ рдХреЗ рд░реВрдк рдореЗрдВ) рдФрд░ рд╕рдмрд╕реЗ рдЫреЛрдЯрд╛ рд╕рдВрднрд╡ рдЖрдХрд╛рд░ред
: PyInstaller, cx_Freeze, py2exe, py2app, Nuitka тАж , PyQt? , ( ) , PyQt, PyQt pyqtdeploy. , , , . , , , тАФ ( ). , : , , , , .
pyqtdeploy , , , , ?
. linux. , "exe'" .
, ( ). PyInstaller тАФ , , . 170 ( , PyQt5 180 ). , , тАФ QtCore, QtGui, QtWidgets тАФ . --exclude-module
. , --onefile
, 60 , . , , ( - ) 170 .
pyqtdeploy. " PyQtтАж - , - PyQt Qt?" тАФ .
pyqtdeploy? , , . ( , PyQt, ) Qt ( rcc) , C++, , //тАж . pyqtdeploy Python 3.5+ PyQt5. ( ):
- exe' PyQt4 PyQt5, Python 2.7 Python 3.3+ ( Python 3.7.2);
- ( exe') ( , тАФ );
- :
- android-32;
- android-64;
- ios-64;
- linux-64;
- macos-64;
- win-32;
- win-64;
- PyQt Qt , - QtCore, - .
pyqtdeploy
, Python 3.5+ PyQt5:
pip install PyQt5 pyqtdeploy
exe' :
- Python-, (!);
- sysroot , ;
- "" .pdy, exe' ( Qt, PyQt, Python, );
- exe' qmake.
: main.py тАФ " " , mainwindow.py тАФ , resources icon.png mainwindow.ui, Qt Designer. , :
main.py
src/
|---__init__.py
|---gui/
|---mainwindow.py
|---__init__.py
|---resources/
|---__init__.py
|---images/
|---icon.png
|---__init__.py
|---ui/
|---mainwindow.ui
|---__init__.py
sysroot ()
, , . sysroot.json ( , ). , (Python, Qt ..). pyqtdeploy API, , //whatever, pyqtdeploy. ( ):
openssl ( ) тАФ (). , sysroot.json, :
"android|macos|win#openssl": {
"android#source": "openssl-1.0.2r.tar.gz",
"macos|win#source": "openssl-1.1.0j.tar.gz",
"win#no_asm": true
}
, , : arch1|arch2|...#plugin-name
. , (ios, android, macos, win, linux), тАФ . , .
:
- source () тАФ ;
- no_asm ( ) тАФ . , PATH nasm;
- python_source ( ) тАФ , , OpenSSL macOS Python v3.6.4 ;
zlib ( ) тАФ ( , , , ) ():
"ios|linux|macos|win#zlib": {
"source": "zlib-1.2.11.tar.gz",
"static_msvc_runtime": true
}
:
- source () тАФ , ;
- static_msvc_runtime ( ) тАФ MSVC (Windows);
qt5 () тАФ ():
"qt5": {
"android-32#qt_dir": "android_armv7",
"android-64#qt_dir": "android_arm64_v8a",
"ios#qt_dir": "ios",
"linux|macos|win#source": "qt-everywhere-src-5.12.2.tar.xz",
"edition": "opensource",
"android|linux#ssl": "openssl-runtime",
"ios#ssl": "securetransport",
"macos|win#ssl": "openssl-linked",
"configure_options": [
"-opengl", "desktop", "-no-dbus", "-qt-pcre"
],
"skip": [
"qtactiveqt", "qtconnectivity", "qtdoc", "qtgamepad",
...
],
"static_msvc_runtime": true
}
:
- qt_dir ( , source) тАФ Qt;
- source ( , qt_dir) тАФ Qt;
- edition (, source) тАФ 2 :
- ssl тАФ 3 :
- openssl-linked тАФ ( openssl);
- securetransport тАФ SSL, Qt (, , AppleтАЩs Secure Transport);
- openssl-runtime тАФ OpenSSL, ;
- configure_options тАФ , Qt. , ;
- skip тАФ ( , top-level , ). Qt , qt тАФ top-level . , , . , top-level ();
- disabled_features тАФ .
configure -list-features
() - static_msvc_runtime ( ) тАФ MSVC (Windows);
python () тАФ ():
"python": {
"build_host_from_source": false,
"build_target_from_source": true,
"source": "Python-3.7.2.tar.xz"
}
:
- build_host_from_source () тАФ true тАФ Python , false тАФ Python ( win32);
- build_target_from_source () тАФ true тАФ Python , false тАФ Python ( Python win32);
- source (, Python ) тАФ Python;
- version (, Python) тАФ Python;
- dynamic_loading ( ) тАФ true тАФ (, C);
- host_installation_bin_dir ( ) тАФ Python, ( , win , тАФ PATH);
sip () тАФ , Python-bindings C/C++ ( ):
"sip": {
"module_name": "PyQt5.sip",
"source": "sip-4.19.15.tar.gz"
}
:
- module_name () тАФ sip-;
- source () тАФ sip;
pyqt5 () тАФ ():
"pyqt5": {
"android#disabled_features": [
"PyQt_Desktop_OpenGL", "PyQt_Printer", "PyQt_PrintDialog",
"PyQt_PrintPreviewDialog", "PyQt_PrintPreviewWidget"
],
"android#modules": [
"QtCore", "QtGui", "QtNetwork", "QtPrintSupport", "QtWidgets",
"QtAndroidExtras"
],
"ios#disabled_features": [
"PyQt_Desktop_OpenGL", "PyQt_MacOSXOnly",
...
],
"ios|macos#modules": [
"QtCore", "QtGui", "QtNetwork", "QtPrintSupport", "QtWidgets",
"QtMacExtras"
],
"linux#modules": [
"QtCore", "QtGui", "QtNetwork", "QtPrintSupport", "QtWidgets",
"QtX11Extras"
],
"win#disabled_features": ["PyQt_Desktop_OpenGL"],
"win#modules": [
"QtCore", "QtGui", "QtNetwork", "QtPrintSupport", "QtWidgets",
"QtWinExtras"
],
"source": "PyQt5_*-5.12.1.tar.gz"
}
:
- disabled_features ( ) тАФ . , , Qt ();
- modules () тАФ , ();
- source () тАФ PyQt;
pyqt3D, pyqtchart, pyqtdatavisualization, pyqtpurchasing, qscintilla ( ) тАФ , PyQt. source
тАФ .
, . sysroot , . , , .
sysroot
sysroot.json :
{
"linux#zlib": {
"source": "zlib-1.2.11.tar.gz"
},
"linux#qt5": {
"source": "qt-everywhere-src-5.12.2.tar",
"edition": "opensource",
"configure_options": [
"-no-dbus", "-no-system-proxies", "-no-cups", "-no-sql-db2",
"-no-sql-ibase", "-no-sql-mysql", "-no-sql-sqlite",
"-no-sql-sqlite2", "-no-sql-oci", "-no-sql-odbc",
"-no-sql-psql", "-no-sql-tds", "-no-sqlite", "-ccache",
"-optimize-size"
],
"skip": [
"qt3d", "qtactiveqt", "qtandroidextras", "qtcanvas3d",
"qtcharts", "qtconnectivity", "qtdatavis3d", "qtdeclarative",
"qtdoc", "qtgamepad", "qtgraphicaleffects", "qtlocation",
"qtmacextras", "qtmultimedia", "qtnetworkauth", "qtpurchasing",
"qtquickcontrols", "qtquickcontrols2", "qtremoteobjects",
"qtscript", "qtscxml", "qtsensors", "qtserialbus",
"qtserialport", "qtspeech", "qtsvg", "qttools",
"qttranslations", "qtvirtualkeyboard", "qtwayland",
"qtwebchannel", "qtwebengine", "qtwebglplugin",
"qtwebsockets", "qtwebview", "qtwinextras", "qtx11extras",
"qtxmlpatterns"
],
"disabled_features": [
"network", "bearermanagement", "dnslookup", "dtls", "ftp",
"http", "localserver", "networkdiskcache", "networkinterface",
"networkproxy", "socks5", "udpsocket", "concurrent", "future",
"cups", "printer", "printdialog", "printpreviewdialog",
"printpreviewwidget", "sql", "sqlmodel", "testlib", "xml"
]
},
"linux#python": {
"build_host_from_source": false,
"build_target_from_source": true,
"source": "Python-3.7.2.tgz",
"dynamic_loading": true
},
"linux#sip": {
"module_name": "PyQt5.sip",
"source": "sip-4.19.15.tar.gz"
},
"linux#pyqt5": {
"modules": ["QtCore", "QtGui", "QtWidgets"],
"source": "PyQt5_*-5.12.2.tar.gz"
}
}
? -, (, ssl, pyqt3D ). -, exe' linux ( , linux-64; , ).
, qt5 - , (, ). top-level QtBase. -optimize-size
-ccache
. Qt , , ( 5 ), , тАФ ccache ( , linux), ( 5). , apt install ccache
.
pyqt5 QtCore, QtGui, QtWidgets.
python dynamic_loading
, C-extension.
sysroot, : zlib, Qt5, Python, sip, PyQt5 sysroot.json ( , ). :
pyqtdeploy-sysroot sysroot.json
, .
--verbose
. , , . , dev-. , . , python3-dev, (, Requirements). , Qt Python ( , ).
, , , .
"" ()
, , exe'. pyqtdeploy GUI. ( .pdy ):
pyqtdeploy main.pdy

Application Source. :
- Name тАФ exe';
- Main script file ( , Entry Point) тАФ , ( , main.py);
- Entry Point ( , Main script file) тАФ , setuptools;
- sys.path тАФ , zip- (, Python egg), sys.path ( , , );
- Target Python version тАФ Python;
- Target PyQt version тАФ PyQt4 PyQt5 (, , PyQt, );
- Use console тАФ , ( Windows). ;
- Application bundle тАФ , bundle ( MacOS);
- Application Package Directory тАФ , . ScanтАж "" (src) main.py, , . (.. main.py src), main.py ( , Main script file).
: .py "" ( -) тАФ .
:
- ScanтАж тАФ Application Package Directory;
- Remove all тАФ Application Package Directory;
- Include all тАФ Application Package Directory;
- Exclude all тАФ Application Package Directory;
- Exclusions тАФ , Application Package Directory. ;
qmake. qmake, ( );

PyQt Modules. PyQt-, . , . QtCore, QtGui, QtWidgets, uic; sip .
PyQt, , ( ).

Standard Library. , , . - , . ( ) , ().
. - ( pip), - ( ), ImportError
. . , PIL, fractions.
Python / (, ssl), . , . INCLUDEPATH (headers), LIBS тАФ ( , ).

Other Packages. (, pypi). , Application source: , ( , site-packages virtual environment), Scan / ( PIL).
Other Extension Modules. C, exe' (; , , ).
, . . Package Lib.a, Name , тАФ Package.Lib ( .a); LIBS , , -L/home/user1/venv/programme1/lib/python3.7/site-packages/Package -lLib ( , " ", /home/user1/venv/programme1/lib/python3.7/site-packages/Package/Lib.a).
, , -, , -, qmake ( , pyqt' ).
, , , Lib.so? тАФ Package.Lib.so (.. , + ) exe'. , . , ImportError
. , , _imaging.so, PIL'.
Locations. , . ( sysroot , main.pdy), .
exe' ()
- :
pyqtdeploy-build main.pdy
cd build-linux-64
../sysroot-linux-64/host/bin/qmake
make #nmake win
, , тАФ .
#1 тАФ , ""
, exe', , PyInstaller:
if getattr(sys, 'frozen', False):
else:
#2 тАФ (, .)
Qt " ", rcc exe'. . icon.png src/resources/images, " " тАФ :/src/resources/images/icon.png. , . тАФ Qt' . .. - :
icon = QIcon(':/src/resources/images/icon.png')
. , , :
icon_file = open(':/src/resources/images/icon.png', 'rb')
icon = icon_file.read()
, open
, , .
Qt (, , , GUI Qt Designer .ui, loadUi
), - :
ui_file = QtCore.QFile(':/src/resources/images/icon.png')
ui_file.open(QtCore.QIODevice.ReadOnly)
data = ui_file.readAll()
ui_file.close()
ui_file = BytesIO(bytes(data))
, exe', - ? PyQt, , , . - ( PyInstaller). тАФ . ~40 (c -optimize-size
~35 ), - , .
рдЬрдм рд╣рдордиреЗ рдиреНрдпреВрдирддрдо рдЖрд╡рд╢реНрдпрдХ Qt рдФрд░ PyQt рдПрдХрддреНрд░ рдХрд┐рдП рд╣реИрдВ, рддреЛ PyInstaller рдпрд╛ cx_Freeze рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ рдЙрдирдХреЗ рдЖрдзрд╛рд░ рдкрд░ рдПрдХ exe рдмрдирд╛рдиреЗ рдХрд╛ рдкреНрд░рдпрд╛рд╕ рдХрд░рдирд╛ рдЕрдЪреНрдЫрд╛ рд╣реЛрдЧрд╛ рдФрд░ рдЖрдХрд╛рд░ рджреЗрдЦреЗрдВ, рд▓реЗрдХрд┐рди рдпрд╣, рдЬреИрд╕рд╛ рдХрд┐ рд╡реЗ рдХрд╣рддреЗ рд╣реИрдВ, рдПрдХ рдФрд░ рдХрд╣рд╛рдиреА рд╣реИ ...