Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Define Qt/binding versions at top level, fix warnings if versions not found, and fix test dir on CIs #292

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ jobs:
COVERALLS_FLAG_NAME: ${{ matrix.os }} Python ${{ matrix.python-version }} conda=${{ matrix.use-conda }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd qtpy # Switch to test working dir per non-src-layout hack
cd temp_test_dir # Switch to test working dir per non-src-layout hack
cat qtpy_basedir.txt
pipx run coveralls --service=github --rcfile="../.coveragerc" --basedir="$(cat qtpy_basedir.txt)"
7 changes: 4 additions & 3 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ echo dist/*.whl | xargs -I % python -bb -X dev -W error -m pip install --upgrade
conda list

# Run tests
cd qtpy # Hack to work around non-src layout pulling in local instead of installed package for cov
python -I -bb -X dev -W error -m pytest --cov-config ../.coveragerc --cov-append
mkdir -p temp_test_dir
pushd temp_test_dir # Hack to work around non-src layout pulling in local instead of installed package for cov
python -I -bb -X dev -W error -m pytest ../qtpy --cov-config ../.coveragerc --cov-append

# Save QtPy base dir for coverage
python -c "from pathlib import Path; import qtpy; print(Path(qtpy.__file__).parent.parent.resolve().as_posix())" > qtpy_basedir.txt
cat qtpy_basedir.txt
cd ..
popd

# Check package and environment
pipx run twine check --strict dist/*
Expand Down
10 changes: 5 additions & 5 deletions qtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class PythonQtWarning(Warning):
PYQT5 = True
PYQT4 = PYQT6 = PYSIDE = PYSIDE2 = PYSIDE6 = False

PYQT_VERSION = None
PYSIDE_VERSION = None
QT_VERSION = None

# Unless `FORCE_QT_API` is set, use previously imported Qt Python bindings
if not os.environ.get('FORCE_QT_API'):
if 'PyQt6' in sys.modules:
Expand All @@ -120,7 +124,6 @@ class PythonQtWarning(Warning):
try:
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt5.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore
PYSIDE_VERSION = None

if sys.platform == 'darwin':
macos_version = parse(platform.mac_ver()[0])
Expand All @@ -145,7 +148,6 @@ class PythonQtWarning(Warning):
try:
from PyQt6.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
from PyQt6.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore
PYSIDE_VERSION = None
PYQT5 = False
PYQT6 = True
except ImportError:
Expand All @@ -157,7 +159,6 @@ class PythonQtWarning(Warning):
from PySide2 import __version__ as PYSIDE_VERSION # analysis:ignore
from PySide2.QtCore import __version__ as QT_VERSION # analysis:ignore

PYQT_VERSION = None
PYQT5 = False
PYSIDE2 = True

Expand All @@ -179,7 +180,6 @@ class PythonQtWarning(Warning):
from PySide6 import __version__ as PYSIDE_VERSION # analysis:ignore
from PySide6.QtCore import __version__ as QT_VERSION # analysis:ignore

PYQT_VERSION = None
PYQT5 = False
PYSIDE6 = True

Expand Down Expand Up @@ -215,7 +215,7 @@ def _warn_old_minor_version(name, old_version, min_version):


# Warn if using an End of Life, unsupported Qt API/binding
if parse(QT_VERSION) < parse(QT_VERSION_MIN):
if QT_VERSION and parse(QT_VERSION) < parse(QT_VERSION_MIN):
_warn_old_minor_version('Qt', QT_VERSION, QT_VERSION_MIN)
if PYQT_VERSION and parse(PYQT_VERSION) < parse(PYQT_VERSION_MIN):
_warn_old_minor_version('PyQt', PYQT_VERSION, PYQT_VERSION_MIN)
Expand Down