Skip to content

PySide breaks labscript saving logic in compilationย #116

@dihm

Description

@dihm

In testing PySide6 support with labscript-suite/runmanager#118, discovered the PySide does some import shenanigans that breaks the compilation.

Compiling any script, you get a traceback like

Traceback (most recent call last):
  File "C:\Users\naqsL\labscript-suite\userlib\labscriptlib\tester\dg4000_test.py", line 42, in <module>
    stop(1.0)
  File "C:\Users\naqsL\src\labscript-suite\labscript\labscript\labscript.py", line 706, in stop
    generate_code()
  File "C:\Users\naqsL\src\labscript-suite\labscript\labscript\labscript.py", line 531, in generate_code
    save_labscripts(hdf5_file)
  File "C:\Users\naqsL\src\labscript-suite\labscript\labscript\labscript.py", line 418, in save_labscripts
    hdf5_file.create_dataset(save_path, data=open(path).read())
                                             ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\naqsL\\labscript-suite\\userlib\\labscriptlib\\tester\\signature_bootstrap.py'
Compilation aborted.

Of course, this file does not exist on disk. Doing some digging, it appears this is due to how PySide imports and generates its bindings at runtime. In particular, this and other files are imported directly from a zip archive into the CWD, with the files deleted after import finishes (but their sys.modules entries left as-is). This is a problem for the labscript compiler because it looks for the script(s) that generated the run by inspecting sys.modules for files in the CWD of the parent labscript file (in the labscript.save_labscripts function), which now contains a bunch of PySide ghost garbage.

A quick fix is to simply check if the module path includes signature_bootstrap.py or shibokensupport, but I worry that our import shenanigans (across the suite) are going to conflict/compound with the PySide import shenanigans in subtle and annoying ways. Will need to keep a close eye on that, and maybe think if there is some better way to isolate these behaviors from each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions