https://github.com/patrickkidd/pyqtdeploy-demo
https://github.com/patrickkidd/pyqtdeploy-demo
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/patrickkidd/pyqtdeploy-demo
- Owner: patrickkidd
- Created: 2022-10-12T15:33:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-27T16:51:07.000Z (over 2 years ago)
- Last Synced: 2025-02-06T04:11:53.097Z (over 1 year ago)
- Language: Python
- Size: 303 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
pyqtdeploy-demo
==================================================================================
This project is an effort at a non-happy path demo for pyqtdeploy. As with all
python deployment tools, there can be a number of problems getting a project up
and running with pyqtdeploy. These problems can be difficult to troubleshoot. This
project is meant to track some common problems using pyqtdeploy and associated python
extensions modules, demonstrate solutions to them, and serve as an example for
non-straightfoward pyqtdeploy project elements listed below under the "Goals"
section below.
TLDR; Setup Environment
----------------------------------------------------------------------------------
```
# Local python environment
pyenv install 3.10.6
pyenv shell 3.10.6
pip install pipenv
pipenv install
```
TLDR; Develop/Debug Application
----------------------------------------------------------------------------------
```
pipenv shell
cd cpythononly && sip-install
cd cpythonplusqt && sip-install
python pyqtdeploy-demo.py
```
TLDR; Build Application
----------------------------------------------------------------------------------
```
# Build sysroot
pyqtdeploy-sysroot --verbose sysroot/sysroot.toml
# Build demo application
pyqtdeploy-build --verbose pyqtdeploy-demo.pdt
cd build-macos-64
qmake
make -j16
```
Goals:
----------------------------------------------------------------------------------
- Patch Qt before build.
- Include a custom pure sip/CPython+Python extension.
- Include a custom sip/CPython+Python extension that extends Qt.
- Include python+pyqt application code
- Import and use all included custom sip extensions.
- Include png resource files in application code.
- Be able to run un-deployed application via source for development.
- Copy-pastable TLDR commands to get a working app binary (if possible)
- Include any necessary changes to sip/pyqt/pyqtbuilder/etc extension code.
Changes To Original pyqt-demo Concept
----------------------------------------------------------------------------------
- Renamed `pyqt-demo.py` to `pyqtdeploy-demo.py`
- Moved ./sysroot.toml to ./sysroot/sysroot.toml
- Added ./Qt.py component plugin to patch Qt-5.15+ on macOS.
- Added ./Qt.py, ./OpenSSL.py, ./python.py component plugins to allow for concurrent builds.
- Added ./cpythononly, ./cpythononly.py for python+cpython only sip extension.
- Added ./cpythonplusqt, ./cpythonplusqt.py for python+cpython+qt sip extension.
List of Problems Discovered in Chronological Order for Base pyqt-demo
----------------------------------------------------------------------------------
- Prerequisite python environment?
- `pip install sip, pyqt5, pyqt-builder`
- Have to make a choice for venv, choosing pipenv.
- ** Created Pipfile, .venv dir to house venv in project dir.
- Why build-demo.py over just TLDR copy-pasta commands?
- pyqtdeploy-sysroot, pyqtdeploy-build, cd build-macos-64 && qmake, make -j16
- Could see as instructive example but can be unclear if it's necessary
- Could see helpful to copy pyqt-demo.py.dat, but why not just do that in the release tarball?
- Can also obscure underlying use of executables, basic sip/pyqtdeploy-* concepts.
- Building sysroot (pyqtdeploy-sysroot)
- took two days with some experience with Qt, PyQt*
- Always recommend --verbose for pyqtdeploy-* to troubleshoot inevitable errors
- pyqtdeploy-sysroot --verbose sysroot.toml
- troubleshooting build errors is timeconsuming without option for parallel builds
- ** Added PYQTDEPLOY_SYSROOT_JOBS env var to `pyqtdeploy` and `pyqtbuild`
- Compile error in Qt-5.15.2-6 on macos: https://github.com/conan-io/conan-center-index/blob/master/recipes/qt/6.x.x/patches/dece6f5.patch
- Had to move `#include ` to first include in file.
- Had to:
1. Create new archive qt-everywhere-src-5.15.6-patched.tar.xz
2. Create debuggable pythons script version of pyqtdeploy-build "exe" that
to step through pyqtdeploybuild_main, to understand pyqtdeploy plugin arch, etc.
3. Create new Qt.py in root project dir to point to new source path instead
of pyqtdeploy automatically downloading buggy source tarball.
- Building qmake project (pyqtdeploy-build)
- Worked out of the box
- Generating makefiles (qmake)
- Run w/ relative path to qmake in sysroot: ./sysroot-macos-64/Qt/bin/qmake
- Then worked
- Compiling project sources (make)
- Compiled + Linked out of the box
- Running binary (./pyqt-demo)
- ERROR
Traceback (most recent call last):
File "pyqt-demo.py", line 269, in
File "pyqt-demo.py", line 224, in create_qscintilla_code_view
File "pyqt-demo.py", line 190, in get_source_code
File ":/importlib/resources.pyo", line 103, in read_text
File ":/importlib/resources.pyo", line 82, in open_text
File ":/importlib/resources.pyo", line 46, in open_binary
SystemError: returned NULL without setting an exception
- Had to read code for `pdytools`
- Adding cpythononly to packages in pyqtdeploy project didn't include sip cpp module sources.