summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Ammerlaan <andrewammerlaan@gentoo.org>2023-10-26 17:15:11 +0200
committerAndrew Ammerlaan <andrewammerlaan@gentoo.org>2023-10-26 17:18:31 +0200
commitad167a488a979260256cb3513dbe7594b9276fc9 (patch)
treea11c47c9cf37cb708e1f32e8330cc5a1f975c806
parentgnome-extra/gnome-shell-frippery: Version bump to 45.0 (diff)
downloadgentoo-ad167a488a979260256cb3513dbe7594b9276fc9.tar.gz
gentoo-ad167a488a979260256cb3513dbe7594b9276fc9.tar.bz2
gentoo-ad167a488a979260256cb3513dbe7594b9276fc9.zip
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@gentoo.org>
-rw-r--r--dev-python/QtPy/QtPy-2.4.1-r1.ebuild (renamed from dev-python/QtPy/QtPy-2.4.1.ebuild)43
1 files 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
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
}