Mercurial > jwe > octave
comparison scripts/miscellaneous/python.m @ 31144:22305b923761
doc: which Python executable and how to change it (bug #62733)
* python.m: Document difference between Unix and Windows. Fix whitespace.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Sat, 09 Jul 2022 22:05:40 -0700 |
parents | 0f4d16af143b |
children |
comparison
equal
deleted
inserted
replaced
31143:b3ca7f891750 | 31144:22305b923761 |
---|---|
31 ## arguments. | 31 ## arguments. |
32 ## | 32 ## |
33 ## Return output in @var{output} and optional status in @var{status}. If | 33 ## Return output in @var{output} and optional status in @var{status}. If |
34 ## @var{scriptfile} is not an absolute filename it is searched for in the | 34 ## @var{scriptfile} is not an absolute filename it is searched for in the |
35 ## current directory and then in the Octave loadpath. | 35 ## current directory and then in the Octave loadpath. |
36 ## | |
37 ## Programming Note: On UNIX systems, the script will be executed by | |
38 ## @command{python3} and on Windows by @command{python}. You can override | |
39 ## these defaults by setting the @env{PYTHON} environment variable, for example | |
40 ## from within Octave using @code{setenv PYTHON /usr/local/bin/python3}. | |
41 ## | |
36 ## @seealso{system, perl} | 42 ## @seealso{system, perl} |
37 ## @end deftypefn | 43 ## @end deftypefn |
38 | 44 |
39 function [output, status] = python (scriptfile, varargin) | 45 function [output, status] = python (scriptfile, varargin) |
40 | 46 |
59 [status, output] = system ([pyexec " " scriptfile, ... | 65 [status, output] = system ([pyexec " " scriptfile, ... |
60 sprintf(" %s", varargin{:})]); | 66 sprintf(" %s", varargin{:})]); |
61 | 67 |
62 endfunction | 68 endfunction |
63 | 69 |
64 function pyexec = get_python_executable () | 70 function pyexec = get_python_executable () |
65 | 71 |
66 pyexec = getenv ("PYTHON"); | 72 pyexec = getenv ("PYTHON"); |
67 if (isempty (pyexec)) | 73 if (isempty (pyexec)) |
68 ## PEP394 says Python 3 installs should all provide this command | 74 ## PEP394 says Python 3 installs should all provide this command |
69 pyexec = "python3"; | 75 pyexec = "python3"; |