
    9f&                     <
   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
rSSKJr  SSKJrJrJrJrJrJr  SSKrSSKrSSKJr  SSKJrJrJr  SSKJrJr  SSK J!r!J"r"  SS	K#J$r$  SS
K%J&r&J'r'J(r(J)r)J*r*  SSK+J,r,  SSK-J.r.J/r/J0r0  SSK1J2r2J3r3J4r4J5r5  SSK6J7r7  SSK8J9r:  \Rv                  " \<5      r=\\>/\\>   4   r?S[S jr@S\>4S jrA\R                  " S5      rC\R                  " S\R                  R                  < S\R                  R                  < S\R                  R                  < S35      rH\H\4" SSSS9-  rH\R                  " S\.5      rJ\R                  " S\R                   S\R                   S\R                   S \R                   S!\R                   S"\R                   S#\R                   S$\J S%35      rQ " S& S'\R                  5      rS " S( S)5      rTS*\\>\>4   S\\>   4S+ jrUS*\\>\>4   S\\>   4S, jrVS\S-\>S.\WS\W4S/ jjrXS-\>4S0 jrYS1\R                  S2\\>\R                  4   S\*4S3 jr\S4\R                  SS4S5 jr]S4\R                  SS4S6 jr^S4\R                  SS4S7 jr_S2\R                  S8\R                  SS4S9 jraS2\R                  S8\R                  SS4S: jrbS;\?S8\R                  SS4S< jrcS;\?S8\R                  4S= jrdS;\?S8\R                  SS4S> jreS;\?S8\R                  SS4S? jrfS;\?S8\R                  SS4S@ jrgS2\R                  S8\R                  SS4SA jrhS2\R                  S8\R                  SS4SB jriS;\?S8\R                  SS4SC jrjS2\R                  S8\R                  SS4SD jrkS;\?S8\R                  SS4SE jrlS2\R                  S8\R                  SS4SF jrmS2\R                  S8\R                  SS4SG jrnS2\R                  S8\R                  S\R                  4SH jroS2\R                  S8\R                  SS4SI jrpS;\?S8\R                  SS4SJ jrqS2\R                  S8\R                  SS4SK jrrS2\R                  S8\R                  SS4SL jrsS\\R                  \\>\R                  4   4   4SM jrtSN\\   SO\uSS4SP jrvS]SQ\\   S\4SR jjrwS\4SS jrxST\uSS4SU jryS1\R                  SS4SV jrzSW\R                  SS4SX jr{S\*4SY jr|\<SZ:X  a  \R                  " \|" 5       5        gg)^z"The command line interface to pipx    N)Path)AnyCallableDictListOptionalTuple)canonicalize_name)commands	constantspaths)hide_cursorshow_cursor)boldgreen)ENVIRONMENT_VARIABLES)EXIT_CODE_OK/EXIT_CODE_SPECIFIED_PYTHON_EXECUTABLE_NOT_FOUNDMINIMUM_PYTHON_VERSIONWINDOWSExitCode)hazard)DEFAULT_PYTHONInterpreterResolutionErrorfind_python_interpreter)	PipxErrormkdir	pipx_wraprmdir)VenvContainer)versionreturnc                  "    [        [        5        g N)print__version__     +/usr/lib/python3/dist-packages/pipx/main.pyprint_versionr*   0   s
    	+r(   c                       [         R                  R                  [        R                  S   5      n U S:X  a  [        R
                   S3$ U $ ! [         a     gf = f)Nr   z__main__.pyz -m pipxpipx)ospathbasenamesysargv
executable	Exception)progs    r)   	prog_namer5   4   sW    ww,= nn%X..K s   AA A 
AAz    The package name or specific installation source passed to pip.
    Runs `pip install -U SPEC`.
    For example `--spec mypackage==2.0.0` or `--spec  git+https://github.com/user/repo.git@branch`
    z
    Install and execute apps from Python packages.

    Binaries can either be installed globally into isolated Virtual Environments
    or run directly in a temporary Virtual Environment.

    Virtual Environment location is z%.
    Symlinks to apps are placed in z-.
    Symlinks to manual pages are placed in z.

    a  
    optional environment variables:
      PIPX_HOME              Overrides default pipx location. Virtual Environments will be installed to $PIPX_HOME/venvs.
      PIPX_GLOBAL_HOME       Used instead of PIPX_HOME when the `--global` option is given.
      PIPX_BIN_DIR           Overrides location of app installations. Apps are symlinked or copied here.
      PIPX_GLOBAL_BIN_DIR    Used instead of PIPX_BIN_DIR when the `--global` option is given.
      PIPX_MAN_DIR           Overrides location of manual pages installations. Manual pages are symlinked or copied here.
      PIPX_GLOBAL_MAN_DIR    Used instead of PIPX_MAN_DIR when the `--global` option is given.
      PIPX_DEFAULT_PYTHON    Overrides default python used for commands.
      USE_EMOJI              Overrides emoji behavior. Default value varies based on platform.
      PIPX_HOME_ALLOW_SPACE  Overrides default warning on spaces in the home path
    z                        T)subsequent_indentkeep_newlinesPIPX__DOC_DEFAULT_PYTHONa  
    The install command is the preferred way to globally install apps
    from python packages on your system. It creates an isolated virtual
    environment for the package, then ensures the package's apps are
    accessible on your $PATH. The package's manual pages installed in
    share/man/man[1-9] can be viewed with man on an operating system where
    it is available and the path in the environment variable `PIPX_MAN_DIR`
    (default: a  ) is in the man search path
    ($MANPATH).

    The result: apps you can run from anywhere, located in packages
    you can cleanly upgrade or uninstall. Guaranteed to not have
    dependency version conflicts or interfere with your OS's python
    packages. 'sudo' is not required to do this.

    pipx install PACKAGE_SPEC ...
    pipx install --python PYTHON PACKAGE_SPEC
    pipx install VCS_URL
    pipx install ./LOCAL_PATH
    pipx install ZIP_FILE
    pipx install TAR_GZ_FILE

    The PACKAGE_SPEC argument is passed directly to `pip install`.

    Virtual Environments will be installed to `$PIPX_HOME/venvs`.
    The default pipx home location is z and can
    be overridden by setting the environment variable `PIPX_HOME`.
    If the `--global` option is used, the default pipx home location
    instead is zt and can be overridden
    by setting the environment variable `PIPX_GLOBAL_HOME`.

    The default app location is z and can be
    overridden by setting the environment variable `PIPX_BIN_DIR`.
    If the `--global` option is used, the default app location instead
    is z and can be overridden by
    setting the environment variable `PIPX_GLOBAL_BIN_DIR`.

    The default manual pages location is z and
    can be overridden by setting the environment variable `PIPX_MAN_DIR`.
    If the `--global` option is used, the default manual pages location
    instead is z and can be overridden
    by setting the environment variable `PIPX_GLOBAL_MAN_DIR`.

    The default python executable used to install a package is
    zZ and can be overridden
    by setting the environment variable `PIPX_DEFAULT_PYTHON`.
    c                   0    \ rS rSrS\S\S\\   4S jrSrg)LineWrapRawTextHelpFormatter   textwidthr"   c                     U R                   R                  SU5      R                  5       n[        R                  " X5      $ )N )_whitespace_matchersubstriptextwrapwrap)selfr<   r=   s      r)   _split_lines)LineWrapRawTextHelpFormatter._split_lines   s2    ''++C6<<>}}T))r(   r'   N)	__name__
__module____qualname____firstlineno__strintr   rF   __static_attributes__r'   r(   r)   r:   r:      s     * *S *T#Y *r(   r:   c                   B    \ rS rSrS\SS4S jrS\S\S\\   4S jr	S	r
g)
InstalledVenvsCompleter   venv_containerr"   Nc                     [        UR                  5       5       Vs/ s H  n[        UR                  5      PM     snU l        g s  snf r$   )sortediter_venv_dirsrL   namepackages)rE   rR   ps      r)   __init__ InstalledVenvsCompleter.__init__   s3    .4^5R5R5T.UV.UQVV.UVVs   Aprefixkwargsc                     U R                    Vs/ s H5  o3R                  [        U5      5      (       d  M#  U U[        U5      S   3PM7     sn$ s  snf r$   )rW   
startswithr
   len)rE   r[   r\   xs       r)   useInstalledVenvsCompleter.use   sE    6:mmom||TeflTmGn,6(1S[\?+,mooos
   "AA)rW   )rH   rI   rJ   rK   r    rY   rL   r   r   ra   rN   r'   r(   r)   rP   rP      s:    W} W Wp# p pc pr(   rP   parsed_argsc                    / nU R                  S5      (       a
  USU S   /-  nU R                  S5      (       a5  U S   R                  S5      nU[        R                  " U[        (       + S9-  nU R                  S5      (       a  US/-  nU$ )N	index_url--index-urlpip_args')posixeditable
--editable)getrB   shlexsplitr   )rc   rg   pip_args_stripeds      r)   get_pip_argsrp      s    H{##]K$<==z""&z288=EKK 0GDD z""\N"Or(   c                 B    / nU R                  S5      (       a  US/-  nU$ )Nsystem_site_packages--system-site-packages)rl   )rc   	venv_argss     r)   get_venv_argsru      s+    I-...//	r(   packageraise_errorc                     [         R                  R                  U 5      nUR                  (       a$  UR                  (       a  U(       d  g[        S5      eg)NTzGPackage cannot be a URL. A valid package name should be passed instead.F)urllibparseurlparseschemenetlocr   )rv   rw   url_parse_packages      r)   package_is_urlr      s>    --g6$5$<$<abbr(   c                 p    [         R                  R                  U ;   a  [        [	        SU  S35      5      eg )Nz
                Error: 'z`' looks like a path.
                Expected the name of an installed package.
                )r-   r.   sepr   r   )rv   s    r)   package_is_pathr      s@    	ww{{g 	 "
 	
 r(   args
subparsersc                    SU ;   a  U R                   OSn[        [        U 5      5      n[        [        U 5      5      n[	        [
        R                  R                  5      nSU ;   a  U R                  n[        U5        [        U5        SU ;   aM  U R                  b@  [        U R                  SS9(       a'  SU R                  ;  a  U R                  SU 3-   U l        UR                  U5      n[        R                  SU 35        SU ;   a  U R                   H  n[        U5        [        U5        M     U R                   Vs0 s H  ofUR                  U5      _M     nnS	R!                  S
 UR#                  5        5       5      n	[        R                  SU	 35        SU ;   a%  U R$                   V
s/ s H  n
['        U
5      PM     nn
SnSU ;   aI  [)        U R*                  5      nU R,                  n [/        U R*                  =(       d    [0        US9nXl        U R>                  S:X  a{  [@        RB                  " U RD                  S   U R                  U RF                  U RD                  SS  U R*                  UUU RH                  UU RJ                  (       + 5
        [M        S5      $ U R>                  S:X  a  [@        RN                  " S S U RP                  [
        R                  RR                  [
        R                  RT                  U R*                  UUUU RV                  SU RX                  U RZ                  U R\                  US9$ U R>                  S:X  ai  [@        R^                  " U R`                  [
        R                  RR                  [
        R                  RT                  U R*                  UUUU RV                  S9$ U R>                  S:X  aY  [@        Rb                  " WS U Rd                  U Rf                  UUU Rh                  U RX                  U RV                  U Rj                  S9
$ U R>                  S:X  a]  [@        Rl                  " WU Rd                  [
        R                  RR                  [
        R                  RT                  U Rn                  US9$ U R>                  S :X  aD  [@        Rp                  " WU R*                  UUUU Rr                  U RV                  U RN                  US!9	$ U R>                  S":X  a.  [@        Rt                  " UUU Rr                  WU RV                  UUS#9$ U R>                  S$:X  a  [@        Rv                  " UU5      $ U R>                  S%:X  aB  [@        Rx                  " UU Rr                  U Rz                  U R|                  U R~                  5      $ U R>                  S&:X  a  U R                  S%:X  a  [@        R                  " U5      $ U R                  S':X  a  [@        R                  " U5      $ U R                  S :X  a  [@        R                  " XR5      $ U R                  c  US&   R                  5         [        $ [        S(U R                   35      eU R>                  S):X  a#  [@        R                  " WUWU R                  5      $ U R>                  S*:X  a  [@        R                  " WU5      $ U R>                  S+:X  aI  [@        R                  " W[
        R                  RR                  [
        R                  RT                  U5      $ U R>                  S,:X  aI  [@        R                  " U[
        R                  RR                  [
        R                  RT                  U5      $ U R>                  S-:X  aS  [@        R                  " W[
        R                  RR                  [
        R                  RT                  U R*                  UUS.9$ U R>                  S/:X  aT  [@        R                  " U[
        R                  RR                  [
        R                  RT                  U R*                  UWUS09$ U R>                  S1:X  a>  W(       d  [        S25      e[@        R                  " WXpR                  U R                   5      $ U R>                  S3:X  a*   [@        R                  " U R                  U RV                  S49$ U R>                  S7:X  a$  [7        [        R                  5        [M        S5      $ U R>                  S8:X  a  [@        R                  " U R                  S99$ [        S:U R>                   35      es  snf s  sn
f ! [2         a@  n[        R5                  SSS9  [7        [9        [:         SU 3SS95        [<        s S nA$ S nAff = f! [         a-  n[        R5                  S5SS9  [        [        U5      SS69S eS nAff = f);NverboseFrv   spec)rw   z#egg=z Virtual Environment location is rW   
c              3   6   #    U  H  u  pS U SU 3v   M     g7f)z- z : Nr'   ).0keyvalues      r)   	<genexpr>#run_pipx_command.<locals>.<genexpr>   s!     ![IZ:3Bse3ug"6IZs   z#Virtual Environment locations are:
skippython)fetch_missing_pythonzFailed to resolve interpreter:Texc_infor?       r6   runr      install)force	reinstallinclude_dependenciespreinstall_packagessuffixpython_flag_passedinstall-all)r   inject)r   include_appsr   r   r   uninject)local_bin_dirlocal_man_dir
leave_depsr   upgrade)include_injectedr   r   r   upgrade-all)r   r   r   rg   r   upgrade-sharedlistinterpreterprunezUnknown interpreter command pinunpin	uninstalluninstall-allr   )venv_dirr   r   r   r   r   reinstall-all)r   r   runpipz)Developer error: venv_dir is not defined.
ensurepath)prependr   Uncaught Exception:)wrap_messagecompletionsenvironment)r   zUnknown command )Xr   rp   varsru   r    r   ctxvenvsrv   r   r   r   get_venv_dirloggerinforW   joinitemsr   r
   boolr   r   r   r   r   debugr%   r   r   r   commandr   r   app_with_argsr.   
pypackagesno_cacher   r   package_specbin_dirman_dirr   include_deps
preinstallr   install_allspec_metadata_filer   dependenciesrequirementsr   with_suffixr   r   r   r   upgrade_allupgrade_sharedlist_packagesjsonshortpinnedinterpreter_commandlist_interpretersprune_interpretersupgrade_interpreters
print_helpr   r   r   injected_onlyr   r   uninstall_allr   reinstall_allrun_pippipargsensure_pipx_pathsr   r3   rL   r   completion_instructionsr   r   )r   r   r   rg   rt   rR   rv   r   	venv_dirsvenv_dirs_msgr`   	skip_listr   r   r   es                   r)   run_pipx_commandr      s   '4/dllUGDJ'Hd4j)I"599??3ND,,w T>dii3diiU;$))+ $		eG9,= =DI!..w76xjABT}}G7#G$ % SWR_R_`R_wn99'BBR_	`		![IZ![[:=/JK~3799=9a&q)9	=4!$++.#88	C1-~DXK &K ||uq!IIIIqr"KKOO	
 {		"IIIIKK**!%!2!2 $;;1
 	
" 
	&####IIIIKK**	
 		
 
	!**!%!2!2**##
 	
 
	#  ))++))++
 	
 
	"KK!22**LL1

 
	
 
	&##!22**1
 	
 
)	)&&
 	
 
	%%!!IIJJKK
 	
 
	&##v---n==%%0..~>>%%200II%%-}%002:4;S;S:TUVV		||Hgy$:L:LMM		 ~~h00		$!!(EII,=,=uyy?P?PRYZZ		(%%IIII	
 	
 
	$!!))++))++;;1
 	
 
	(%%IIIIKK1
 	
 
	!GHH<<NN		%	B--dll$**UU 
	&i//0{		&##$**55*4<<.9::y a
 > * 	CLL9DLIhasO&- CB	CD  	BLL.L>CF7TA	BsB   d00d51'd: (f :
f5e?9f?f
f>(f99f>parserc                     U R                  SSSS9  U R                  SSSS9  U R                  S	S
SSS9  U R                  SSS9  g )Nrs   
store_truezDGive the virtual environment access to the system site-packages dir.actionhelprf   z-iz Base URL of Python Package Indexr   rk   z-ez"Install a project in editable moder   r   
--pip-argsHArbitrary pip arguments to pass directly to pip install/upgrade commandsadd_argumentr   s    r)   add_pip_venv_argsr     sp    
 S  
 t2TU
1	   W  r(   c                 &    U R                  SSSS9  g )N--include-depsz"Include apps of dependent packagesr   r   r   r   s    r)   add_include_dependenciesr     s    
(/S\hir(   c                 V    U R                  SS[         S3S9  U R                  SSSS9  g )	Nz--pythonzPython to install with. Possible values can be the executable name (python3.11), the version of an available system Python or to pass to py launcher (3.11), or the full path to the executable. Requires Python z
 or above.r   z--fetch-missing-pythonr   zzWhether to fetch a standalone python build from GitHub if the specified python version is not found locally on the system.r   )r   r   r   s    r)   add_python_optionsr     sN    
CCYBZZdf     I	  r(   shared_parserc                    U R                  SS[        [        U/S9nUR                  SSSS9  [	        U5        UR                  SS	S
SS9  UR                  SSSS9  [        U5        UR                  SSSS9  [        U5        g )Nr   zInstall a packager   formatter_classdescriptionparentsr   z+package name(s) or pip installation spec(s)+r   nargs--force-fr   NModify existing virtual environment and files in PIPX_BIN_DIR and PIPX_MAN_DIRr   z--suffix z}Optional suffix for virtual environment and executable names. NOTE: The suffix feature is experimental and subject to change.)defaultr   z--preinstallappendzOptional package to be installed into the Virtual Environment before installing the main package. Use this flag multiple times if you want to preinstall multiple packages.)
add_parserr:   INSTALL_DESCRIPTIONr   r   r   r   r   r   rX   s      r)   _add_installr    s     4' 	 	A NN>(U]`NaQNN]	   NNN	   qNNu	   ar(   c                     U R                  SS[        SU/S9nUR                  SSS9  UR                  SS	S
SS9  [        U5        [	        U5        g )Nr   zInstall all packagesz:Installs all the packages according to spec metadata file.r   r   z2Spec metadata file generated from pipx list --jsonr   r  r  r   r  r   )r  r:   r   r   r   r  s      r)   _add_install_allr    sk    #4P 	 	A NN'.bNcNN]	   qar(   venv_completerc           
      @   U R                  SSSU/S9nUUR                  SSS9l        UR                  SS	S
S9  UR                  SSSS/ SSS9  UR                  SSSS9  UR                  SSSS9  [        U5        UR                  SSSSS9  UR                  SSSS9  g )Nr   z5Install packages into an existing Virtual EnvironmentzBInstalls packages to an existing pipx-managed virtual environment.r   r   r  rv   DName of the existing pipx-managed Virtual Environment to inject intor   r   *z\the packages to inject into the Virtual Environment--either package name or pip package specr  r   z-rz--requirementr   r
  filezfile containing the packages to inject into the Virtual Environment--one package name or pip package spec per line. May be specified multiple times.)destr   r	  metavarr   z--include-appsr   zPAdd apps from the injected packages onto your PATH and expose their manual pagesr   r   z:Include apps of dependent packages. Implies --include-appsr   r  r  r  z--with-suffixzNAdd the suffix (if given) of the Virtual Environment to the packages to inject)r  r   	completerr   r   r  r   rX   s       r)   _add_injectr    s   DX	 	 	A ! NNS   NNk  
 NN/   NN_  
 NNI  
 aNN]	   NN]  r(   c                     U R                  SSSU/S9nUUR                  SSS9l        UR                  SS	S
S9  UR                  SSSS9  g )Nr   z@Uninstall injected packages from an existing Virtual EnvironmentzOUninstalls injected packages from an existing pipx-managed virtual environment.r  rv   r  r   r   r  z:the package names to uninject from the Virtual Environmentr  z--leave-depsr   zNOnly uninstall the main injected package but leave its dependencies installed.r   r  r   r  r  s       r)   _add_uninjectr  C  s~    Oe	 	 	A ! NNS   NNI  
 NN]  r(   c                     U R                  SSSU/S9nUR                  SSS9  UR                  SSS	S
9  UR                  SS/ SS9  g )Nr   z;Pin the specified package to prevent it from being upgradedr  rv   zInstalled package to pinr   z--injected-onlyr   zPin injected packages in venv only, so that they will not be upgraded during upgrade operations. Note that this should not be passed if you wish to pin both main package and injected packages.r   --skipr  z/Skip these packages. Implies `--injected-only`.r  r	  r   r  r   r  s       r)   _add_pinr$  Z  st    JQ	 	 	A NN9#=N>NNn	   NN>	  r(   c                 J    U R                  SSSU/S9nUR                  SSS9  g )Nr   zUnpin the specified packagez^Unpin the specified package and all injected packages in its venv to allow them to be upgradedr  rv   zInstalled package to unpinr   r#  r  s       r)   
_add_unpinr&  r  s8    *t	 	 	A NN9#?N@r(   c                     U R                  SSSU/S9nXR                  SSSS9l        UR                  S	S
SS9  UR                  SSS
SS9  [        U5        UR                  SS
SS9  [	        U5        g )Nr   zUpgrade a packagezdUpgrade package(s) in pipx-managed Virtual Environment(s) by running 'pip install --upgrade PACKAGE'r  rW   zpackage names(s) to upgrader  r  --include-injectedr   >Also upgrade packages injected into the main app's environmentr   r  r  r  z	--installzInstall package spec if missing)r  r   r  r   r   r  s       r)   _add_upgrader*  |  s     z	 	 	A [iNN:$ANMWNNM  
 NN]	   aNN.  
 qr(   c                     U R                  SSSU/S9nUR                  SSSS9  UR                  S	S
/ SS9  UR                  SSSSS9  g )Nr   zGUpgrade all packages. Runs `pip install -U <pkgname>` for each package.zbUpgrades all packages within their virtual environments by running 'pip install --upgrade PACKAGE'r  r(  r   r)  r   r!  r  skip these packagesr"  r  r  r  r#  r  s      r)   _add_upgrade_allr-    su    Vx	 	 	A NNM  
 NN839NNONN]	  r(   c                 J    U R                  SSSU/S9nUR                  SSS9  g )Nr   zUpgrade shared libraries.r  r   r   r   r#  r  s      r)   _add_upgrade_sharedr/    s>    (/	 	 	A NNW  r(   c                 T    U R                  SSSU/S9nXR                  S5      l        g )Nr   zUninstall a packagezbUninstalls a pipx-managed Virtual Environment by deleting it and any files that point to its apps.r  rv   r  r  s       r)   _add_uninstallr1    s6    "x	 	 	A +9NN9'r(   c                 *    U R                  SSSU/S9  g )Nr   zUninstall all packagesz#Uninstall all pipx-managed packagesr  )r  )r   r   s     r)   _add_uninstall_allr3    s#    %9	  r(   c                     U R                  S[        S[        R                  " S5      U/S9nXR	                  S5      l        [        U5        g )Nr   zReinstall a packagez
            Reinstalls a package.

            Package is uninstalled, then installed with pipx install PACKAGE
            with the same options used in the original install of PACKAGE.

            r   r   r   r  rv   )r  r:   rC   dedentr   r  r   r  s       r)   _add_reinstallr7    sQ    4"OO
  	 	A +9NN9'qr(   c                     U R                  S[        S[        R                  " S5      U/S9n[	        U5        UR                  SS/ SS9  g )	Nr   zReinstall all packagesaV  
            Reinstalls all packages.

            Packages are uninstalled, then installed with pipx install PACKAGE
            with the same options used in the original install of PACKAGE.
            This is useful if you upgraded to a new version of Python and want
            all your packages to use the latest as well.

            r5  r!  r  r,  r"  )r  r:   rC   r6  r   r   r  s      r)   _add_reinstall_allr9    sW    4%OO

  	 	A" qNN839NNOr(   c                     U R                  SSSU/S9nUR                  SSSS9  UR                  5       nUR                  S	SS
S9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  g )Nr   zList installed packagesz*List packages and apps installed with pipxr  r(  r   z6Show packages injected into the main app's environmentr   z--jsonz Output rich data in json format.z--shortzList packages only.z--pinnedzoList pinned packages only. Pass --include-injected at the same time to list injected packages that were pinned.z--skip-maintenancez(deprecated) No-op)r  r   add_mutually_exclusive_group)r   r   rX   gs       r)   	_add_listr=    s    &@	 	 	A NNE  
 	
&&(ANN8L7YNZNN9\8MNNNN~  
 NN'CWNXr(   c                     U R                  SSSU/S9nUR                  SSSS9nUR                  SS	S	S
9  UR                  SSSS
9  UR                  SSSS
9  U$ )Nr   z*Interact with interpreters managed by pipxr  subcommandsz:Get help for commands with pipx interpreter COMMAND --helpr   )titler   r  r   zList available interpreters)r   r   r   zPrune unused interpretersr   zJUpgrade installed interpreters to the latest available micro/patch version)r  add_subparsers)r   r   rX   ss       r)   _add_interpreterrC    s     ",!6!69@	 "7 "A 	
P" 	 	A
 LL;IfLgLL:HcLdLLY`  
 Hr(   c           
      >   U R                  S[        S[        R                  " S[        R
                   S35      U/S9nUR                  SSSS	9  UR                  S
S[        R                  S/ S9  UR                  SSSS	9  UR                  SSSS	9  UR                  S[        S9  [        U5        [        U5        UR                  US9  [        R                  " SSUR                  5       5      Ul        [        R                  " SSUR                   5      Ul        g )Nr   zDownload the latest version of a package to a temporary virtual environment, then run an app from it. Also compatible with local `__pypackages__` directory (experimental).z
            Download the latest version of a package to a temporary virtual environment,
            then run an app from it. The environment will be cached
            and re-used for up to a   days. This
            means subsequent calls to 'run' for the same package will be faster
            since they can reuse the cached Virtual Environment.

            In support of PEP 582 'run' will use apps found in a local __pypackages__
            directory, if present. Please note that this behavior is experimental,
            and acts as a companion tool to pythonloc. It may be modified or
            removed in the future. See https://github.com/cs01/pythonloc.
            r5  z
--no-cacher   z4Do not reuse cached virtual environment if it existsr   r   zapp ...z5app/package name and any arguments to be passed to it)r  r  r   r	  z--pathz"Interpret app name as a local pathz--pypackagesz9Require app to be run from local __pypackages__ directoryz--specr   )	subparserz^usage: r  z\.\.\.)r  r:   rC   r6  r   #TEMP_VENV_EXPIRATION_THRESHOLD_DAYSr   argparse	REMAINDER	SPEC_HELPr   r   set_defaultsrerA   format_usageusager  s      r)   _add_runrN  &  s-   4( OO# $-#P#P"Q R
 - 	 	A0 NNC  
 NN  D   NN8L7[N\NNH  
 NN8)N,qaNNQN ff["ann&67AGffY	1773AGr(   c                     U R                  SSSU/S9nUUR                  SSS9l        UR                  S[        R                  / SS	9  g )
Nr   z7Run pip in an existing pipx-managed Virtual Environmentr  rv   zCName of the existing pipx-managed Virtual Environment to run pip inr   r   z#Arguments to forward to pip commandr"  )r  r   r  rG  rH  r  s       r)   _add_runpiprP  \  sk    FM	 	 	A ! NNR   NN  2	  r(   c                 p    U R                  SSSU/S9nUR                  SSSS9  UR                  S	S
SSS9  g )Nr   zVEnsure directories necessary for pipx operation are in your PATH environment variable.a   Ensure directory where pipx stores apps is in your PATH environment variable. Also if pipx was installed via `pip install --user`, ensure pipx itself is in your PATH. Note that running this may modify your shell's configuration file(s) such as '~/.bashrc'.r  z	--prependr   z{Prepend directories to your PATH instead of appending. This is useful if you want to prioritize pipx apps over system apps.r   r  r  zzAdd text to your shell's config file even if it looks like your PATH already contains paths to pipx and pipx-install apps.r#  r  s      r)   _add_ensurepathrR  o  sk    fF  	 	A NNS	   NNI  r(   c                     U R                  S[        S[        R                  " S5      [        R                  " SR                  [        5      SS9-   U/S9nUR                  SS	S
SS9  g )Nr   z=Print a list of environment variables and paths used by pipx.a  
            Prints the names and current values of environment variables used by pipx,
            followed by internal pipx variables which are derived from the environment
            variables and platform specific default values.

            Available variables:
            z, F)break_long_wordsr5  z--valuez-VVARIABLEz Print the value of the variable.)r  r   )r  r:   rC   r6  fillr   r   r   r  s      r)   _add_environmentrW    so    4LOO
 --		"785
Q	R  	 	A  NN9dJ=_N`r(   c                  r   [        [        R                  R                  5      n [	        U 5      n[
        R                  " SS9nUR                  SSSSSS9  UR                  S	S
SSSS9  [        R                  (       d  UR                  SSSSS9  [
        R                  " [        5       [        [        U/S9n[        R                  5       S   Ul        UR                  SSS9n0 n[!        XB5        [#        XB5        [%        XAR&                  U5        [)        XAR&                  U5        [+        XAR&                  U5        [-        XAR&                  U5        [/        XAR&                  U5        [1        XB5        [3        XB5        [5        XAR&                  U5        [7        XB5        [9        XAR&                  U5        [;        XB5        [=        XB5        [?        XB5      US'   [A        XB5        [C        XAR&                  U5        [E        XB5        [G        XB5        UR                  SSSS9  URI                  SSSU/S9  X54$ )NF)add_helpz--quietz-qcountr   z~Give less output. May be used multiple times corresponding to the ERROR and CRITICAL logging levels. The count maxes out at 2.)r   r	  r   z	--verbosez-vzGive more output. May be used multiple times corresponding to the INFO, DEBUG and NOTSET logging levels. The count maxes out at 3.z--globalr   	is_globalz&Perform action globally for all users.)r   r  r   )r4   r   r   r  r   r   z.Get help for commands with pipx COMMAND --help)r  r   r   z	--versionzPrint version and exitr   r   z9Print instructions on enabling shell completions for pipxr  )%r    r   r   r   rP   rG  ArgumentParserr   r   r   r5   r:   PIPX_DESCRIPTION
splitlinesman_short_descriptionrA  r  r  r  ra   r  r$  r&  r*  r-  r/  r1  r3  r7  r9  r=  rC  rN  rP  rR  rW  r  )rR   completer_venvsr   r   r   subparsers_with_subcommandss         r)   get_command_parserrb    s   "599??3N-n=O++U;ML  	 P  	 ""9	 	# 	
 $$[4$	F $4#>#>#@#CF &&ICs&tJ"$+Z/*11=A
//?Z,,m<z..>00-@Z/
2:22MBz1:22MBz1j(1A*1\.Z'
//?J.Z/
L?WXHO	   ..r(   	file_listkeep_numberc                     [        U 5      n [        U 5      U:  a  U S U*   H  n UR                  5         M     g g ! [         a     M'  f = fr$   )rT   r_   unlinkFileNotFoundError)rc  rd  existing_files      r)   delete_oldest_logsri    sU    y!I
9~#&}5M$$& 6 $ % s   ;
A	A	pipx_log_dirc                    SnU =(       d    [         R                  R                  n U R                  SSS9  [	        [        U R                  S5      5      U5        [	        [        U R                  S5      5      U5        [        R                  " S5      nU SU S3-  nS	nUR                  5       (       a4  US:  a.  U SU S
U S3-  nUS	-  nUR                  5       (       a  US:  a  M.  UR                  5         U$ )N
   T)r  exist_okzcmd_*[0-9].logzcmd_*_pip_errors.logz%Y-%m-%d_%H.%M.%Scmd_z.logr   _)r   r   logsr   ri  r   globtimestrftimeexiststouch)rj  max_logsdatetime_strlog_filecounters        r)   _setup_log_filerz    s    H1599>>Ltd3tL--.>?@(KtL--.DEFQ==!45L\N$77HG
//

"Day"EE1 //

" NNOr(   c                  v     [        5       $ ! [         a"    [        [        R                  " S5      5      s $ f = f)Nr,   )rz  PermissionErrorplatformdirsuser_log_pathr'   r(   r)   setup_log_filer    s8    C   C|99&ABBCs   	 )88r   c           	          [         R                  R                  5       (       a  [        [	        S5      5      OSn[        5       [        R                  l        [        [        S[        R                  SU -  -
  5      S5      n[        R                  " U5      nSSSSS	.SUS
-   SS	.SSSS	.S.SU (       a  SOSUS.SS[        [        R                  R                  5      SSS.S.SSS/SS.0SS.n[        R                  R!                  U5        g )Nzpipx >r   rl  2   r   zlogging.Formatterz	{message}{)classformatstylez ({funcName}:{lineno}): {message}z;{relativeCreated: >8.1f}ms ({funcName}:{lineno}): {message})stream_nonverbosestream_verboser  zlogging.StreamHandlerr  r  )r  	formatterlevelzlogging.FileHandlerr  zutf-8DEBUG)r  r  filenameencodingr  )streamr  r,   r  )handlersr  F)r!   
formattersr  loggersincremental)r0   stdoutisattyr   r   r  r   r   rx  minmaxloggingWARNINGgetLevelNamerL   config
dictConfig)r   pipx_strlevel_numberr  logging_configs        r)   setup_loggingr    s   (+

(9(9(;(;tE(O$H')EII s1gooW<=rBL  .E  -%" -"%GG -W
& 118->Q /#		 2 23# 
 (F);gNOE#NH NNn-r(   c           	         SU ;   a1  U R                   (       a   [        5         [        R                  " S5        [        R
                  (       d/  U R                  (       a  [        R                  R                  5         U R                  U R                  -
  n[        U5        [        R                  [        R                   " S5       5        [        R                  SR#                  [        R$                  5       5        [        R'                  S[(         35        [        R'                  S[*         S35        [-        [        R                  R.                  5        [-        [        R                  R0                  5        [-        [        R                  R2                  5        [-        [        R                  R4                  5        [-        [        R                  R6                  5        [        R                  R4                  [        R                  R6                  4 H\  nUS-  nUR9                  5       (       a  M  [        R                  S	5        S
n[;        US5       nUR=                  U5        S S S 5        M^     [?        [        R                  R@                  S5        [        R                  R.                  S-  nUR9                  5       (       a*  [        RC                  [E        S[F         SU< S3SS95        g g ! , (       d  f       M  = f)Nr!   r   z%Y-%m-%d %H:%M:%Sr?   zpipx version is zDefault python interpreter is 'rh   zCACHEDIR.TAGz&Adding CACHEDIR.TAG to cache directoryzSignature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by pipx.
# For information about cache directory tags, see:
#       https://bford.info/cachedir/
wFzpipx-appz
                zA  A virtual environment for pipx was detected at
                z. The 'pipx-app' package has been
                renamed back to 'pipx'
                (https://github.com/pypa/pipx/issues/82).
                r   r   )$r!   r*   r0   exitr   r   r[  r   r   make_globalr   quietr  r   r   rr  rs  r   r1   r   r&   r   r   r   r   r   
venv_cachestandalone_python_cachedirrt  openwriter   trashwarningr   r   )r   r   cachedircachedir_tag	signaturer  old_pipx_venv_locations          r)   setupr  H  s	   DT\\		llTZZ'G'
LLDMM"5679
LLCHHSXX&')
KK";-01
KK1.1ACD	%))//	%))

	%))

	%))

	%))
.
./ 					,,  .0""$$LLAB9  lC(D

9% )(  
%))//5!"YY__z9$$&& '* + #*
	
 ' )(s   K::
L		parsed_pipx_argsc                     U R                   S:X  am  U R                  (       a.  U R                  S   S:X  a  U R                  R                  S5        U R                  (       d  U R                  R	                  S5        g g g )Nr   r   z--z)the following arguments are required: app)r   r   poprE  error)r  s    r)   
check_argsr    sm    5( )).>.L.LQ.OSW.W**..q1  --&&,,-XY . )r(   c                  r    [        5         [        5       u  p[        R                  " U 5        U R	                  5       n[        U5        [        U5        UR                  (       d:  U R                  5         [        S5      [        R                  S5        [        5         $ [        X!5      [        R                  S5        [        5         $ ! [         al  n[        [!        U5      ["        R$                  S9  [        R                  SU 3SS9  [        S5      s SnA[        R                  S5        [        5         $ SnAf[&         a-    [        S5      s [        R                  S5        [        5         $ [(         a    [        R                  SSS9  e f = f! [        R                  S5        [        5         f = f)	zEntry point from command liner   zpipx finished.)r  zPipxError: Tr   Nr   )r   rb  argcompleteautocomplete
parse_argsr  r  r   r   r   r   r   r   r   r   r%   rL   r0   stderrKeyboardInterruptr3   )r   r   r  r   s       r)   clir    sI   /1  (!,,.#$''A; 	%&   0= 	%&  c!f3::&{1#&6{ 	%&  {
 	%&  *T: 	%&sC   A=C	 
C	 	
FAD:FF :FF 3FF !F6__main__)r"   N)Tr$   )~__doc__rG  r  logging.configr-   rK  rm   r0   rC   rr  urllib.parsery   pathlibr   typingr   r   r   r   r   r	   r  r}  packaging.utilsr
   r,   r   r   r   pipx.animater   r   pipx.colorsr   r   pipx.commands.environmentr   pipx.constantsr   r   r   r   r   pipx.emojisr   pipx.interpreterr   r   r   	pipx.utilr   r   r   r   	pipx.venvr    pipx.versionr!   r&   	getLoggerrH   r   rL   VenvCompleterr*   r5   r6  rI  r   r   r   r   r]  getenvDOC_DEFAULT_PYTHONDEFAULT_PIPX_MAN_DIRDEFAULT_PIPX_HOMEDEFAULT_PIPX_GLOBAL_HOMEDEFAULT_PIPX_BIN_DIRDEFAULT_PIPX_GLOBAL_BIN_DIRDEFAULT_PIPX_GLOBAL_MAN_DIRr  RawDescriptionHelpFormatterr:   rP   rp   ru   r   r   r   	Namespacer\  r   r   r   r   _SubParsersActionr  r  r  r  r$  r&  r*  r-  r/  r1  r3  r7  r9  r=  rC  rN  rP  rR  rW  rb  rM   ri  rz  r  r  r  r  r  r  r'   r(   r)   <module>r     s   )    	 	  
     = =   - + + 1 # ;   
 9 8 # /			8	$#S	)*	3 	 OO	 ??	% &+YY__$7 8$$)II$5$5#8 9,,1II,=,=+@ A
  I   " YY9>J oo	 ))* +'$ (-'>'>&? @ ../ 0! "'!;!; < = 	))* +* +0*D*D)E F 112 3  Y.0 f*8#G#G *p pd38n c "tCH~ $s) C d d 	
S 	
U;8-- U;4XE\E\@\;] U;bj U;ph55 $ &jX%<%< j jx66 4 $!X77 !H_H_ !dh !H!;!; HLcLc hl &2M 2(JaJa 2fj 2jm HLcLc . xG^G^ cg 0A= AI`I` Aei A] 8KbKb gk 8!;!; HLcLc hl *
H$>$> 
xOfOf 
ko 
9} 9XMdMd 9im 98#=#= hNeNe jn } XMdMd im (P8#=#= PhNeNe Pjn P,Y(44 YXE\E\ Yae Y.**;C;R;R03433 34HD[D[ 34`d 34lM (JaJa fj & : : 8KbKb gk @a!;!; aHLcLc ahl a(K/E("9"94XE\E\@\;]"]^ K/\$t* 3 4 (4. D *C C..3 ..4 ..b5
"" 5
t 5
p	Z!3!3 	Z 	ZX 6 zHHSUO r(   