I have a plugin that I created in python. To install it I do pip install my_plugin
And then I have another plugin that uses my_plugin as a base.
So I do pip install -e other_plugin
Now I'm able to debug into other_plugin in VSCode.
My launch.json looks like this:
{
"name": "Python : Active File",
"type": "python",
"request": "launch",
"program": "./my_plugin/host.py",
"console": "integratedTerminal",
"justMyCode": true
}
Now I want my_plugin's code to be totally invisible to the customer. So I made a package of it using pyinstaller. What do i change in the launch.json so that my customer can create his own plugin that will use my_plugin as a base.
I've tried
{
"name": "Python : Active File",
"type": "python",
"request": "launch",
"program": "./dist/my_plugin", <-- exe of my_plugin
"console": "integratedTerminal",
"justMyCode": true
}
but i get ValueError: source code string cannot contain null bytes
What do I need to do so that my customer can debug his own plugin?
When you use PyInstaller to package Python code into an executable, the resulting executable is not a Python script and cannot be run or debugged using the Python debugger. The executable contains a bundled Python interpreter and Python code, but they are both compiled to machine code.
If you want your customers to be able to debug their own plugins, which are based on yours, you have a few options, although these methods can't guarantee that your source code is completely secure:
Provide a debug version of your plugin: This will be the plugin version that is not packaged into the executable. Customers can use this version for debugging and the packaged version for production.
Use a different method of hiding your source code: PyInstaller isn't the only way to hide your Python source code. Other methods include obfuscation, in which the code is modified to be more difficult to understand, and encryption, in which the code is encrypted and decrypted only at runtime. These methods may be more complex to implement and may not provide as much protection as packaging code into an executable.