1j`S@dZddlmZddlZddlZddlZddlZddlmZddl m Z m Z ddl m Z mZmZmZmZddlmZmZmZmZmZdd lmZdd lmZe rdd lmZdd lmZm Z ed Z!eddZ"eddZ#eddZ$GddZ%dS)ztdistutils.cmd Provides the Command class, the base class for the command classes in the distutils.command package. ) annotationsN)abstractmethod)CallableMutableSequence) TYPE_CHECKINGAnyClassVarTypeVaroverload) _modified archive_utildir_util file_utilutillog)DistutilsOptionError Distribution) TypeVarTupleUnpack_Ts _StrPathTstr | os.PathLike[str])bound _BytesPathTbytes | os.PathLike[bytes] _CommandTCommandceZdZUdZgZded<gZded<dmd Zdnd Ze dnd Z e dnd Z dodZ e dndZ ejfdpdZdqdZdrdZdrdsdZdtdZdrdZdtd Zdtd!Zdud"Zdvd&Zdwdxd+Ze dydzd.Ze dyd{d0Z dyd|d2Zd}d3Zd~d5Zdqd6Z ddd<Z ddd@Z!e dddIZ"e dddMZ" dddPZ" dddRZ#e dddVZ$e dddXZ$ dddYZ$ ddd]Z%e dddeZ&e dddfZ& dddgZ& dddlZ'dS)r a}Abstract base class for defining command classes, the "worker bees" of the Distutils. A useful analogy for command classes is to think of them as subroutines with local variables called "options". The options are "declared" in 'initialize_options()' and "defined" (given their final values, aka "finalized") in 'finalize_options()', both of which must be defined by every command class. The distinction between the two is necessary because option values might come from the outside world (command line, config file, ...), and any options dependent on other options must be computed *after* these outside influences have been processed -- hence 'finalize_options()'. The "body" of the subroutine, where it does all its work based on the values of its options, is the 'run()' method, which must also be implemented by every command class. z8ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] sub_commandszHClassVar[list[tuple[str, str, str]] | list[tuple[str, str | None, str]]] user_optionsdistrreturnNonecddlm}t||std|jt urt d||_||j |_ d|_ d|_ d|_ dS)zCreate and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. rrz$dist must be a Distribution instancezCommand is an abstract classNF) distutils.distr isinstance TypeError __class__r RuntimeError distributioninitialize_optionsverboseforcehelp finalized)selfr$rs P/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/cmd.py__init__zCommand.__init__Ks 0/////$ -- DBCC C >W $ $=>> >  !!!|   cJ|js|d|_dS)NT)r2finalize_optionsr3s r4ensure_finalizedzCommand.ensure_finalizedus)~ $  ! ! # # #r6c2td|jd)aSet default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, 'initialize_options()' implementations are just a bunch of "self.foo = None" assignments. This method must be implemented by all command classes. abstract method -- subclass  must overrider,r+r9s r4r.zCommand.initialize_options& I4> I I I   r6c2td|jd)aSet final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if 'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as long as 'foo' still has the same value it was assigned in 'initialize_options()'. This method must be implemented by all command classes. r<r=r>r9s r4r8zCommand.finalize_optionss& I4> I I I   r6Nc|ddlm}|d|d}|||ztj|dz}|jD]j\}}}||}|ddkr |dd}t||}|||d |ztjkdS) Nr) longopt_xlatezcommand options for 'z':)levelz =z = ) distutils.fancy_getoptrCget_command_nameannounceloggingINFOr# translategetattr)r3headerindentrCoption_values r4 dump_optionszCommand.dump_optionss888888 >HT-B-B-D-DHHHF fvoW\ :::$ - N NLFAq%%m44FbzS  D&))E MM&f#8#8#8#88 M M M M M  N Nr6c2td|jd)aA command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'. All terminal output and filesystem interaction should be done by 'run()'. This method must be implemented by all command classes. r<r=r>r9s r4runz Command.runr?r6msgobjectrDintc0tj||dSNr)r3rVrDs r4rIzCommand.announces sr6ctddlm}|r/t|tjdSdS)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)DEBUGN)distutils.debugr\printsysstdoutflush)r3rVr\s r4 debug_printzCommand.debug_printsM *)))))   #JJJ J         r6c t||}|t||||St|tst d|d|d|d|S)N'z ' must be a z (got `z`))rMsetattrr)strr)r3rPwhatdefaultvals r4_ensure_stringlikezCommand._ensure_stringlikesodF## ; D&' * * *NC%% U&'S6'S'St'S'SC'S'S'STT T r6rPrfrh str | Nonec4||d|dS)zWEnsure that 'option' is a string; if not defined, set it to 'default'. stringN)rj)r3rPrhs r4 ensure_stringzCommand.ensure_strings" ':::::r6c6t||}|dSt|tr&t||t jd|dSt|t rtd|D}nd}|std|d|ddS)zEnsure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"]. Nz,\s*|\s+c3@K|]}t|tVdSrZ)r)rf).0vs r4 z-Command.ensure_string_list..s,99As++999999r6Frdz!' must be a list of strings (got )) rMr)rfreresplitlistallr)r3rPrioks r4ensure_string_listzCommand.ensure_string_lists dF## ; F S ! !  D&"(;"<"< = = = = =#t$$ 99S99999 *IIIIII  r6c||||}|"||std|z||fzdSdS)Nzerror in '%s' option: )rjr)r3rPtesterrg error_fmtrhris r4_ensure_tested_stringzCommand._ensure_tested_stringsX%%fdG<< ?66#;;?&)I5&#F  ???r6cT||tjjdddS)z5Ensure that 'option' is the name of an existing file.filenamez$'%s' does not exist or is not a fileN)r~ospathisfiler3rPs r4ensure_filenamezCommand.ensure_filenames2 "" BGNJ0V     r6cT||tjjdddS)Nzdirectory namez)'%s' does not exist or is not a directory)r~rrisdirrs r4ensure_dirnamezCommand.ensure_dirnames4 ""  GM  7      r6cHt|dr|jS|jjS)N command_name)hasattrrr+__name__r9s r4rHzCommand.get_command_names( 4 ( ( +$ $>* *r6src_cmd option_pairstuple[str, str]c |j|}||D]4\}}t||t ||t||5dS)a>Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'. Usually called from 'finalize_options()' for options that depend on some other command rather than another option of the same command. 'src_cmd' is the other command from which option values will be taken (a command object will be created for it if necessary); the remaining arguments are '(src_option,dst_option)' tuples which mean "take the value of 'src_option' in the 'src_cmd' command object, and copy it to 'dst_option' in the current command object". N)r-get_command_objr:rMre)r3rr src_cmd_obj src_option dst_options r4set_undefined_optionszCommand.set_undefined_optionss{"'77@@ $$&&&&2 L L "J tZ((0j'+z*J*JKKK L Lr6Tcommandcreateboolcd|j||}||S)zWrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object. )r-rr:)r3rrcmd_objs r4get_finalized_commandzCommand.get_finalized_command7s3 #33GVDD  """r6Freinit_subcommandscdSrZr3rrs r4reinitialize_commandzCommand.reinitialize_commandCs #r6rcdSrZrrs r4rzCommand.reinitialize_commandGs Cr6 str | Commandc8|j||SrZ)r-rrs r4rzCommand.reinitialize_commandKs 55g?QRRRr6c:|j|dS)zRun some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method. N)r- run_command)r3rs r4rzCommand.run_commandPs! %%g.....r6 list[str]chg}|jD]'\}}| ||r||(|S)akDetermine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution. Return a list of command names. )r"append)r3commandscmd_namemethods r4get_sub_commandszCommand.get_sub_commandsWsI $ 1 * * Hf~~)))r6cVtjd||dS)Nzwarning: %s: %s )rwarningrH)r3rVs r4warnz Command.warnfs) ')>)>)@)@#FFFFFr6r funcCallable[[Unpack[_Ts]], object]argstuple[Unpack[_Ts]]c2tj|||dSrZ)rexecute)r3rrrVrDs r4rzCommand.executeis T4%%%%%r6namemodec0tj||dSrZ)rmkpath)r3rrs r4rzCommand.mkpathrsd#####r6infileroutfiler preserve_modepreserve_timeslinktuple[_StrPathT | str, bool]cdSrZrr3rrrrrrDs r4 copy_filezCommand.copy_fileus (+sr6rr tuple[_BytesPathT | bytes, bool]cdSrZrrs r4rzCommand.copy_files ,/3r63str | os.PathLike[str] | bytes | os.PathLike[bytes]@tuple[str | os.PathLike[str] | bytes | os.PathLike[bytes], bool]c@tj|||||j |S)zCopy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.))rrr0rs r4rzCommand.copy_files/"     N     r6preserve_symlinksc@tj||||||j S)z\Copy an entire directory tree respecting verbose, dry-run, and force flags. )r copy_treer0)r3rrrrrrDs r4rzCommand.copy_trees/!      N    r6srcdst_StrPathT | strcdSrZrr3rrrDs r4 move_filezCommand.move_files #r6_BytesPathT | bytescdSrZrrs r4rzCommand.move_files "cr6c,tj||S)z$Move a file respecting dry-run flag.)rrrs r4rzCommand.move_files"3,,,r6cmdMutableSequence[str] search_pathc*ddlm}|||dS)z2Spawn an external command respecting dry-run flag.r)spawnN)distutils.spawnr)r3rrrDrs r4rz Command.spawns. *))))) c;r6 base_nameformatroot_dir:str | os.PathLike[str] | bytes | os.PathLike[bytes] | Nonebase_dirownergroupcdSrZrr3rrrrrrs r4 make_archivezCommand.make_archive cr6cdSrZrrs r4rzCommand.make_archiverr6c6tj||||||S)N)rr)rrrs r4rzCommand.make_archives0(         r6infiles!str | list[str] | tuple[str, ...]exec_msgskip_msgc|d|d}t|tr|f}n+t|ttfst d|)d|d|}|jstj ||r| ||||dStj |dS)aSpecial case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no timestamp checks. Nz skipping z (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating {} from {}z, ) r)rfrwtupler*rjoinr0r newer_grouprrdebug)r3rrrrrrrDs r4 make_filezCommand.make_files$  ?7???H gs # # YjGGGdE]33 YWXX X  .55gtyy?Q?QRRH : .w@@ LLtXu 5 5 5 5 5 Ih     r6)r$rr%r&)r%r&)NrA)rVrWrDrXr%r&)rVrWr%r&rZ)rPrfrhrkr%r&)rPrfr%r&)r%rf)rrfrrr%r&)T)rrfrrr%r )F)rrfrrr%r )rrrrr%r)rrr%r )rrfr%r&)r%r)Nr ) rrrrrVrWrDrXr%r&)r)rrfrrXr%r&)TTNr )rrrrrrrrrrkrDrXr%r)rrrrrrrrrrkrDrXr%r)rrrrrrrrrrkrDrXr%r)TTFr )rrrrfrrrrrrrDrXr%r)r )rrrrrDrXr%r)rrrrrDrXr%r)rrrrrDrXr%r)Tr )rrrrrDrXr%r&)NNNN)rrfrrfrrrrkrrkrrkr%rf)NNN)rrrrfrrrrkrrkrrkr%rf)rrrrfrrrrkrrkrrkr%rf)NNr )rrrrrrrrrrWrrWrDrXr%r&)(r __module__ __qualname____doc__r"__annotations__r#r5r:rr.r8rSrUrJr\rIrbrjrnrzr~rrrHrrr rrrrrrrrrrrrrr6r4r r "s  >          ((((T$    ^      ^   N N N N    ^  29.;;;;; *        ++++ LLLL27<X=BX:?SSSSS ////    GGGG &&&&&$$$$$ ##++++X+ ##////X/##     2##"'     *HIXNO""""X" -----QR      PT#  X $  XPT#       0 % % % % % % % r6)&r __future__rrJrrur_abcrcollections.abcrrtypingrrr r r rAr rrrr_logrerrorsrr(rtyping_extensionsrrrrrrr rr6r4rs #""""" 55555555BBBBBBBBBBBBBB@@@@@@@@@@@@@@((((((++++++66666666 ,u  C GK'? @ @ @ gm+GHHH GKy 1 1 1 u u u u u u u u u u r6