@@ -654,25 +654,45 @@ def unpack_to_dir(destpath = ""):
654654 if not destpath :
655655 return
656656
657+ if not os .path .isdir (destpath ):
658+ os .makedirs (destpath )
659+
657660 if os .path .isdir (srcpath ) and os .path .isdir (destpath ) and not os .listdir (destpath ):
658661 try :
659662 if cliunpack :
660663 print (f"KoboldCpp will be extracted to { destpath } \n This process may take several seconds to complete." )
661664 else :
662665 messagebox .showinfo ("Unpack Starting" , f"KoboldCpp will be extracted to { destpath } \n This process may take several seconds to complete." )
663666 pyds_dir = os .path .join (destpath , 'pyds' )
667+ using_pyinstaller_6 = False
668+ try :
669+ import pkg_resources
670+ piver = pkg_resources .get_distribution ("pyinstaller" ).version
671+ print (f"PyInstaller Version: { piver } " )
672+ if piver .startswith ("6." ):
673+ using_pyinstaller_6 = True
674+ os .makedirs (os .path .join (destpath , "_internal" ), exist_ok = True )
675+ pyds_dir = os .path .join (os .path .join (destpath , "_internal" ), 'pyds' )
676+ except Exception :
677+ pass
664678 os .makedirs (pyds_dir , exist_ok = True )
665679 for item in os .listdir (srcpath ):
666680 s = os .path .join (srcpath , item )
667681 d = os .path .join (destpath , item )
668- if item .endswith ('.pyd' ): # relocate pyds files to subdirectory
669- d = os .path .join (pyds_dir , item )
682+ d2 = d #this will be modified for pyinstaller 6 and unmodified for pyinstaller 5
683+ if using_pyinstaller_6 :
684+ d2 = os .path .join (os .path .join (destpath , "_internal" ), item )
685+ if using_pyinstaller_6 and item .startswith ('koboldcpp-launcher' ): # Move koboldcpp-launcher to its intended location
670686 shutil .copy2 (s , d )
687+ continue
688+ if item .endswith ('.pyd' ): # relocate pyds files to subdirectory
689+ pyd = os .path .join (pyds_dir , item )
690+ shutil .copy2 (s , pyd )
691+ continue
692+ if os .path .isdir (s ):
693+ shutil .copytree (s , d2 , False , None )
671694 else :
672- if os .path .isdir (s ):
673- shutil .copytree (s , d , False , None )
674- else :
675- shutil .copy2 (s , d )
695+ shutil .copy2 (s , d2 )
676696 if cliunpack :
677697 print (f"KoboldCpp successfully extracted to { destpath } " )
678698 else :
0 commit comments