File tree Expand file tree Collapse file tree 2 files changed +26
-19
lines changed
labscript_utils/device_registry Expand file tree Collapse file tree 2 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 1- try :
2- import importlib .metadata as importlib_metadata
3- except ImportError :
4- import importlib_metadata
5- import packaging .version
1+ from ._device_registry import *
62
7- use_local_machinery = True
3+ # Backwards compatibility for labscript-devices < 3.1. If labscript_devices defines the
4+ # device registry as well, undo the above import and use the contents of
5+ # labscript_devices instead. The above import must be done first so that the names are
6+ # available to labscript_devices during the below import, since as of 3.1 it imports
7+ # this module as well.
88try :
9- labscript_device_version_str = importlib_metadata .version ('labscript_devices' )
10- labscript_devices_version = packaging .version .parse (labscript_device_version_str )
11- use_local_machinery = labscript_devices_version >= packaging .version .parse ('3.1.0.dev16' )
12- except importlib_metadata .PackageNotFoundError :
9+ from labscript_devices import ClassRegister
10+ if ClassRegister .__module__ == 'labscript_devices' :
11+ for name in _device_registry .__all__ :
12+ del globals ()[name ]
13+ from labscript_devices import *
14+ except ImportError :
1315 pass
14-
15- # import and use the labscript_devices code if an old version of the package is used.
16- # This ensures that new labscript_utils with old labscript_devices doesn't attempt to
17- # register labscript_devices classes twice
18- if not use_local_machinery :
19- from labscript_devices import *
20- else :
21- from ._device_registry import *
Original file line number Diff line number Diff line change 11import os
2- import sys
32import importlib
43import imp
54import warnings
@@ -45,6 +44,20 @@ class belong to each device. Tab and parser classes must be passed to register_c
4544"""
4645
4746
47+ __all__ = [
48+ 'LABSCRIPT_DEVICES_DIRS' ,
49+ 'labscript_device' ,
50+ 'BLACS_worker' ,
51+ 'BLACS_tab' ,
52+ 'runviewer_parser' ,
53+ 'import_class_by_fullname' ,
54+ 'deprecated_import_alias' ,
55+ 'get_BLACS_tab' ,
56+ 'get_runviewer_parser' ,
57+ 'register_classes' ,
58+ ]
59+
60+
4861def _get_import_paths (import_names ):
4962 """For the given list of packages, return all folders containing their submodules.
5063 If the packages do not exist, ignore them."""
You can’t perform that action at this time.
0 commit comments