QT error when compiling my klayout based python script into binary

edited September 10 in Python scripting

I have built a windows GUI executable based on the python scripts that I wrote.
These scripts use klayout python library (pya).
Some of my python scripts requires klayout exe to be run, because I need klayout to be able to run functions like

   ##This is my py_script
    app = pya.Application.instance()
    mw = app.main_window()

To be able to run a python script like above I use os.system function
os.system(f'{klayout_exe_path} -r \"{py_script_path}\" -rd script_input1=\"{csv_path}\" -rd script_input2=\"{layout_path}\")

However when my application tries to open the klayout.exe and tries to run the above command I am getting the error in the screenshot below.

This error happens if klayout executable is above version 0.25.xxx. It doesn't happen with the older versions of klayout (i.e. 0.25.3)

I think the problem is due to the compilation process. I use pyinstaller to compile my application into binary. I know this, because this problem doesn't occur when I run this command

f'{klayout_exe_path} -r \"{py_script_path}\" -rd script_input1=\"{csv_path}\" -rd script_input2=\"{layout_path}\"

directly from the source code (instead of the from the binary). I believe I can't properly add some of the dependencies during compilation. However I don't know which ones are missing and how I can properly add those dependencies into my binary.

I use the following command to compile my python application into windows executable (binary)

pyinstaller --onefile --add-binary C:\ProgramData\anaconda3\envs\pycharm_project\Lib\site-packages\rtree\lib\spatialindex_c-64.dll;db_plugins --add-binary C:\ProgramData\anaconda3\envs\pycharm_project\Lib\site-packages\klayout\db_plugins\*.dll;db_plugins --add-binary C:\ProgramData\anaconda3\envs\pycharm_project\Lib\site-packages\rtree\lib\spatialindex_c-64.dll;db_plugins --add-binary C:\ProgramData\anaconda3\envs\pycharm_project\Lib\site-packages\klayout\*.dll;db_plugins main.spec

I attached main.spec file to the post (just remove the .txt extension - I had to add .txt to be able to upload it to the post)

Can someone understand what is going wrong in the compilation process and does anyone have suggestion?

Thanks for the help!
Regards,
Ege

Comments

  • Hi @Ege_Bey,

    I think that is an effect of a Qt version upgrade in the KLayout Windows package. It probably needs some more DLLs - probably the ones in "platforms". You may also want to include "cert.pem" and the files from "iconengines" and "imageformats". These are all Qt ingredients.

    Packaging Windows applications is a pain.

    Matthias

Sign In or Register to comment.