From 6b16e5557ea43a1488b2c63d9b5945307216e504 Mon Sep 17 00:00:00 2001 From: jm Date: Sat, 8 Jan 2022 15:06:11 -0800 Subject: [PATCH 1/5] Pyside build command for building from source. --- Makefile.toml | 19 ++++++++++++++++--- pyproject.toml | 2 +- swiftnav_console/main.py | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index be154ec6f..f8fb060a0 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -383,15 +383,28 @@ script = ''' touch ./py39-dist/.frozen ''' +[tasks.pre-build-dist] +dependencies = [ + "prep-dist", + "build-dist-copy-resources", + "build-dist-freeze", + "install-qt", +] + +[tasks.install-qt] +script_runner = "@duckscript" +script = ''' +exec --fail-on-error /home/jm/swift-toolbox/py39-dist/bin/python3.9 /home/jm/pyside-setup/setup.py install --qt 5.15.2 --qmake=/home/jm/Qt/5.15.2/gcc_64/bin/qmake --parallel=8 --relwithdebinfo --standalone --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,Widgets,Charts +''' + [tasks.build-dist] -dependencies = ["prep-dist"] run_task = [ { name = [ "build-dist-install-frontend-wheel", "build-dist-install-backend-wheel", "build-dist-install-console", - "build-dist-copy-resources", - "build-dist-freeze", + # "build-dist-copy-resources", + # "build-dist-freeze", ] }, ] diff --git a/pyproject.toml b/pyproject.toml index 7223702c6..af5c1e026 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ readme = "README.md" classifiers = [] requires-python = ">=3.8" dynamic = ['version', 'description'] -dependencies = ["PySide2 ~= 5.15.2", "pycapnp ~= 1.1.0"] +dependencies = ["pycapnp ~= 1.1.0"] [project.optional-dependencies] test = [ diff --git a/swiftnav_console/main.py b/swiftnav_console/main.py index b61a8cc6a..52f96ffd0 100644 --- a/swiftnav_console/main.py +++ b/swiftnav_console/main.py @@ -4,6 +4,7 @@ import os import sys import threading +import time from typing import List, Any, Optional, Tuple @@ -226,7 +227,10 @@ def receive_messages(app_, backend, messages): + start = time.time() while True: + if time.time() - start > 10: + return app_.quit() buffer = backend.fetch_message() if not buffer: print("terminating GUI loop", file=sys.stderr) From 42920cc61718a7f336bbe294bddeab53f16c0007 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Tue, 22 Feb 2022 17:24:24 -0500 Subject: [PATCH 2/5] Add readme showing how to loop-run the debugger Add a readme and a script that describe how to run the app in a looped fashion to help debug intermittent startup crashes. --- README.debug.md | 35 +++++++++++++++++++++++++++++ debug_intermittent_startup_crash.sh | 17 ++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 README.debug.md create mode 100755 debug_intermittent_startup_crash.sh diff --git a/README.debug.md b/README.debug.md new file mode 100644 index 000000000..d22a25b6a --- /dev/null +++ b/README.debug.md @@ -0,0 +1,35 @@ +# Debugging Swift Toolbox 🧰 + +## Setup + +Follow README.md + +# Build the build-dist target + +``` +cargo make build-dist +``` + +## Debugging an intermittent crash on startup + +# Linux +``` +cd py39-dist +for i in {1..1000}; do + rust-gdb -ex='set confirm on' -ex run -ex=quit --args swift-console --log-console --file ../console_backend/tests/data/ins_updates.sbp + echo ${i} +done +``` + +# macOS + +``` +cd py39-dist +for i in {1..1000}; do + rust-lldb -o run -o quit -- ./swift-console --log-console --file ../console_backend/tests/data/ins_updates.sbp + echo ${i} +done +``` + +For your convenience a script is provided that will perform this looped +execution. You can find it at `./debug_intermittent_startup_crash.sh` diff --git a/debug_intermittent_startup_crash.sh b/debug_intermittent_startup_crash.sh new file mode 100755 index 000000000..c165c6560 --- /dev/null +++ b/debug_intermittent_startup_crash.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! -d py39-dist ]; then + cargo make build-dist +fi +cd py39-dist + +trap "echo Ctrl-C pressed, exiting loop. ; exit" SIGINT SIGTERM + +for i in {1..1000}; do + if [ $(uname) == "Darwin" ]; then + rust-lldb -o run -o quit -- ./swift-console --log-console --file ../console_backend/tests/data/ins_updates.sbp + else + rust-gdb -ex='set confirm on' -ex run -ex=quit --args swift-console --log-console --file ../console_backend/tests/data/ins_updates.sbp + fi + echo ${i} +done From 4390710c056b27d155913d412c4c2f8fe2078940 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 9 Mar 2022 15:34:31 -0500 Subject: [PATCH 3/5] Update .gitignore rules for qt for python and vscode --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b4bc20783..cb72eac9e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ get-pip.py installers/Windows/*.exe installers/Linux/*.deb installers/Windows/NSIS/ +/.qt_for_python +/.vscode/launch.json From 6d9a43b5d2a55bfca6c665f8417dc79dfdcae5f0 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Thu, 10 Mar 2022 13:52:29 -0500 Subject: [PATCH 4/5] Improve pyside build from src for Windows * This improves the build process to build PySide2 from sources to allow for debugging. * With this change, one should be able to build PySide2 and build, install the console into the dist python installation. * Steps to be able to run the console from a blank slate with PySide2 built from source, run these steps: + cargo make pre-build-dist + cargo make build-dist + py39-dist/python.exe -m swiftnav_console.main --- Makefile.toml | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index f8fb060a0..5809e6509 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -7,6 +7,7 @@ if eq ${os} windows set_env STANDALONE_PY_URL "${PY_BASE_URL}/cpython-3.9.7-x86_64-pc-windows-msvc-shared-pgo-20211017T1616.tar.zst" set_env PYTHON "${WORKSPACE}\\py39\\python.exe" set_env DIST_PYTHON "${WORKSPACE}\\py39-dist\\python" + set_env DIST_PYSIDE2_RCC "${WORKSPACE}\\py39-dist\\Lib\\site-packages\\PySide2\\rcc.exe" set_env PYSIDE2_RCC "${WORKSPACE}\\py39\\Lib\\site-packages\\PySide2\\rcc.exe" set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-win_amd64.whl set_env BUILD_TRIPLET "x86_64-pc-windows-msvc" @@ -16,6 +17,7 @@ elseif eq ${os} linux set_env STANDALONE_PY_URL "${SWFT_PY_BASE_URL}/cpython-3.9.10-x86_64-unknown-linux-gnu-pgo+lto-20220203T2103.tar.zst" set_env PYTHON "${WORKSPACE}/py39/bin/python3" set_env DIST_PYTHON "${WORKSPACE}/py39-dist/bin/python3" + set_env DIST_PYSIDE2_RCC "${WORKSPACE}/py39-dist/bin/pyside2-rcc" set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc" set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-linux_x86_64.whl set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt" @@ -27,6 +29,7 @@ else set_env STANDALONE_PY_URL "${PY_BASE_URL}/cpython-3.9.7-x86_64-apple-darwin-pgo+lto-20211017T1616.tar.zst" set_env PYTHON "${WORKSPACE}/py39/bin/python3" set_env DIST_PYTHON "${WORKSPACE}/py39-dist/bin/python3" + set_env DIST_PYSIDE2_RCC "${WORKSPACE}/py39-dist/bin/pyside2-rcc" set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc" set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt" @@ -115,6 +118,16 @@ writefile /tmp/piksi_tools_constants.py ${output.stdout} exec --fail-on-error ${python} -m py2many --rust=1 /tmp/piksi_tools_constants.py --outdir console_backend/src/ ''' +[tasks.dist-generate-resources] +command = "${DIST_PYSIDE2_RCC}" +args = [ + "resources/console_resources.qrc", + "-o", + "swiftnav_console/console_resources.py", + "-g", + "python", +] + [tasks.generate-resources] command = "${PYSIDE2_RCC}" args = [ @@ -237,13 +250,23 @@ args = [ "./console_backend", ] +[tasks.dist-install-pip-flit] +command = "${DIST_PYTHON}" +args = ["-m", "pip", "install", "flit"] + [tasks.build-frontend-wheel] -command = "${PYTHON}" +dependencies = ["dist-install-pip-flit"] +command = "${DIST_PYTHON}" args = ["-m", "flit", "build", "--no-setup-py"] +[tasks.dist-install-pip-setuptools-rust] +command = "${DIST_PYTHON}" +args = ["-m", "pip", "install", "setuptools_rust"] + [tasks.build-backend-wheel] +dependencies = ["dist-install-pip-setuptools-rust"] cwd = "console_backend" -command = "${PYTHON}" +command = "${DIST_PYTHON}" args = ["setup.py", "-vv", "bdist_wheel"] [tasks.get-get-pip] @@ -385,16 +408,29 @@ touch ./py39-dist/.frozen [tasks.pre-build-dist] dependencies = [ + "setup-builder", "prep-dist", "build-dist-copy-resources", "build-dist-freeze", - "install-qt", + "build-install-pyside", ] -[tasks.install-qt] +[tasks.build-install-pyside] script_runner = "@duckscript" script = ''' -exec --fail-on-error /home/jm/swift-toolbox/py39-dist/bin/python3.9 /home/jm/pyside-setup/setup.py install --qt 5.15.2 --qmake=/home/jm/Qt/5.15.2/gcc_64/bin/qmake --parallel=8 --relwithdebinfo --standalone --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,Widgets,Charts +# Note: To make build-install-pyside work on Windows, you need to run from a powershell or cmd shell +# that is a VS2019 or other visual studio command line (vcvars*.bat needs to be sourced). +# To set up a powershell with the Visual Studio environment, run these two commands: +# Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" +# Enter-VsDevShell -VsInstanceId fdbeecbc -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo' +# You may also need to add `jom` to the path to allow parallel builds to work. You can find this installed +# in a standard Qt installation in the Qt\Tools\QtCreator\bin\jom directory. +if eq ${os} windows + lib = get_env LIB + set_env LIB "${lib};${WORKSPACE}\\py39-dist\\libs" +end +exec --fail-on-error ${DIST_PYTHON} -m pip install setuptools wheel packaging +exec --fail-on-error ${DIST_PYTHON} ${WORKSPACE}/../pyside-setup/setup.py install --qt 5.15.2 --qmake=D:/Qt/5.15.2/msvc2019_64/bin/qmake.exe --parallel=8 --relwithdebinfo --standalone --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,Widgets,Charts ''' [tasks.build-dist] @@ -403,6 +439,7 @@ run_task = [ "build-dist-install-frontend-wheel", "build-dist-install-backend-wheel", "build-dist-install-console", + "dist-generate-resources", # "build-dist-copy-resources", # "build-dist-freeze", ] }, From 27bc2bfd4f2b1cd0d3c19509a192e7eeb18006e2 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Thu, 10 Mar 2022 14:12:06 -0500 Subject: [PATCH 5/5] clone pyside if !found when running pre-build-dist --- Makefile.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 5809e6509..34c0836c4 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -415,7 +415,15 @@ dependencies = [ "build-install-pyside", ] +[tasks.clone-pyside-repo] +condition = { files_not_exist = ["${WORKSPACE}/pyside-setup/setup.py"] } +script_runner = "@duckscript" +script = ''' + exec --fail-on-error git clone http://code.qt.io/pyside/pyside-setup.git +''' + [tasks.build-install-pyside] +dependencies = ["clone-pyside-repo"] script_runner = "@duckscript" script = ''' # Note: To make build-install-pyside work on Windows, you need to run from a powershell or cmd shell @@ -430,7 +438,7 @@ if eq ${os} windows set_env LIB "${lib};${WORKSPACE}\\py39-dist\\libs" end exec --fail-on-error ${DIST_PYTHON} -m pip install setuptools wheel packaging -exec --fail-on-error ${DIST_PYTHON} ${WORKSPACE}/../pyside-setup/setup.py install --qt 5.15.2 --qmake=D:/Qt/5.15.2/msvc2019_64/bin/qmake.exe --parallel=8 --relwithdebinfo --standalone --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,Widgets,Charts +exec --fail-on-error ${DIST_PYTHON} ${WORKSPACE}/pyside-setup/setup.py install --qt 5.15.2 --qmake=D:/Qt/5.15.2/msvc2019_64/bin/qmake.exe --parallel=8 --relwithdebinfo --standalone --no-examples --skip-docs --module-subset Core,Network,Gui,Qml,Widgets,Charts ''' [tasks.build-dist]