There is a comprehensive tutorial for here, but is intended for Windows users.
I didn’t see any Linux related tutorial for Flatpack users and the way to debug scripts using this distribution is way different.
So this is a tutorial for those like me that wanted to debug Siril -Flatpack- in Linux.
[Prerequisites]
- Siril 1.4 or above
- I’m using VSC to debug so Python extension and Debugger are required
[Setting up]
- Install debugpy in the system
python3 -m pip install --user --break-system-packages debugpy
- From VSC open the folder where the script to debug is and the select the desired script
- Append the following code at the beginning of the script, before any other import statement, but after any from XXXX import stament
import os
os.environ["PYDEVD_DISABLE_FILE_VALIDATION"] = "1"
import sys
sys.path.append("/home/USER_NAME/.local/lib/python3.XX/site-packages")
import debugpy
debugpy.listen(("0.0.0.0", 5678))
print("Waiting for debugger...")
debugpy.wait_for_client()
print("Debugger attached, running script…")
Replace USER_NAME and python3.XX as required
- Add debug configuration: From the menu Run > Add configuration > Python debugger > Remote Attach: Attach to a remote debug server. Set localhost as host IP and 5678 as port
- The following code will be created and stored in launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Siril (debugpy)",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"justMyCode": false
}
]
}
- Append the justMyCode key if planning to break into sirilpy
[Debugging]
- In Siril open the Script menu -no need to enable Python debug mode- and run the script. In the console you’ll see a Waiting for debugger… message
- In VSC set a breakpoint at any line in the code and press F5 to run the script. It’ll automatically attach to the running script in Siril and a new message will show up in the console: Debugger attached, running script…
You can now debug the script as usual