Add QGIS 4.0, Qt6, and Python 3.14 compatibility enhancements while keeping backwards compatibility#4
Open
celray wants to merge 4 commits intoswat-model:masterfrom
Open
Add QGIS 4.0, Qt6, and Python 3.14 compatibility enhancements while keeping backwards compatibility#4celray wants to merge 4 commits intoswat-model:masterfrom
celray wants to merge 4 commits intoswat-model:masterfrom
Conversation
- Add qt_compat.py shim for Qt5/Qt6 enum differences - Replace all exec_() calls with exec() (35 instances) - Replace direct PyQt5 imports with qgis.PyQt wrapper - Patch Qt5 short-name enums for auto-generated ui_*.py files - Add fv() helper for NULL feature attributes (None in Qt6 vs QPyNullVariant in Qt5) - Fix QMetaType enum values in parameters.py - Separate dataInC Cython imports to prevent cascade failures - Add metadata.txt and fix __init__.py import path - Update make_uis.py to try PyQt6 first - Fix missing logFile parameter in getLayerByFilenameOrLegend
Add compile_pyx() helper to qt_compat.py that invokes Cython/setuptools to build a .pyx file for the running Python version. All dataInC, polygonizeInC2, and jenks imports now fall back to auto-compilation when the pre-built .so does not match the current Python. Requires Cython, setuptools, numpy, and a C compiler at runtime.
QGIS 4.0 on Windows does not ship rtree, and it is not used anywhere in the codebase — only imported but never referenced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements to how the code handles data type conversions and imports, particularly for compatibility with different Python environments and to ensure robust handling of Cython-compiled modules. The most significant changes include the introduction of a new utility function
fvfor safe value conversion, refactoring of import logic for Cython modules, and replacement of direct Qt enum and constant references with imports from a compatibility layer.Compatibility and Import Handling Improvements:
dataInC) in bothDBUtils.pyandQSWATTopology.py, including dynamic compilation if necessary, to improve cross-environment compatibility.Data Conversion and Type Safety:
Introduced and consistently used the
fvutility function for extracting and converting feature attribute values, replacing direct usage of raw values to prevent type errors and improve code robustness. This change affects multiple locations in bothDBUtils.pyandQSWATTopology.py, especially where numeric computations are performed on feature attributes.UI and User Interaction Updates:
Replaced direct usage of Qt cursor and dialog result enums in
QSWATPlusMain.pywith imports fromqt_compat, improving abstraction and compatibility for both QGIS 3.XX and QGIS 4.XX.Sorting and List Handling:
AscendingOrderconstant instead ofQt.AscendingOrder.