File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 1
1
%% PYTHON_VERSION get the Python version used by MATLAB
2
2
%
3
- % uses persistent variable to cache the Python version
3
+ % uses persistent variable to cache the Python version.
4
+ % If the environment changes, the cached version will be invalid.
5
+ % this cache is cleared by "clear stdlib.python_version"
4
6
%
5
7
% %% Inputs
6
8
% * force_old: (optional) boolean flag to force checking of Python on Matlab < R2022a
17
19
force_old = false ;
18
20
end
19
21
20
- persistent stdlib_py_version
22
+ persistent stdlib_py_version pyv_cached
23
+
24
+ if ~isempty(pyv_cached )
25
+ pyv_cached = false ;
26
+ end
21
27
22
28
msg = ' ' ;
23
29
24
- if ~isempty( stdlib_py_version )
30
+ if pyv_cached
25
31
v = stdlib_py_version ;
26
32
return
27
33
end
43
49
msg = e .message ;
44
50
end
45
51
46
- % cache the result
47
- if ~isempty(v )
48
- stdlib_py_version = v ;
49
- end
52
+ % cache the result - even if empty -- because the check takes up to 1000 ms say on HPC
53
+ stdlib_py_version = v ;
54
+ pyv_cached = true ;
50
55
51
56
end
You can’t perform that action at this time.
0 commit comments