Skip to content

Commit

Permalink
PySide6 Port #628 + Cleanup [CPP-794] (#667)
Browse files Browse the repository at this point in the history
Co-authored-by: Keith Kyzivat <[email protected]>
Co-authored-by: [email protected] <jm>
  • Loading branch information
john-michaelburke and keithel-qt authored Aug 30, 2022
1 parent 1c48f20 commit dd4c4cc
Show file tree
Hide file tree
Showing 127 changed files with 1,106 additions and 1,522 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
"console_backend/tests/data/*" filter=lfs diff=lfs merge=lfs -text
"pyside-wheels/*.whl" filter=lfs diff=lfs merge=lfs -text
installers/Windows/NSIS/*.zip filter=lfs diff=lfs merge=lfs -text
27 changes: 20 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
strategy:
matrix:
os:
- ubuntu-18.04
- macos-10.15
- ubuntu-20.04
- macos-11
- windows-2019

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -92,6 +92,7 @@ jobs:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pyproject-toml-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}


- name: Install ImageMagick
shell: bash
run: |
Expand Down Expand Up @@ -120,10 +121,9 @@ jobs:

name: Code Quality Checks

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:

- name: Checkout source
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -176,10 +176,22 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Qt
uses: jurplel/install-qt-action@910f37ee23653fd4b243fe5c7f81ff26a8a6a64e
with:
version: '6.3.1'
setup-python: false

- name: Run Checks
run: |
cargo make check-all
# TODO Fix qmllint warnings [CPP-798]
- name: Run qmllint
continue-on-error: true
run: |
cargo make qml-lint
- name: Run Tests
uses: nick-invision/retry@v2
with:
Expand All @@ -199,8 +211,8 @@ jobs:
strategy:
matrix:
os:
- {name: ubuntu-18.04, exe_suffix: "", short_name: "linux"}
- {name: macos-10.15, exe_suffix: "", short_name: "macos"}
- {name: ubuntu-20.04, exe_suffix: "", short_name: "linux"}
- {name: macos-11, exe_suffix: "", short_name: "macos"}
- {name: windows-2019, exe_suffix: ".exe", short_name: "windows"}

runs-on: ${{ matrix.os.name }}
Expand Down Expand Up @@ -406,6 +418,7 @@ jobs:
env:
OS_NAME: ${{ runner.os }}
shell: bash
continue-on-error: true
run: |
cargo make disk-usage-bench
Expand Down Expand Up @@ -472,7 +485,7 @@ jobs:
"$f"
done
for f in $(ls Contents/Resources/lib/python3.9/site-packages/**/Qt/lib/*.framework/Versions/5/*)
for f in $(ls -d Contents/Resources/lib/python3.9/site-packages/**/Qt/lib/*.framework/Versions/A/*)
do
codesign -vvvv \
-s "${{ secrets.APPLE_DEVELOPER_ID }}" \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ installers/Windows/*.exe
installers/Linux/*.deb
installers/Windows/NSIS/*
!installers/Windows/NSIS/*.zip
/.qt_for_python
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "swiftnav_console.main",
"stopOnEntry": false,
"sourceLanguages": [
"rust",
"python",
"c++"
],
"preLaunchTask": "prepare-run"
}
]
}
77 changes: 48 additions & 29 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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 PYSIDE2_RCC "${WORKSPACE}\\py39\\Lib\\site-packages\\PySide2\\rcc.exe"
set_env PYSIDE2_RCC "${WORKSPACE}\\py39\\Lib\\site-packages\\PySide6\\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"
set_env PYO3_CONFIG_FILE "${WORKSPACE}\\standalone-py\\pyo3_config.txt"
Expand All @@ -17,7 +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 PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc"
set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside6-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"
set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt"
Expand All @@ -28,7 +28,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 PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc"
set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside6-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"
set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt"
Expand Down Expand Up @@ -286,17 +286,7 @@ script_runner = "@duckscript"
script = '''
wget -O py39.tar.zst ${STANDALONE_PY_URL}
exec --fail-on-error zstd -f -d py39.tar.zst
exec --fail-on-error tar -xvf py39.tar
'''

[tasks.install-pyside-wheels]
env = { USE_PYTHON = { value = "${PYTHON}", condition = { env_not_set = [
"USE_PYTHON",
] } }, OS_WHEEL_LABEL = { source = "${OS}", default_value = "unknown", mapping = { "linux" = "abi3-manylinux1_x86_64", "mac" = "abi3-macosx_10_13_intel", "windows" = "none-win_amd64" } } }
script_runner = "@duckscript"
script = '''
exec --fail-on-error ${USE_PYTHON} -m pip install pyside-wheels/shiboken2-5.15.2.2-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-${OS_WHEEL_LABEL}.whl
exec --fail-on-error ${USE_PYTHON} -m pip install pyside-wheels/PySide2-5.15.2.2-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-${OS_WHEEL_LABEL}.whl
exec --fail-on-error tar -xf py39.tar
'''

[tasks.setup-builder]
Expand All @@ -312,7 +302,6 @@ cp . ../../../py39
cd ../../../
exec --fail-on-error ${PYTHON} ./get-pip.py
exec --fail-on-error ${PYTHON} -m pip install wheel flit . ".[test]"
cm_run_task install-pyside-wheels
cm_run_task generate-resources
'''

Expand Down Expand Up @@ -438,7 +427,6 @@ dependencies = ["build-frontend-wheel"]
script_runner = "@duckscript"
script = '''
exec --fail-on-error ${DIST_PYTHON} -m pip install ./dist/swiftnav_console-0.1.0-py3-none-any.whl --force-reinstall
cm_run_task install-pyside-wheels
'''

[tasks.build-dist-install-backend-wheel]
Expand Down Expand Up @@ -475,8 +463,8 @@ env = { PYTHONDONTWRITEBYTECODE = "1" }
cwd = "py39-dist"
script_runner = "@duckscript"
script = '''
py_folders = array test tests examples __pycache__ demos turtledemo translations idlelib lib/tcl8 lib/tcl8.6 lib/tk8.6 shiboken2/docs ensurepip lib2to3 tkinter unittest include
qt_folders = array plugins/geoservices plugins/virtualkeyboard plugins/sqldrivers lib/Tix8.4.3 tcl/tix8.4.3 Qt/resources PySide2/resources
py_folders = array test tests examples __pycache__ demos turtledemo translations idlelib lib/tcl8 lib/tcl8.6 lib/tk8.6 shiboken6/docs ensurepip lib2to3 tkinter unittest include
qt_folders = array plugins/geoservices plugins/virtualkeyboard plugins/sqldrivers lib/Tix8.4.3 tcl/tix8.4.3 Qt/resources PySide6/resources
qml_folders = array qml/QtWeb* qml/QtBluetooth* qml/QtNfc* qml/QtGamepad qml/QtTest qml/QtQuick3D qml/Qt3D qml/QtSensors qml/QtLocation qml/QtPositioning
all_folders = array_concat ${py_folders} ${qt_folders} ${qml_folders}
Expand All @@ -503,7 +491,9 @@ for ext in ${file_exts}
end
end
libs = array QtSensors QtLocation Qt5Location QtPositioning Qt3D Qt53D Qt5Nfc Qt5Web QtWeb Qt5Pdf Qt5Designer Qt5DesignerComponents Qt5VirtualKeyboard Qt5Bluetooth Qt5Quick3D
libs_a = array Qt3D QtBluetooth QtCconcurrent QtDataVisualization QtDesigner QtHelp QtMultimedia QtNfs QtPositioning
libs_b = array QtQuick3D QtRemoteObjects QtScxml QtSensors QtSerialPort QtSql QtStateMachine QtTest QtUiTools QtWeb QtXml
libs = array_concat ${libs_a} ${libs_b}
for lib in ${libs}
files = glob_array ./**/*${lib}*
Expand All @@ -529,7 +519,7 @@ if eq ${os} windows
end
end
qtbins = glob_array ./Lib/site-packages/PySide2/*.exe
qtbins = glob_array ./Lib/site-packages/PySide6/*.exe
for bin in ${qtbins}
rm ${bin}
end
Expand All @@ -544,12 +534,36 @@ if eq ${os} windows
end
end
end
elseif eq ${os} mac
rm -r ./share
rm -r ./lib/python3.9/site-packages/PySide6/Qt/libexec
bins = array qmllint lupdate lrelease scripts
for bin in ${bins}
files = glob_array ./lib/python3.9/site-packages/PySide6/${bin}
for bin in ${files}
rm -r ${bin}
end
end
# The Mac signing process needed to be fine tuned. There were a bunch of variations in the paths
# that we purge or sign which needed fixing. Also there were quite a few "Resources" folders buried
# within all of the PySide6 .framework files that were causing issues with the signing. I'm not sure
# if it was simply due to the folder named "Resources" or that each folder contained an Info.plist file.
# That being said after deleting them the app runs fine and passes the mac signing gauntlet.
# See: https://stackoverflow.com/a/29271922/12265938
resources_a = glob_array ./lib/python3.9/site-packages/PySide6/Qt/lib/*.framework/Versions/A/Resources
resources_b = glob_array ./lib/python3.9/site-packages/PySide6/Qt/lib/*.framework/Resources
resources = array_concat ${resources_a} ${resources_b}
for dir in ${resources}
rm -r ${dir}
end
else
rm -r ./share
bins = array rcc uic designer pyside2-lupdate Designer.app
bins = array rcc uic designer pyside6-lupdate Designer.app
for bin in ${bins}
files = glob_array ./**/PySide2/${bin}
files = glob_array ./**/PySide6/${bin}
for bin in ${files}
rm -r ${bin}
end
Expand Down Expand Up @@ -582,7 +596,9 @@ else
endif
if eq ${os} mac
rm -r lib/python3.9/site-packages/PySide2/Designer.app/
rm -r lib/python3.9/site-packages/PySide6/Designer.app/
rm -r lib/python3.9/site-packages/PySide6/Assistant.app/
rm -r lib/python3.9/site-packages/PySide6/Linguist.app/
rm lib/python3.9/lib-dynload/_testcapi.cpython-39-darwin.so
rm lib/python3.9/lib-dynload/xxlimited.cpython-39-darwin.so
Expand All @@ -593,7 +609,7 @@ if eq ${os} mac
rm -r lib/thread2.8.5/
endif
py_internal_libs = array Lib/email Lib/distutils Lib/http Lib/multiprocessing Lib/msilib Lib/http Lib/dbm Lib/curses Lib/xml Lib/xmlrpc Lib/urllib Lib/ensurepip Lib/venv Lib/wsgiref Lib/lib2to3
py_internal_libs = array Lib/email Lib/distutils Lib/http Lib/multiprocessing Lib/msilib Lib/http Lib/dbm Lib/curses Lib/xml Lib/xmlrpc Lib/ensurepip Lib/venv Lib/wsgiref Lib/lib2to3
for name in ${py_internal_libs}
folders = glob_array **/${name}/
Expand Down Expand Up @@ -846,34 +862,36 @@ script = '''
makensis /V4 .\installers\Windows\Installer.nsi
'''

