pyarmor
pyarmor copied to clipboard
[BUG] `RuntimeError: unauthorized use of script (1:1102)`
I am obfuscating my code with Pyarmor first, and then trying to Cythonize it to .so file.
I am Pyarmoring the code with the following command:
pyarmor gen -O dist2 src/* --enable-jit --mix-str --obf-code 2 --assert-call --private
These are the files that get Pyarmored:
src/
main.py
pw/
utils.py
interface.py
core.py
infer.py
after which, I am able to run my script by calling python3 main.py
I then Cythonize my code with the following:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("pw.utils", ["pw/utils.py"]),
Extension("pw.core", ["pw/core.py"]),
Extension("pw.infer", ["pw/infer.py"]),
Extension("pw.interface", ["pw/interface.py"])#,
]
for e in ext_modules:
e.cython_directives = {'language_level': "3"}
setup(
name = 'PrintWatch',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
After which, the code will not run when I call python3 main.py:
File "<frozen __main__>", line 4, in <module>
File "<frozen main>", line 2, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1116, in exec_module
File "<frozen pw.core>", line 228, in _call_with_frames_removed
File "pw/core.py", line 3, in init pw.core
RuntimeError: unauthorized use of script (1:1102)