Skip to content

Executable version on Windows #412

@gustaphe

Description

@gustaphe

It appears _get_version() does not get specialized for either matlab nor python on Windows. I suspect that this is because .exe is automatically tacked on the executable name, and then the lookup does not recognize it. The generic handler will not work for either program.

I am also not sure that Matlab specifically will print the message to the commandline, it would be better and faster to search the output of matlab -h for version_pattern_matlab = re.compile(r'(?<=Version: )(?P<version>\d.+)\b').

In a somewhat less relevant issue, SIGALRM is OS specific and not defined on Windows, but I guess it's supposed to crash anyway so it doesn't matter.

Error message

smt run -e matlab -m .\test.m parameters.m

Using C:\Program Files\MATLAB\R2025a\bin\matlab.exe
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Scripts\smt.exe\__main__.py", line 7, in <module>
    sys.exit(smt())
             ~~~^^
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\cli\smt.py", line 32, in smt
    main(sys.argv[2:])
    ~~~~^^^^^^^^^^^^^^
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\commands.py", line 411, in run
    executable = get_executable(path=executable_path)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\programs.py", line 228, in get_executable
    program = Executable(path)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\programs.py", line 77, in __init__
    self.version = version or self._get_version()
                              ~~~~~~~~~~~~~~~~~^^
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\programs.py", line 104, in _get_version
    returncode, output, err = run("%s --version" % self.path,
                              ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                  shell=True, timeout=5)
                                  ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\sumatra\core.py", line 69, in run
    signal.signal(signal.SIGALRM, alarm_handler)
                  ^^^^^^^^^^^^^^
AttributeError: module 'signal' has no attribute 'SIGALRM'. Did you mean: 'SIGABRT'?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions