+
    Ki   c                   s.   R t ^ RIt^ RIt^ RIHt ^ RIHtHtHtH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt R
tR R ltR R ltR R lt]R R l4       tR R ltR R ltR R lt]R R l4       tR R lt ]R3R R llt!R  R! lt"R# )"z*Utility module to deal with Proton and umuN)gettext)Dict	GeneratorListOptional)settings)MissingExecutableError)RUNNING_COMMANDS)cache_singlesystem)get_steamapps_dirs)get_natural_sort_keyzumu-defaultc                F    V ^8  d   QhR\         \        ,          R\        /#    versionreturnr   strboolZformat   "</usr/lib/python3.14/site-packages/lutris/util/wine/proton.py__annotate__r      s     , ,x} , ,    c                s    V \        4       9   # )zTrue if the version indicated specifies a Proton version of Wine; these
require special handling. This does not recognize the special 'ge-proton' version
found in configurations; this must be specially  handled elsewhere.)get_proton_versions)r      &r   is_proton_versionr      s     )+++r   c                r   )r   pathr   r   r   r   r   r   r      s"     V Vhsm V Vr   c                s|    \        T ;'       d+    V P                  R4      ;'       g    V P                  R4      4      # )zTrue if the path given actually runs Umu; this will run Proton-Wine in turn,
but can be directed to particular Proton implementation by setting the env-var
PROTONPATH, but if this is omitted it will default to the latest Proton it
downloads.z/umu_run.pyz/umu-run)r   Zendswith)r   r   r   is_umu_pathr      s1    
 TT$--6SS$--
:SUUr   c                r   r   	wine_pathr   r   r   r   r   r   r   !   s      hsm  r   c                s    V '       g   R# \        4       P                  4        F"  p\        P                  ! W4      '       g   K!   R# 	  R# )as  True if the path given actually runs Umu; this will run Proton-Wine in turn,
but can be directed to particular Proton implementation by setting the env-var
PROTONPATH, but if this is omitted it will default to the latest Proton it
downloads.

This function may be given the wine root directory or a file within such as
the wine executable and will return true for either.TF)r   Zvaluesr	   Zpath_contains)r   Zcandidate_wine_path   & r   is_proton_pathr!   !   s;     24;;= 3??  > r   c                $    V ^8  d   QhR\         /# r   r   r   r   r   r   r   r   2   s     $> $>c $>r   c                 s$   RR.p \         P                  ! R4      pV'       dI   V  FB  p\        P                  P	                  W4      p\
        P                  ! V4      '       g   K@  Vu # 	  \
        P                  ! R4      '       d   \
        P                  ! R4      # RRRR\         P                  3pV FO  pV  FF  p\        P                  P	                  VRV4      p\
        P                  ! V4      '       g   KB  Vu u # 	  KQ  	  \        R	4      h)
ah  Returns the path to the Umu launch script, which can be run to execute
a Proton version. It can supply a default Proton, but if the env-var PROTONPATH
is set this will direct it to a specific Proton installation.

The path that this returns will be considered an Umu path by is_umu_path().

If this script can't be found this will raise MissingExecutableError.zumu-runz
umu_run.pyZumu_pathz
/app/sharez/usr/local/sharez
/usr/sharez/optZumuzInstall umu to use Proton)r   Zread_settingosr   joinr	   Zpath_existsZcan_find_executableZfind_required_executableRUNTIME_DIRr   )Zentry_pointsZcustom_pathZentry_pointZ
entry_pathZpath_candidatesZpath_candidates         r   get_umu_pathr(   1   s     |,L''
3K'Kk?J!!*--!! ( !!),,..y99O *'Kne[IJ!!*--!! ( *
 !!<
==r   c                0    V ^8  d   QhR\         R\         /# r   r$   r   r   r   r   r   Y   s     w w# w# wr   c                s   \        4       P                  V 4      pV'       d   \        P                  P	                  VR4      p\        P                  P                  V4      '       d   V# \        P                  P	                  VR4      p\        P                  P                  V4      '       d   V# \        \        R4      V ,          4      h)z2Get the wine path for the specified proton versionzdist/bin/winezfiles/bin/winezEProton version '%s' is missing its wine executable and can't be used.)r   getr%   r   r&   existsr   _)r   r   Zwine_path_distZwine_path_filess   &   r   get_proton_wine_pathr-   Y   s    #%))'2IiA77>>.))!!'',,y2BC77>>/**""
 #j!knu!u
vvr   c                r)   r   r$   r   r   r   r   r   h   s      s s r   c                 s    \         P                  P                  V 4      p\         P                  P                  \         P                  P                  V4      4      pV# )N)r%   r   Zdirname)r   Zdirectory_pathZversion_directorys   &  r   get_proton_path_by_pathr.   h   s<    WW__Y/N (GHr   c                s:    V ^8  d   QhR\         \        ,          /# r#   )r   r   r   r   r   r   r   r   s     X Xd3i Xr   c                 sR    \        \        4       P                  4       \        RR7      # )zGReturn the list of Proton versions installed in Steam, in sorted order.T)ZkeyZreverse)Zsortedr   Zkeysr    r   r   list_proton_versionsr0   r   s     %',,.4HRVWWr   c                sF    V ^8  d   QhR\         \        \        3,          /# r#   )r   r   r   r   r   r   r   x   s      T#s(^ r   c                 s    \        4       p \        4       p\        4        F  p\        P
                  P                  T4      '       g   K*  \        P                  ! T4       Fs  pY19  g   K  \        P
                  P                  Y#4      p\        P
                  P                  \        P
                  P                  TR4      4      '       g   Ko  YAT&   Ku  	  K  	  T#   \         d    / u # i ; i)zReturn the dict of Proton versions installed in Steam, which is cached.
The keys are the versions, and the values are the paths to those versions,
which are their wine-paths.Zproton)
r(   r   Zdict_iter_proton_locationsr%   r   ZisdirZlistdirr&   Zisfile)r,   ZversionsZproton_pathr   r   s        r   r   r   w   s    
N vH-/77==%%::k2* "[ BIww~~bggll9h&GHH,5)	 3 0 O " 	s   
C C-,C-c                s@    V ^8  d   QhR\         \        RR3,          /# )r   r   N)r   r   r   r   r   r   r      s      	#tT/ : r   c               #  sX  "   \         P                  x   \        4       p T  Uu. uF#  p\        P                  P                  TR4      NK%  	  up F  pTx  K	  	  T  Uu. uF#  p\        P                  P                  TR4      NK%  	  up F  pTx  K	  	  R#     R# ; iu upi u upi 5i)z.Iterate through all potential Proton locationsNZcommon )r   ZWINE_DIRr
   r%   r   r&   )Zsteamapp_dirsZpr   s      r   r1   r1      s     


