Make pyarmor work with zipapp #1510
EmberLightVFX
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Refer to |
Beta Was this translation helpful? Give feedback.
1 reply
-
If auto filter doesn't work, try to search |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a module that I would need to package down into one single file. Using zipapp would be the best solution but zipapp doesn't work with .pyd files. Shiv and equal doesn't work as those can't be loaded as modules. zipapps can.
My idea is to modify the
__init__.py
file in thepyarmor_runtime_006099
folder so the file itself includes the binaries (converted to base64) of the original__init__.py
andpyarmor_runtime.pyd
. When init.py gets execited it will create the init and runtime files in a temp-folder, add the temp-folder to sys usingsys.path.append(temp_dir)
and the import it like thisfrom pyarmor_runtime_006099 import __pyarmor__
The system works in my tests with the built pyarmor files (with modified init.py) but if I obfuscate the code with
--assert-call
or--assert-import
I get an protection exception after packing in into a zipapp.So my feature request would be to be able to pack the obfuscation into a zipapp with
--assert-call
and--assert-import
applied but ignored for the init.py file so it can genenrate the needed .pyd file and import it outside the zipapp.I'm attaching my test-project here so you can try it out yourself. These are the steps needed:
build_pyarmor.py
to generate the needed pyarmor codegenerate_init.py
and select./build/aesl/pyarmor_runtime_006099/__init__.py
orpyarmor_runtime.pyd
The script will fetch them both, take the content of
__init__template.py
, replace the needed parts and overwrite the old init.py file.build_zipapp.py
to generate the zipapp../dist
you should now havedemo.py
andaesl.pyz
. Run demo.py to test it out.build
and run it.test.zip
Beta Was this translation helpful? Give feedback.
All reactions