# TODO Fix tool location when available in PySide6 wheels[CPP-799]
[tasks.qml-format]
dependencies = ["set-qml-files", "set-qml-app"]
script_runner = "@shell"
script = '''
${QT_APP}/Qt/bin/qmlformat -i ${QML_FILES}
qmlformat -i ${QML_FILES}
'''

# TODO Fix tool location when available in PySide6 wheels[CPP-799]
[tasks.qml-format.windows]
dependencies = ["set-qml-files", "set-qml-app"]
script_runner = "powershell"
script_extension = "ps1"
script = '''
& ${env:QT_APP}\Qt\bin\qmlformat -i $(-split ${env:QML_FILES})
& qmlformat -i $(-split ${env:QML_FILES})
'''

[tasks.qml-lint]
dependencies = ["set-qml-files", "set-qml-app"]
script_runner = "@shell"
script = '''
${QT_APP}/Qt/bin/qmllint -I ${QT_APP}/../PySide2/Qt/qml/ -I resources/ ${QML_FILES}
${QT_APP}/qmllint -I ${QT_APP}/../PySide6/Qt/qml/ -I resources/ ${QML_FILES}
'''

[tasks.qml-lint.windows]
dependencies = ["set-qml-files", "set-qml-app"]
script_runner = "powershell"
script_extension = "ps1"
script = '''
& ${env:QT_APP}\Qt\bin\qmllint -I ${env:QT_APP}\..\PySide2\Qt\qml -I resources $(-split ${env:QML_FILES})
& ${env:QT_APP}\qmllint -I ${env:QT_APP}\..\PySide6\Qt\qml -I resources $(-split ${env:QML_FILES})
'''

