-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] "unauthorized use of script" when packing with pyinstaller and using private/restrict. #1676
Comments
PyInstaller loader is different from Python Interpreter, so the script executed by PyInstaller loader must be no restrict. Here is an example to show how to use Suppose the main script is import fib
def main():
print('Hello', fib.message)
if __name__ == '__main__':
main() The content of message = 'Fibo' Then it need create fake main script
Now generate executable
And pack the obfuscated script by
Test it
It has been tested in Linux and with PyInstaller 5.13.2 |
Thanks for directing me here and suggesting a workaround. If you replace the filenames fake_main, foo, fib with the filenames a, b, c, it appears to reproduce the problem. |
Thank you for the 8.4.7 release.
|
Got it, it seems I'll check it again |
Here is one solution by patching The idea is to make PyInstaller module loader like CPython interpreter In the traceback, there is a line
So edit # exec(bytecode, module.__dict__)
def _call_with_frames_removed():
exec(bytecode, module.__dict__)
_call_with_frames_removed() After that no
|
Thanks for the suggestion. No. 5 in the License section |
Based on your suggestion, I think I can work around it for the time being by dynamically rewriting the module so that it does not affect the license. Thanks for your help. fake_main.pyimport sys
if mod := sys.modules.get("pyimod02_importers"):
mod.exec = lambda *args, **kwargs: exec(*args, **kwargs)
from foo import main
main() |
This is temporary solution, if this patch works, in next release v8.5.0, it will be implemented in the pyarmor side, so need do nothing in PyInstaller. |
Fixed in v8.5.0 |
I have a project with two files:
a.py
:main.py
:My goal is to use
pyinstaller
to create a single binary I can distribute. I want to make sure user cannot decompile the binary and import packagea.py
. I buildmain.py
and itsa.py
dependency into a binary:I then try to
--pack
with the--private
:But I get this error when running the built binary.
I've also tried using both
--restrict
andrestrict_module=2
(as stated in #1274), but I get the same error.Is there any way to protect the packages with
pyarmor
when usingpyinstaller
? Otherwise, a user could decompile the binary and import my packages.The text was updated successfully, but these errors were encountered: