4z+3@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<dnd Zd Zdod Z e dod Z e dodZ dpdZ e dodZejfdqdZdrdZdsdZdsdtdZdudZdsd Zdud!Zdud"Zdvd#Zdwd'Zdxdyd,Ze dzd{d/Ze dzd|d1Z dzd}d3Zd~d4Zdd6Zdrd7Z ddd=Z!dddAZ"e dddJZ#e dddNZ# dddQZ# dddSZ$e dddWZ%e dddYZ% dddZZ% ddd^Z&e dddfZ'e dddgZ' dddhZ' dddmZ(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||_|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_options_dry_runverboseforcehelp finalized)selfr$rs k/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py__init__zCommand.__init__Ks 0/////$ -- DBCC C >W $ $=>> >  !!! |   c|dkr,t|d|z}|t|j|S|St|)Ndry_run_)getattrr-AttributeError)r4attrmyvals r5 __getattr__zCommand.__getattr__{sK 9  D#*--E}t0$777  && &r7cJ|js|d|_dS)NT)r3finalize_optionsr4s r5ensure_finalizedzCommand.ensure_finalizeds)~ $  ! ! # # #r7c2td|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+rBs r5r.zCommand.initialize_options& I4> I I I   r7c2td|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. rErFrGrBs r5rAzCommand.finalize_optionss& I4> I I I   r7Nc|ddlm}|d|d}|||ztj|dz}|jD]j\}}}||}|ddkr |dd}t||}|||d |ztjkdS) Nr) longopt_xlatezcommand options for 'z':)levelz =z = ) distutils.fancy_getoptrLget_command_nameannounceloggingINFOr# translater;)r4headerindentrLoptionr:values r5 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 Nr7c2td|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. rErFrGrBs r5runz Command.runrHr7msgobjectrMintc0tj||dSNr)r4r]rMs r5rRzCommand.announces sr7ctddlm}|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.debugrcprintsysstdoutflush)r4r]rcs r5 debug_printzCommand.debug_printsM *)))))   #JJJ J         r7c t||}|t||||St|tst d|d|d|d|S)N'z ' must be a z (got `z`))r;setattrr)strr)r4rXwhatdefaultvals r5_ensure_stringlikezCommand._ensure_stringlikesodF## ; D&' * * *NC%% U&'S6'S'St'S'SC'S'S'STT T r7rXrmro str | Nonec4||d|dS)zWEnsure that 'option' is a string; if not defined, set it to 'default'. stringN)rq)r4rXros r5 ensure_stringzCommand.ensure_strings" ':::::r7c6t||}|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|tVdSra)r)rm).0vs r5 z-Command.ensure_string_list.. s,99As++999999r7Frkz!' must be a list of strings (got )) r;r)rmrlresplitlistallr)r4rXrpoks r5ensure_string_listzCommand.ensure_string_lists dF## ; F S ! !  D&"(;"<"< = = = = =#t$$ 99S99999 *IIIIII  r7c||||}|"||std|z||fzdSdS)Nzerror in '%s' option: )rqr)r4rXtesterrn error_fmtrorps r5_ensure_tested_stringzCommand._ensure_tested_stringsX%%fdG<< ?66#;;?&)I5&#F  ???r7cT||tjjdddS)z5Ensure that 'option' is the name of an existing file.filenamez$'%s' does not exist or is not a fileN)rospathisfiler4rXs r5ensure_filenamezCommand.ensure_filenames2 "" BGNJ0V     r7cT||tjjdddS)Nzdirectory namez)'%s' does not exist or is not a directory)rrrisdirrs r5ensure_dirnamezCommand.ensure_dirnames4 ""  GM  7      r7cHt|dr|jS|jjS)N command_name)hasattrrr+__name__rBs r5rQzCommand.get_command_name(s( 4 ( ( +$ $>* *r7src_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_objrCr;rl)r4rr src_cmd_obj src_option dst_options r5set_undefined_optionszCommand.set_undefined_options.s{"'77@@ $$&&&&2 L L "J tZ((0j'+z*J*JKKK L Lr7Tcommandcreateboolcd|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-rrC)r4rrcmd_objs r5get_finalized_commandzCommand.get_finalized_commandGs3 #33GVDD  """r7Freinit_subcommandscdSrar4rrs r5reinitialize_commandzCommand.reinitialize_commandSs #r7rcdSrarrs r5rzCommand.reinitialize_commandWs Cr7 str | Commandc8|j||Sra)r-rrs r5rzCommand.reinitialize_command[s 55g?QRRRr7c:|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)r4rs r5rzCommand.run_command`s! %%g.....r7 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)r4commandscmd_namemethods r5get_sub_commandszCommand.get_sub_commandsgsI $ 1 * * Hf~~)))r7cVtjd||dS)Nzwarning: %s: %s )rwarningrQ)r4r]s r5warnz Command.warnvs) ')>)>)@)@#FFFFFr7r funcCallable[[Unpack[_Ts]], object]argstuple[Unpack[_Ts]]c@tj||||jdSNr9)rexecuter9)r4rrr]rMs r5rzCommand.executeys% T4dl;;;;;;r7namemodec>tj|||jdSr)rmkpathr9)r4rrs r5rzCommand.mkpaths!dDL999999r7infileroutfiler preserve_modepreserve_timeslinktuple[_StrPathT | str, bool]cdSrarr4rrrrrrMs r5 copy_filezCommand.copy_files (+sr7rr tuple[_BytesPathT | bytes, bool]cdSrarrs r5rzCommand.copy_files ,/3r73str | os.PathLike[str] | bytes | os.PathLike[bytes]@tuple[str | os.PathLike[str] | bytes | os.PathLike[bytes], bool]c Ntj|||||j ||jS)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.)r)rrr1r9rs r5rzCommand.copy_files9"     N L    r7preserve_symlinksc Ntj||||||j |jS)z\Copy an entire directory tree respecting verbose, dry-run, and force flags. r)r copy_treer1r9)r4rrrrrrMs r5rzCommand.copy_trees9!      NL    r7srcdst_StrPathT | strcdSrarr4rrrMs r5 move_filezCommand.move_files #r7_BytesPathT | bytescdSrarrs r5rzCommand.move_files "cr7c:tj|||jS)z$Move a file respecting dry-run flag.r)rrr9rs r5rzCommand.move_files"3T\BBBBr7cmdMutableSequence[str] search_pathc8ddlm}||||jdS)z2Spawn an external command respecting dry-run flag.r)spawnrN)distutils.spawnrr9)r4rrrMrs r5rz Command.spawns5 *))))) c; 555555r7 base_nameformatroot_dir:str | os.PathLike[str] | bytes | os.PathLike[bytes] | Nonebase_dirownergroupcdSrarr4rrrrrrs r5 make_archivezCommand.make_archive cr7cdSrarrs r5rzCommand.make_archiverr7c Btj|||||j||S)N)r9rr)rrr9rs r5rzCommand.make_archives5(    L    r7infiles!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)rmr~tupler*rjoinr1r newer_grouprrdebug)r4rrrrrrrMs r5 make_filezCommand.make_files$  ?7???H gs # # YjGGGdE]33 YWXX X  .55gtyy?Q?QRRH : .w@@ LLtXu 5 5 5 5 5 Ih     r7)r$rr%r&)r%r&)NrJ)r]r^rMr_r%r&)r]r^r%r&ra)rXrmrorrr%r&)rXrmr%r&)r%rm)rrmrrr%r&)T)rrmrrr%r )F)rrmrrr%r )rrrrr%r)rrr%r )rrmr%r&)r%r)Nr ) rrrrr]r^rMr_r%r&)r)rrmrr_r%r&)TTNr )rrrrrrrrrrrrMr_r%r)rrrrrrrrrrrrMr_r%r)rrrrrrrrrrrrMr_r%r)TTFr )rrrrmrrrrrrrMr_r%r)r )rrrrrMr_r%r)rrrrrMr_r%r)rrrrrMr_r%r)Tr )rrrrrMr_r%r&)NNNN)rrmrrmrrrrrrrrrrrr%rm)NNN)rrrrmrrrrrrrrrrrr%rm)rrrrmrrrrrrrrrrrr%rm)NNr )rrrrrrrrrr^rr^rMr_r%r&))r __module__ __qualname____doc__r"__annotations__r#r6r?rCrr.rArZr\rSrcrRrirqrurrrrrQrrr rrrrrrrrrrrrrr7r5r r "s  >          ----`'''$    ^      ^   N N N N    ^  29.;;;;; *        ++++ LLLL27<X=BX:?SSSSS ////    GGGG <<<<<::::: ##++++X+ ##////X/##     4##"'     ,HIXNO""""X" CCCCCQR66666 PT#  X $  XPT#       2 % % % % % % % r7)&r __future__rrSrr|rfabcrcollections.abcrrtypingrrr r r rJr rrrr_logrerrorsrr(rtyping_extensionsrrrrrrr rr7r5rs #""""" 55555555BBBBBBBBBBBBBB@@@@@@@@@@@@@@((((((++++++66666666 ,u  C GK'? @ @ @ gm+GHHH GKy 1 1 1 H H H H H H H H H H r7