Skip to content

Commit

Permalink
Merge pull request bluesky#1512 from tacaswell/future_support
Browse files Browse the repository at this point in the history
Future support
  • Loading branch information
mrakitin committed May 23, 2022
2 parents c1c8ac0 + e53b065 commit 85c5d92
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
ophyd-version: ["master", "latest"]
fail-fast: false
steps:
Expand Down Expand Up @@ -43,6 +43,14 @@ jobs:
python -m pip install git+https://github.com/bluesky/ophyd.git@master
python -m pip list
- name: Install pyqt6 on some versions
if: ${{ matrix.python-version == '3.10' }}
shell: bash -l {0}
run: |
set -vxeuo pipefail
python -m pip install pyqt6
python -m pip list
- name: Ensure that callbacks import without matplotlib
shell: bash -l {0}
run: |
Expand Down
11 changes: 8 additions & 3 deletions bluesky/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ def get_file_list(self, datum_kwarg_gen):
def db(request):
"""Return a data broker
"""
from databroker import temp
db = temp()
return db
try:
from databroker import temp
db = temp()
return db
except ImportError:
pytest.skip("Databroker v2 still missing temp.")
except ValueError:
pytest.skip("Intake is failing for unknown reasons.")


@pytest.fixture(autouse=True)
Expand Down
45 changes: 41 additions & 4 deletions bluesky/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,39 @@ def block(self, blocking_event):
# if with a Qt backend, do the scary thing
if 'qt' in backend:

from matplotlib.backends.qt_compat import QtCore, QtWidgets
from matplotlib.backends.qt_compat import QtCore, QtWidgets, QT_API
import functools

@functools.lru_cache(None)
def _enum(name):
"""
Between PyQt5 and PyQt6 how the various enums were accessed changed from
all of the various names being in the module namespace to being nested under
the Enum name. Thus in PyQt5 we access the QSocketNotifier Type enum values as ::
QtCore.QSocketNotifier.Read
but in PyQt6 we use::
QtCore.QSocketNotifier.Type.Read
rather than have this checking inline where we use it, this function lets us do::
_enum('QtCore.QSocketNotifier.Type').Read
and well get the right namespace to get the Enum member from.
We use the extra layer of indirection of `operator.attrgetter` so that
multi-level names work and we can rely on the Qt compat layer to get the
correct PyQt5 vs PyQt6
This is copied from Matplotlib.
"""
# foo.bar.Enum.Entry (PyQt6) <=> foo.bar.Entry (non-PyQt6).
return operator.attrgetter(
name if QT_API == 'PyQt6' else name.rpartition(".")[0]
)(sys.modules[QtCore.__package__])

app = QtWidgets.QApplication.instance()
if app is None:
_qapp = app = QtWidgets.QApplication([b'bluesky'])
Expand Down Expand Up @@ -1584,8 +1616,10 @@ def exit_loop():
for fd in (rfd, wfd):
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
wakeupsn = QtCore.QSocketNotifier(rfd,
QtCore.QSocketNotifier.Read)
wakeupsn = QtCore.QSocketNotifier(
rfd,
_enum('QtCore.QSocketNotifier.Type').Read
)
origwakeupfd = signal.set_wakeup_fd(wfd)

def cleanup():
Expand Down Expand Up @@ -1648,7 +1682,10 @@ def my_exception_hook(exctype, value, traceback):

try:
sys.excepthook = my_exception_hook
event_loop.exec_()
(event_loop.exec()
if hasattr(event_loop, "exec")
else event_loop.exec_()
)
# make sure any pending signals are processed
event_loop.processEvents()
if vals[1] is not None:
Expand Down

0 comments on commit 85c5d92

Please sign in to comment.