commit: ad167a488a979260256cb3513dbe7594b9276fc9 Author: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org> AuthorDate: Thu Oct 26 15:15:11 2023 +0000 Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org> CommitDate: Thu Oct 26 15:18:31 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ad167a48
dev-python/QtPy: properly handle implicit QT_API behaviour If a Qt4Python implementation has already been imported QtPy tries to use that implementation by default, even if this implementation is disabled by USE flag configuration. Here we add some extra sed's to remove the sys.modules check for implementations that we have disabled, taking care that the first entry in the if block always starts with if and not elif. Closes: https://bugs.gentoo.org/916298 Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org> .../{QtPy-2.4.1.ebuild => QtPy-2.4.1-r1.ebuild} | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/dev-python/QtPy/QtPy-2.4.1.ebuild b/dev-python/QtPy/QtPy-2.4.1-r1.ebuild similarity index 87% rename from dev-python/QtPy/QtPy-2.4.1.ebuild rename to dev-python/QtPy/QtPy-2.4.1-r1.ebuild index b36bfa5ce6fc..2d5fc3255ee9 100644 --- a/dev-python/QtPy/QtPy-2.4.1.ebuild +++ b/dev-python/QtPy/QtPy-2.4.1-r1.ebuild @@ -157,18 +157,45 @@ src_prepare() { sed -i -e 's:--cov=qtpy --cov-report=term-missing::' pytest.ini || die # Disable Qt for Python implementations that are not selected if ! use pyqt5; then - sed -i -e '/from PyQt5.QtCore import/,/)/c\ \ \ \ \ \ \ \ raise ImportError #/' qtpy/__init__.py || die - fi - if ! use pyqt6; then - sed -i -e '/from PyQt6.QtCore import/,/)/c\ \ \ \ \ \ \ \ raise ImportError #/' qtpy/__init__.py || die + sed \ + -e '/from PyQt5.QtCore import/,/)/c\ \ \ \ \ \ \ \ raise ImportError #/' \ + -e '/if "PyQt5" in sys.modules:/,/"pyqt5"/c\' \ + -i qtpy/__init__.py || die + + # We need to ensure the first option is an 'if' not 'elif' + sed -e 's/elif "PySide2" in sys.modules:/if "PySide2" in sys.modules:/g' -i qtpy/__init__.py || die fi if ! use pyside2; then - sed -i -e "s/from PySide2 import/raise ImportError #/" qtpy/__init__.py || die - sed -i -e "s/from PySide2.QtCore import/raise ImportError #/" qtpy/__init__.py || die + sed \ + -e "s/from PySide2 import/raise ImportError #/" \ + -e "s/from PySide2.QtCore import/raise ImportError #/" \ + -e '/if "PySide2" in sys.modules:/,/"pyside2"/c\' \ + -i qtpy/__init__.py || die + + if ! use pyqt5; then + sed \ + -e 's/elif "PyQt6" in sys.modules:/if "PyQt6" in sys.modules:/g' \ + -i qtpy/__init__.py || die + fi + fi + if ! use pyqt6; then + sed \ + -e '/from PyQt6.QtCore import/,/)/c\ \ \ \ \ \ \ \ raise ImportError #/' \ + -e '/if "PyQt6" in sys.modules:/,/"pyqt6"/c\' \ + -i qtpy/__init__.py || die + + if ! use pyqt5 && ! use pyside2; then + sed \ + -e 's/elif "PySide6" in sys.modules:/if "PySide6" in sys.modules:/g' \ + -i qtpy/__init__.py || die + fi fi if ! use pyside6; then - sed -i -e "s/from PySide6 import/raise ImportError #/" qtpy/__init__.py || die - sed -i -e "s/from PySide6.QtCore import/raise ImportError #/" qtpy/__init__.py || die + sed \ + -e "s/from PySide6 import/raise ImportError #/" \ + -e "s/from PySide6.QtCore import/raise ImportError #/" \ + -e '/if "PySide6" in sys.modules:/,/"pyside6"/c\' \ + -i qtpy/__init__.py || die fi }
