Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.
| 1 | # -*- mode: python ; coding: utf-8 -*- |
| 2 | |
| 3 | |
| 4 | import os |
| 5 | import sys |
| 6 | from PyInstaller.utils.hooks import collect_all |
| 7 | |
| 8 | block_cipher = None |
| 9 | |
| 10 | # Ottieni il percorso della directory corrente |
| 11 | current_dir = os.path.dirname(os.path.abspath('__main__')) |
| 12 | |
| 13 | # Funzione per verificare l'esistenza di un file o una directory |
| 14 | def resource_path(relative_path): |
| 15 | path = os.path.join(current_dir, relative_path) |
| 16 | if not os.path.exists(path): |
| 17 | print(f"Warning: {path} not found") |
| 18 | return path |
| 19 | |
| 20 | # Raccogli tutti i dati necessari per Crypto |
| 21 | crypto_datas, crypto_binaries, crypto_hiddenimports = collect_all('Crypto') |
| 22 | |
| 23 | # Raccogli tutti i moduli in Utilities e file_operations |
| 24 | utilities_datas, utilities_binaries, utilities_hiddenimports = collect_all('Utilities') |
| 25 | file_operations_datas, file_operations_binaries, file_operations_hiddenimports = collect_all('file_operations') |
| 26 | |
| 27 | # Includi il pacchetto dell'interfaccia grafica (serve per bundlare i JSON delle traduzioni) |
| 28 | gui_datas, gui_binaries, gui_hiddenimports = collect_all('GraphicUserInterface') |
| 29 | |
| 30 | # Includi la cartella con gli strumenti PS3 necessari a runtime |
| 31 | ps3lib_tree = Tree(os.path.join('packages', 'ps3lib'), prefix=os.path.join('packages', 'ps3lib')) |
| 32 | |
| 33 | # Percorso icona eseguibile |
| 34 | icon_path = resource_path(os.path.join('icons', 'icon.ico')) |
| 35 | |
| 36 | a = Analysis( |
| 37 | ['main.py'], |
| 38 | pathex=[], |
| 39 | binaries=[], |
| 40 | datas=[('PS4PKGToolTemp', 'PS4PKGToolTemp')] + utilities_datas + file_operations_datas + gui_datas, |
| 41 | hiddenimports=['repack', 'gui', 'package', 'PS4_Passcode_Bruteforcer', 'PS5_Game_Info'] + |
| 42 | utilities_hiddenimports + file_operations_hiddenimports + gui_hiddenimports, |
| 43 | hookspath=[], |
| 44 | hooksconfig={}, |
| 45 | runtime_hooks=[], |
| 46 | excludes=[], |
| 47 | win_no_prefer_redirects=False, |
| 48 | win_private_assemblies=False, |
| 49 | cipher=None, |
| 50 | noarchive=False, |
| 51 | ) |
| 52 | |
| 53 | pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) |
| 54 | |
| 55 | exe = EXE( |
| 56 | pyz, |
| 57 | a.scripts, |
| 58 | [], |
| 59 | exclude_binaries=True, |
| 60 | name='PkgToolBox', |
| 61 | debug=False, |
| 62 | bootloader_ignore_signals=False, |
| 63 | strip=False, |
| 64 | upx=True, |
| 65 | console=False, |
| 66 | disable_windowed_traceback=False, |
| 67 | argv_emulation=False, |
| 68 | target_arch=None, |
| 69 | codesign_identity=None, |
| 70 | entitlements_file=None, |
| 71 | icon=icon_path, |
| 72 | ) |
| 73 | |
| 74 | # Crea le DLL separate |
| 75 | coll = COLLECT( |
| 76 | exe, |
| 77 | a.binaries, |
| 78 | a.zipfiles, |
| 79 | a.datas, |
| 80 | ps3lib_tree, |
| 81 | strip=False, |
| 82 | upx=True, |
| 83 | upx_exclude=[], |
| 84 | name='PkgToolBox', |
| 85 | ) |
| 86 | |
| 87 | # Crea una cartella per i file temporanei |
| 88 | temp_folder = 'PS4PKGToolTemp' |
| 89 | if not os.path.exists(temp_folder): |
| 90 | os.makedirs(temp_folder) |
| 91 | |
| 92 | # Copia la cartella PS4PKGToolTemp nell'eseguibile |
| 93 | import shutil |
| 94 | shutil.copytree(temp_folder, os.path.join(DISTPATH, temp_folder), dirs_exist_ok=True) |
| 95 | |
| 96 | print(f"Build completed. Executable and libraries should be in {DISTPATH}") |
| 97 |