Replies: 32 comments 2 replies
-
Our current usage is like
Will the below achieve an identical obfuscation as before we |
Beta Was this translation helpful? Give feedback.
-
There is no identical pack in Pyarmor 8.0. Pyarmor 8.0 only provide repack function to handle bundle of PyInstaller. |
Beta Was this translation helpful? Give feedback.
-
@jondy , I tried this suggestion, but got the following error,
pyinstaller==5.9.0 |
Beta Was this translation helpful? Give feedback.
-
Just a heads up @jondy , |
Beta Was this translation helpful? Give feedback.
-
But you can't install pyinstaller==5.2.0 with py311 because
Interestingly though, this code still runs though, logging bug maybe?
|
Beta Was this translation helpful? Give feedback.
-
@SamComber thank you very much. What's the content of |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Got it, thanks |
Beta Was this translation helpful? Give feedback.
-
Hey @jondy, will we be able to use a patched version for this |
Beta Was this translation helpful? Give feedback.
-
I have checked this line, but did not find the problem. Do you run |
Beta Was this translation helpful? Give feedback.
-
No, I just run it on the output from
i.e. My folder tree is like
|
Beta Was this translation helpful? Give feedback.
-
Changing my script a bit, getting a different bug now
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks @jondy, this error has disappeared now 👍 !!!! I just have one question, are we supposed to use the patched bundle or are we supposed to use the output folder from I can see from the logs
And if I try to run Does this mean the packaged bundle |
Beta Was this translation helpful? Give feedback.
-
And just a heads up, when I attempted a more non-trivial example, I got this error after running
Is it looking in the wrong place? I can see the correct .so inside
|
Beta Was this translation helpful? Give feedback.
-
PyInstaller will extract bundle to random temporary folder, here it is I'll check this today. |
Beta Was this translation helpful? Give feedback.
-
@SamComber I test So could you test it with pyinstaller |
Beta Was this translation helpful? Give feedback.
-
I'm using a .spec file, and the pyinstaller bundle works without obfuscation with Can you reproduce with the issue with this small example @jondy ?
And then test commands
Where I get this error Python 3.11, pyarmor 8.0.20, pyinstaller 5.6.2 |
Beta Was this translation helpful? Give feedback.
-
Could you check the dependency of pyarmor_runtime.so?
And for a test with
|
Beta Was this translation helpful? Give feedback.
-
There is no dist/test/pyarmor_runtime_xxxxxx/pyarmor_runtime.so existing actually ! I can only find it at a directory level above -
But
I cannot use --onefile option because I have hidden imports that I need to declare inside my .spec file @jondy. .spec files cannot be used with --onefile or --onedir flags unfortunately |
Beta Was this translation helpful? Give feedback.
-
Hey @jondy, are you able to reproduce this error locally with For production use case pyinstaller --onefile isn't usually enough.. for any non-trivial use you would typically create a .spec file to define your bundled executable so it would be really nice if we could find a solution here |
Beta Was this translation helpful? Give feedback.
-
@SamComber I have not reproduced it. But I think I find the problem, because It will be fixed in next release. |
Beta Was this translation helpful? Give feedback.
-
You can try this method to pack the scripts, actually this is what old Pyarmor pack does. Please replace
a = Analysis(....)
# Patched by PyArmor
_src = r'/Users/jondy/workspace/pyarmor/test'
_obf = r'/Users/jondy/workspace/pyarmor/test/dist/obf'
_count = 0
for i in range(len(a.scripts)):
if a.scripts[i][1].startswith(_src):
x = a.scripts[i][1].replace(_src, _obf)
if os.path.exists(x):
a.scripts[i] = a.scripts[i][0], x, a.scripts[i][2]
_count += 1
if _count == 0:
raise RuntimeError('No obfuscated script found')
for i in range(len(a.pure)):
if a.pure[i][1].startswith(_src):
x = a.pure[i][1].replace(_src, _obf)
if os.path.exists(x):
if hasattr(a.pure, '_code_cache'):
with open(x) as f:
a.pure._code_cache[a.pure[i][0]] = compile(f.read(), a.pure[i][1], 'exec')
a.pure[i] = a.pure[i][0], x, a.pure[i][2]
# Patch end.
pyz = PYZ(a.pure, a.zipped_data, cipher=BLOCK_CIPHER)
|
Beta Was this translation helpful? Give feedback.
-
Sorry, forget one thing, it need append a hidden import for HIDDEN_IMPORTS = ['pyarmor_runtime_000000']
a = Analysis(
['test.py'],
pathex=['/path/to/obf'],
...) |
Beta Was this translation helpful? Give feedback.
-
Finally I decide not to move If option I have documented it here |
Beta Was this translation helpful? Give feedback.
-
thanks @jondy !! It seems to work great. A question is, how is
I guess the larger question is how this is suddenly different than the output produced from pyinstaller alone? It's hard to tell if the obfuscation has worked... here is the resulting structure following the instructions. How is The immediate below is produced from pyarmor pack obfuscation with .spec patch:
Then the below here is produced from only pyinstaller from test.spec (without patch):
What makes these different, and how is |
Beta Was this translation helpful? Give feedback.
-
A simple way is to add extra print statement in the patched ...
if os.path.exists(x):
print('replace', x)
... Note that |
Beta Was this translation helpful? Give feedback.
-
@jondy thank you so much! This is working well and I can see that the obfuscation is further working by removing
as we would expect it to, so I'm confident I just have one last question and then we can close this issue.. is there an option to rename |
Beta Was this translation helpful? Give feedback.
-
No, the runtime package name can't be changed. |
Beta Was this translation helpful? Give feedback.
-
Okay thanks @jondy - feel free to close, nice work! |
Beta Was this translation helpful? Give feedback.
-
From the cli arguments I can see the pack command is no longer listed, we rely on this and use the pyinstaller approach using a .spec file to obfuscate…
In pyarmor 8.0, how can we achieve the same thing without the pack command being available ?
Beta Was this translation helpful? Give feedback.
All reactions