
    hl*                        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  S SKJ	r	  S SK
JrJrJr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  S SKJrJrJr  S S	KJr  S S
K J!r!  S SK"J#r#J$r$  S SK%J&r'  SSK(J)r)  SSK*J+r+  SSK,J-r-  SSK.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  Sr7Sr8Sr9Sr:Sr;Sr<S\9 S3r=Sr>Sr?Sr@\R                  rB\R                  rD\R                  " \;\<S9r&\R                  " S\?SS 9rF\R                  " S!\>SS 9rG\R                  " S"\@SS 9rH\&R                  \'S#\=SS 9  \&R                  \G5        \&R                  \F5        \&R                  \H5        SFS% jrJ\/R                  4S&\\L   S'\\L   S$\\L\4   4S( jjrMSGS&\\L   S*\NS$\\L\4   4S+ jjrOS,\S$\4S- jrP\ SHSS.SSS/.S0\\\L\	4      S1\\L   S2\LS3\\N   S4\N4
S5 jjj5       rQS6\\\	\L4      S$S4S7 jrR SIS8\LS$\\S\S4   4S9 jjrT\SJS,\LS:\+S)   S$\\L   4S; jj5       rU\S,\LS:\+S   S$\\S   4S< j5       rUSGS,\LS:\NS$\\\L   \\S   4   4S= jjrUSHS>\SS$S4S? jjrVSHS@\	SA\\L   S$\\	   4SB jjrWSKSC\\S\X4   SD\SS$\L4SE jjrYg)L    N)InterpolationError)contextmanager)Path)	TYPE_CHECKINGAnyDictIterableListOptionalTupleUnionoverload)NoSuchOption)split_arg_string)ConfigConfigValidationErrorrequire_gpu)gpu_is_available)get_command)Printermsg)app   )about)Literal)validate)ENV_VARSSimpleFrozenDictimport_fileis_compatible_versionloggermake_tempdirregistryrun_commandz.tar.gzz-py3-none-any.whlzproject.ymlzpython -m spacyspacyz=spaCy Command-line Interface

DOCS: https://spacy.io/api/cli
zCommand-line interface for spaCy projects and templates.
You'd typically start by cloning a project template to a local directory and
fetching its assets like datasets etc. See the project's z for the
available commands.
zSuite of helpful commands for debugging and profiling. Includes
commands to check and validate your config files, training and evaluation data,
and custom model implementations.
z$Commands for benchmarking pipelines.z8Commands for initializing configs and pipeline packages.)namehelp	benchmarkT)r&   r'   no_args_is_helpdebuginitprojectreturnc                  r    [         R                  R                  5         [        [        5      n U " [
        S9  g )N)	prog_name)r#   cliget_allr   r   COMMAND)commands    I/home/james-whalen/.local/lib/python3.13/site-packages/spacy/cli/_util.py	setup_clir5   R   s$    LL#Gg    argsenv_varc                 b   U(       a   [         R                  R                  US5      OSn[        [	        U5      5      n[        U SS9nU(       a0  U Vs/ s H  oUU;  d  M
  UPM     nn[
        R                  " SU5        U(       a   [
        R                  " S[        U5      5        0 UEUE$ s  snf )a  Generate a dictionary of config overrides based on the extra arguments
provided on the CLI, e.g. --training.batch_size to override
"training.batch_size". Arguments without a "." are considered invalid,
since the config only allows top-level sections to exist.

env_vars (Optional[str]): Optional environment variable to read from.
RETURNS (Dict[str, Any]): The parsed dict, keyed by nested config setting.
 T)is_clizConfig overrides from CLI: %sz'Config overrides from env variables: %s)osenvironget_parse_overridesr   r!   r*   list)r7   r8   