[tasks.qml-format-check]
Expand Down Expand Up @@ -990,8 +1008,9 @@ dependencies = [
]
run_task = "check-git-diff"

# TODO Fix qmllint warnings then add qml-lint back to lint task.[CPP-798]
[tasks.lint]
dependencies = ["qml-lint", "python-lint", "rust-lint", "format-check"]
dependencies = ["python-lint", "rust-lint", "format-check"]

[tasks.types]
dependencies = ["python-type-check", "rust-type-check"]
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MASTER]
jobs=0
extension-pkg-whitelist=PySide2
extension-pkg-whitelist=PySide6

[MESSAGES CONTROL]
# Disable undesired lints here (https://stackoverflow.com/a/4341833/749342)
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ readme = "README.md"
classifiers = []
requires-python = ">=3.8"
dynamic = ['version', 'description']
dependencies = ["pycapnp == 1.1.0"]
dependencies = ["PySide6 == 6.3.1", "pycapnp == 1.1.0"]

[project.optional-dependencies]
test = [
Expand All @@ -16,7 +16,6 @@ test = [
"pytest ~= 6.2.4",
"setuptools-rust ~= 0.12.1",
"psutil ~= 5.8.0",
"qt5-applications ~= 5.15.2",
"py2many >=0.3",
"types-requests ~= 2.25.0",
]
Expand Down

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions pyside-wheels/PySide2-5.15.2.1-5.15.2-cp39-cp39-win_amd64.whl

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit dd4c4cc

Please sign in to comment.