
    9f                         S SK r S SKrS SKrS SKJr  S SKJrJr  S SKrS SK	J
r
  S SKJrJr  S SKJrJr  S SKJr  \ R&                  " \5      rS\\   4S	 jrS
S.S\S\S\S\\\4   4S jjrSS\S\S\4S jjrg)    N)Path)OptionalTuple)paths)EXIT_CODE_OKExitCode)hazardstars)	pipx_wrapreturnc                     Sn [        [        5      R                  5       n[        [        R                  " 5       5      R                  5       n UR                  U5      nSnU(       aq  US-  S-  [        [        R                  " 5       5      R                  5       R                  S-  S-  4nU H'  nUR                  5       (       d  M  UR                  n   U $    U $ ! [         a    Sn Nf = f)zeReturns None if pipx is not installed using `pip --user`
Otherwise returns parent dir of pipx binary
NTFbinpipxScriptszpipx.exe)
r   __file__resolvesitegetuserbaserelative_to
ValueErrorgetusersitepackagesparentexists)pipx_bin_pathscript_pathuserbase_path_pip_user_installed
test_paths	test_paths          ;/usr/lib/python3/dist-packages/pipx/commands/ensure_path.pyget_pipx_user_bin_pathr"      s     Mx.((*K))+,446M"##M2 "E!F*))+,446==	IJV

 $I!! ) 0 0 $
   #"#s   C C)(C)F)prependlocationforcer#   c                6   [        U 5      nSn[        R                  " U5      n[        R                  " U5      nU(       d  U(       d  U(       d  U(       a  [        R                  " US5      nO[        R
                  " US5      nU(       d  [        [        [         SU S3SS95        O[        [        SU S3SS95        [        R                  " U5      nXE4$ U(       d!  U(       a  [        [        S	U S
3SS95        XE4$ [        [        U S3SS95        XE4$ )zEnsure location is in user's PATH or add it to PATH.
If prepend is True, location will be prepended to PATH, else appended.
Returns True if location was added to PATH
Fr   z  ze is not added to the PATH environment variable successfully. You may need to add it to PATH manually.z    )subsequent_indentzSuccess! Added z" to the PATH environment variable.
                a   has been been added to PATH, but you need to
                open a new terminal or re-login for this PATH change to take
                effect. Alternatively, you can source your shell's config file
                with e.g. 'source ~/.bashrc'.
                z is already in PATH.)	struserpathneed_shell_restartin_current_pathr#   appendprintr   r	   )r$   r%   r#   location_str
path_addedr+   r,   s          r!   ensure_pathr1   6   s+   
 x=LJ!44\B..|<O_-?!)),?J!v>Jhb /? @&- %l^3UV&- &88F  ++ !3  #*
	
 ++ 	i<.(<=QXYZ++    c           	      ,   [         R                  R                  1n[        5       nUb  UR	                  U5        SnSnU(       a  SOSnU H  n[        XqU S9u  pXH-  nXY-  nM     [        5         U(       a  [        [        S5      S-   5        OQU(       dJ  [        R                  R                  5         [        R                  [        S[         SU S	35      S-   5        U(       a  [        [        S
5      S-   5        [        S[         35        [        $ )zReturns pipx exit code.Fzprepended tozappended to)r#   r%   z
                Consider adding shell completions for pipx. Run 'pipx
                completions' for instructions.
                
r(   z(  All pipx binary directories have been z PATH. If you
                are sure you want to proceed, try again with the '--force'
                flag.
                z
                You will need to open a new terminal or re-login for the PATH
                changes to take effect. Alternatively, you can source your shell's
                config file with e.g. 'source ~/.bashrc'.
                zOtherwise pipx is ready to go! )r   ctxbin_dirr"   addr1   r.   r   sysstdoutflushloggerwarningr	   r
   r   )
r%   r#   	bin_pathspipx_user_bin_pathr0   r+   path_action_strbin_pathpath_added_currentneed_shell_restart_currents
             r!   ensure_pipx_pathsrC   g   s%   ""#I/1%()J(/n]O;Fxhm;n8	(
8 
 
G 	
  

@@Q R 		
  		
 
+E7
34r2   )F)loggingr   r8   pathlibr   typingr   r   r*   r   r   pipx.constantsr   r   pipx.emojisr	   r
   	pipx.utilr   	getLogger__name__r;   r"   boolr1   rC    r2   r!   <module>rN      s      
  "   1 % 			8	$" "J AF .,$ .,$ ., .,%PTVZPZJ[ .,b8T 8D 8X 8r2   