Skip to content

Packaging Pyarmor obfuscated script #9039

Closed Answered by rokm
mightbecharles asked this question in Help
Discussion options

You must be logged in to vote

Is there a limit to the length of bytecode that can be imported in a hook?

I don't think so. The following example generates a package with 10k sub-modules and a hook that adds them to hiddenimports, and it seems to work for me:

import sys
import os
import pprint

NUM_MODULES=10_000

hook_dir = 'extra-hooks'

module_names = [
    f"mypackage.module_{i}" for i in range(NUM_MODULES)
]

# Create package and its modules
for module_name in module_names:
    module_file = module_name.replace('.', os.sep) + '.py'
    module_dir = os.path.dirname(module_file)
    os.makedirs(module_dir, exist_ok=True)

    with open(module_file, 'w') as fp:
        print("# Test module", file=fp)
        print(f…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mightbecharles
Comment options

Answer selected by mightbecharles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants