File tree 3 files changed +68
-0
lines changed
3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ Added a `print_debug_info ` function for bug reports.
Original file line number Diff line number Diff line change 37
37
# in case setuptools scm screw up and find version to be 0.0.0
38
38
assert not __version__ .startswith ("0.0.0" )
39
39
40
+
41
+ def print_debug_info () -> None :
42
+ """
43
+ Print version info for use in bug reports.
44
+ """
45
+ import platform
46
+ from importlib .metadata import version
47
+
48
+ def print_packages (packages : list [str ]) -> None :
49
+ not_installed = []
50
+ for package in packages :
51
+ try :
52
+ print (f"{ package } : { version (package )} " )
53
+ except ModuleNotFoundError :
54
+ not_installed .append (package )
55
+ if not_installed :
56
+ print ("\n **Not Installed:**" )
57
+ for package in not_installed :
58
+ print (package )
59
+
60
+ required = [
61
+ "packaging" ,
62
+ "numpy" ,
63
+ "numcodecs" ,
64
+ "typing_extensions" ,
65
+ "donfig" ,
66
+ ]
67
+ optional = [
68
+ "botocore" ,
69
+ "cupy-cuda12x" ,
70
+ "fsspec" ,
71
+ "numcodecs" ,
72
+ "s3fs" ,
73
+ "gcsfs" ,
74
+ "universal-pathlib" ,
75
+ "rich" ,
76
+ "obstore" ,
77
+ ]
78
+
79
+ print (f"platform: { platform .platform ()} " )
80
+ print (f"python: { platform .python_version ()} " )
81
+ print (f"zarr: { __version__ } \n " )
82
+ print ("**Required dependencies:**" )
83
+ print_packages (required )
84
+ print ("\n **Optional dependencies:**" )
85
+ print_packages (optional )
86
+
87
+
40
88
__all__ = [
41
89
"Array" ,
42
90
"AsyncArray" ,
67
115
"open_consolidated" ,
68
116
"open_group" ,
69
117
"open_like" ,
118
+ "print_debug_info" ,
70
119
"save" ,
71
120
"save_array" ,
72
121
"save_group" ,
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
1
3
import zarr
2
4
3
5
@@ -9,3 +11,19 @@ def test_exports() -> None:
9
11
10
12
for export in __all__ :
11
13
getattr (zarr , export )
14
+
15
+
16
+ def test_print_debug_info (capsys : pytest .CaptureFixture [str ]) -> None :
17
+ """
18
+ Ensure that print_debug_info does not raise an error
19
+ """
20
+ from importlib .metadata import version
21
+
22
+ from zarr import __version__ , print_debug_info
23
+
24
+ print_debug_info ()
25
+ captured = capsys .readouterr ()
26
+ # test that at least some of what we expect is
27
+ # printed out
28
+ assert f"zarr: { __version__ } " in captured .out
29
+ assert f"numpy: { version ('numpy' )} " in captured .out
You can’t perform that action at this time.
0 commit comments