env_stringenv_overridescli_overrideskkeyss          r4   parse_config_overridesrF   Z   s     18,RJ$%5j%ABM$T$7M(C=a],B=C4d;>]@ST-m-}--	 Ds   	B, B,Fr;   c                    0 nU (       Ga  U R                  S5      nSU S3nUR                  S5      (       a  UnUR                  SS5      nSU;  a*  U(       a  [        U5      e[        R
                  " U S3SS	9  S
U;   a'  UR                  S
S5      u  p6UR                  SS5      nO4U (       a  U S   R                  S5      (       a  SnOU R                  S5      n[        U5      X#'   O[        R
                  " U S3SS	9  U (       a  GM  U$ )Nr   zInvalid config override ''z--r:   .z#: can't override top-level sections   exits=-_truez: name should start with --)pop
startswithreplacer   r   failsplit_parse_override)r7   r;   resultopterrorig_optvalues          r4   r?   r?   p   s    F
hhqk)#a0>>$H++dB'C#~&x00HHu$GHPQRcz YYsA.
kk#s+tAw11$77"E HHQKE)%0FKHHu78B+ $, Mr6   r[   c                 f     [         R                  " U 5      $ ! [         a    [        U 5      s $ f = fN)srsly
json_loads
ValueErrorstr)r[   s    r4   rV   rV      s1    && 5zs    00r:   )titledescshow_config	hint_fill	file_pathrb   rc   rd   re   c          	   #     #     Sv   g! [          Ga  nUb  UOUR                  nUR                  (       a%  U(       d  UR                   OUR                   SU 3nUR                  USX#S9n[        R
                  " U5        [        UR                  R                  5       5        U(       aS  SUR                  ;   aC  U b  [        U 5      S:w  a  U OSn[        R                  " SS	S
9  [        [         SU SU S35        [        R                  " S5         SnAgSnAf[         a   n[        R
                  " SUSS9   SnAgSnAff = f7f)aq  Helper to show custom config validation errors on the CLI.

file_path (str / Path): Optional file path of config file, used in hints.
title (str): Override title of custom formatted error.
desc (str): Override description of custom formatted error.
show_config (bool): Whether to output the config the error refers to.
hint_fill (bool): Show hint about filling config.
Nz

r:   )rb   rc   rd   zvalue_error.missingrN   z
config.cfgz|If your config contains missing values, you can run the 'init fill-config' command to fill in all the defaults, if possible:T)spacedz init fill-config  z 
rJ   zConfig validation errorrK   )r   rb   rc   
from_errorr   rT   printtextstriperror_typesra   r2   sysexitr   )rf   rb   rc   rd   re   erY   config_paths           r4   show_validation_errorrs      s    "8  *66&*affX166($tf0EDll1BTlKchhnn.#//A (S^s-B ! 
 HHQ
 WI/}Ak]#NO 8*AQ78s=   E
	 E
EDDE
E'E=E
EE
	code_pathc                     U bB  [        U 5      R                  5       (       d  [        R                  " SU SS9   [	        SU 5        gg! [
         a#  n[        R                  " SU  3USS9   SnAgSnAff = f)zHelper to import Python file provided in training commands / commands
using the config. This makes custom registered functions available.
NzPath to Python code not foundrJ   rK   python_codezCouldn't load Python code: )r   existsr   rT   r   	Exception)rt   rq   s     r4   import_codery      so     I%%''HH4iqI	Ly1	 
  	LHH29+>K	Ls   A 
A4A//A4errorc                 $    [        SSS9nUR                  R                  5       nU(       a  UR	                  S5      (       d  gUSS R                  5       R                  S5      n[        US	   5      [        US
   5      4$ !   [        U 5      e= f)zGet the version of git and raise an error if calling 'git --version' fails.
error (str): The error message to show.
RETURNS (Tuple[int, int]): The version as a (major, minor) tuple. Returns
    (0, 0) if the version couldn't be determined.
zgit --versionT)capturezgit version)r   r      NrI   r   rJ   )r$   RuntimeErrorstdoutrm   rR   rU   int)rz   retr   versions       r4   get_git_versionr      s    "/48 ZZF**=99RSk!'',Gwqz?C
O++"5!!s   
B Bintifyc                     g r]    r[   r   s     r4   string_to_listr          r6   c                     g r]   r   r   s     r4   r   r      r   r6   c                    U (       d  / $ U R                  S5      (       a  U R                  S5      (       a  U SS n / nU R                  S5       H  nUR                  5       nUR                  S5      (       a  UR                  S5      (       a  USS nUR                  S5      (       a  UR                  S5      (       a  USS nUR                  5       nU(       a  [	        U5      nUR                  U5        M     U$ )a;  Parse a comma-separated string to a list and account for various
formatting options. Mostly used to handle CLI arguments that take a list of
comma-separated values.

value (str): The value to parse.
intify (bool): Whether to convert values to ints.
RETURNS (Union[List[str], List[int]]): A list of strings or ints.
[]rJ   ,rH   ")rR   endswithrU   rm   r   append)r[   r   rW   ps       r4   r   r      s     	!4!4aF[[GGI<<C!BA<<C!BAGGIAAa  Mr6   use_gpuc                     Uc  [        5       nO[        X(       + S9nU S:  a   UR                  SU  35        [        U 5        gUR                  S5        [        5       (       a  UR                  S5        gg)zConfigure the GPU and log info.N)no_printprettyr   zUsing GPU: z	Using CPUz.To switch to GPU 0, use the option: --gpu-id 0)r   infor   r   )r   silent	local_msgs      r4   	setup_gpur     sc    ~I	VJ?	!|WI./G{#NNKL r6   pathsuffixc                    U R                  5       (       d  U /$ U /n/ n[        5       nU H  n [        U 5      U;   a  M  UR                  [        U 5      5        U R                  S   R                  S5      (       a  MS  U R                  5       (       a!  UR                  U R                  5       5        M  Ub%  U R                  S   R                  U5      (       d  M  UR                  U 5        M     UR                  5         U$ )a  Given a directory and a suffix, recursively find all files matching the suffix.
Directories or files with names beginning with a . are ignored, but hidden flags on
filesystems are not checked.
When provided with a suffix `None`, there is no suffix-based filtering.r   rI   )is_dirsetra   addpartsrR   extenditerdirr   r   sort)r   r   pathslocsseens        r4   walk_directoryr     s    
 ;;==vFED5Dt9T::b>$$S))[[]]LL(

2(?(?(G(GKK  	IIKKr6   numberndigitsc                 R    [        U [        5      (       a  U SU S3 $ [        U 5      $ )zFormats a number (float or int) rounding to `ndigits`, without truncating trailing 0s,
as happens with `round(number, ndigits)`rI   f)
isinstancefloatra   )r   r   s     r4   _format_numberr   2  s.     &%  7)1%&6{r6   )r-   N)Fr]   )zNCould not run 'git'. Make sure it's installed and the executable is available.).)r   )Zhashlibr<   shutilro   configparserr   
contextlibr   pathlibr   typingr   r   r   r	   r
   r   r   r   r   r^   typerclickr   click.parserr   	thinc.apir   r   r   
thinc.utilr   
typer.mainr   wasabir   r   weaselr   project_clir:   r   compatr   schemasr   utilr   r   r   r    r!   r"   r#   r$   SDIST_SUFFIXWHEEL_SUFFIXPROJECT_FILEr2   NAMEHELPPROJECT_HELP
DEBUG_HELPBENCHMARK_HELP	INIT_HELPArgumentArgOptionOptTyperbenchmark_cli	debug_cliinit_cli	add_typerr5   CONFIG_OVERRIDESra   rF   boolr?   rV   rs   ry   r   r   r   r   r   r   r   r   r6   r4   <module>r      sW    	  
 + % 
 
 
    ) @ @ ' "  %   	 	 	 "
::F H

 <J	 nnllkkt$'>SWXKKW:tL	;;FDI k	d S i  m  h  /7.G.G.
s).&sm.	#s(^.,49 d tCH~ 6	3 	3 	 ,0(8  "&(8c4i()(8 C=(8 	(8
 $(8 (8 (8V
L8E$)$45 
L$ 
L b,,
38_,& 
# wu~ S	  
 
# wt} c  
# t d3ic>R8S 6Ms MD M x} T
 65e, s 3 r6   