*, 5BBMqa*MB
 C /<<ma$m<
 =B =s2   B*
B B*)B B*)B%B*BB*r2   c          
      sn    V ^8  d   QhR\         R\        \         \         3,          R\         R\         RR/# )r   r   envgame_idumu_logr   N)r   r   r   r   r   r   r      s9     $$ $$ $$4S> $$C $$cf $$pt $$r   c                s   RV9  d&   \        V 4      '       d   RVR&   M\        V 4      VR&   RV9  d   W!R&   RV9  d   V'       d   W1R&   RV9  d   RVR&   RV9  d7   VP                  R4      pV'       d   VR	 \         4       9   d   R
VR&   MRVR&   VP                  R4      pVP                  R4      pV'       d   V'       g   WQR&   R# R# R# )a  Add various env-vars to an 'env' dict for use by Proton and Umu; this won't replace env-vars, so they can still
be pre-set before we get here. This sets the PROTONPATH so the Umu launcher will know what Proton to use,
and the WINEARCH to win64, which is what we expect Proton to always be. GAMEID is required, but we'll use a default
GAMEID if you don't pass one in.

This also propagates LC_ALL to HOST_LC_ALL, if LC_ALL is set.Z
PROTONPATHz	GE-ProtonZGAMEIDZUMU_LOGZWINEARCHZwin64ZPROTON_VERB
WINEPREFIXc              3   sV   "   T F  qP                   P                  R 4      x  K!  	  R# 5i)r6   N)r3   r*   )Z.0Zcr    r   Z	<genexpr>Z$update_proton_env.<locals>.<genexpr>   s       SBRQ<!8!8BRs   ')ZruninprefixZwaitforexitandrunZLC_ALLZHOST_LC_ALLN)r   r.   r*   r   )r   r3   r4   r5   ZprefixZlocaleZhost_locales   &&&&   r   update_proton_envr7      s     3y!! +C 7	 BCsH I!JC &f SBR SS!.C!4CWWXF''-(Kk#M "vr   c                r"   r#   r$   r   r   r   r   r      s      c r   c                 s   V '       g   \         # VP                  R 4      pV'       d   V# \        P                  P	                  \
        P                  R4      p\        P                  P                  V4      '       g   \         # \        VRRR7      ;_uu_ 4       p\        P                  ! V4      pRRR4       X Fr  pVR,          '       g   K  VR,          V P                  8X  g$   VR,          R8X  g   K<  V P                  R8X  g   KO  VR	,          V P                  8X  g   Ki  VR
,          u # 	  \         #   + '       g   i     L; i)ZUMU_IDzumu-games/umu-games.jsonZrzutf-8)ZencodingNZstoreZhumbleZhumblebundleappidZumu_id)DEFAULT_GAMEIDr*   r%   r   r&   r   r'   r+   ZopenjsonZloadZservicer8   )Zgamer3   r4   Z
games_pathZ
games_fileZ	umu_gamesZumu_games   &&     r   get_game_idr;      s    gghGh224NOJ77>>*%%	j#	0	0JIIj)	 
1 W!T\\1hw6G86SX\XdXdhvXv!TZZ/H%%   
1	0s   D66E	)#Z__doc__r:   r%   r    r,   Ztypingr   r   r   r   Zlutrisr   Zlutris.exceptionsr   Zlutris.monitored_commandr   Zlutris.utilr   r	   Zlutris.util.steam.configr
   Zlutris.util.stringsr   r9   r   r   r!   r(   r-   r.   r0   r   r1   r7   r;   r/   r   r   <module>r<      s    0  	   2 2  4 5 , 7 4,V  $> $>NwX
  *  KYik $$Nr   