VULN_CHECK_I913V6 SSh@rdZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z ddl mZGdd eZy) zHdistutils.command.build_py Implements the Distutils 'build_py' command.N)Command)DistutilsOptionErrorDistutilsFileError) convert_path)logceZdZdZgdZddgZddiZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZddZdZdZdZdZy)build_pyz5"build" pure Python modules (copy to build directory)))z build-lib=dzdirectory to "build" (copy) to)compileczcompile .py to .pyc) no-compileNz!don't compile .py files [default])z optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])forcefz2forcibly build everything (ignore file timestamps)r rrctd|_d|_d|_d|_d|_d|_d|_d|_y)Nr) build_lib py_modulespackage package_data package_dirr optimizerselfs K/usr/lib/python3.12/site-packages/setuptools/_distutils/command/build_py.pyinitialize_optionszbuild_py.initialize_options#s<     c|jddd|jj|_|jj|_|jj|_i|_|jj rD|jj j D]\}}t||j |<|j|_ t|jts6 t|j|_ d|jcxkrdksJJyy#ttf$r tdwxYw)Nbuild)rr)rrrrzoptimize must be 0, 1, or 2)set_undefined_options distributionpackagesrrritemsrget_data_files data_files isinstancerint ValueErrorAssertionErrorr)rnamepaths rfinalize_optionszbuild_py.finalize_options-s! "" /1C ))22 ++66 --::    ( ("//;;AAC d)5d);  &D--/$--- J #DMM 2 DMM.Q....../ J*+HII Js 64D,,Ec|jr|j|jr |j|j |j |j dy)Nr)include_bytecode)r build_modulesr"build_packagesbuild_package_data byte_compile get_outputsrs rrunz build_py.runFsR, ??    ==    !  # # % $**A*>?rcxg}|js|S|jD]}|j|}tjj|j g|j dz}d}|rt|dz}|j||Dcgc]}||d }}|j||||f|Scc}w)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples.rN) r"get_package_dirosr+joinrsplitlenfind_data_filesappend)rdatarsrc_dir build_dirplenfile filenamess rr$zbuild_py.get_data_filesds}}K}}G**73G '7'--:L'LNID7|a'261E1Egw1WX1Wde1WIX KK'9i@ A% Ys B7c |jjdg|jj|gz}g}|D]}tjtjj tj |t|}|j|Dcgc])}||vstjj|s(|+c}|Scc}w)z6Return filenames for package's data files in 'src_dir') rgetglobr9r+r:escaperextendisfile)rrr@globsfilespatternfilelistfns rr=zbuild_py.find_data_fileszs!!%%b"-0A0A0E0Egr0RRGyy T[[1<3HIH LL&Qh"E/bggnnR>PhQ   Rs C )C C c>|jD]\}}}}|D]}tjj||}|j tjj ||j tjj|||dy)z$Copy data files into build directoryF preserve_modeN)r%r9r+r:mkpathdirname copy_file)rrr@rArDfilenametargets rr1zbuild_py.build_package_datasx6:oo 2GWi%i: BGGOOF34GGLL(3V5&7Frc|jd}|js|rtjj|Syg}|rM |jdj |}|j d|tjj|S|jjd}||j d||rtjj|Sy#t $r|j d|d|d=YnwxYw|rŌy)zReturn the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).r6rFr)r;rr9r+r:insertKeyErrorrG)rrr+tailpdirs rr8zbuild_py.get_package_dirs}}S!ww||T**D/++CHHTN;D KK4(77<<..''++B/#KK4(77<<..+ !KK48,R!sC!D?DcH|dk7rZtjj|std|ztjj |std|z|rAtjj |d}tjj |r|Sy)NrFz%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz __init__.py)r9r+existsrisdirr:rK)rrrinit_pys r check_packagezbuild_py.check_packages " 77>>+.(;kI77==-(-/:; ggll; >Gww~~g&rcrtjj|stjd||yy)Nz!file %s (for module %s) not foundFT)r9r+rKrwarning)rmodule module_files r check_modulezbuild_py.check_modules)ww~~k* KK;[& QrcF|j||tjtjj tj |d}g}tjj |jj}|D]}tjj |}||k7rTtjjtjj|d}|j|||f{|jd|z|S)Nz*.pyrz excluding %s) rcrHr9r+r:rIabspathr! script_namesplitextbasenamer> debug_print) rrr module_filesmodules setup_scriptrabs_frfs rfind_package_moduleszbuild_py.find_package_moduless 7K0yydkk+.F!OP wwt'8'8'D'DE AGGOOA&E $))"''*:*:1*=>qA34  ,!>? rci}g}|jD]}|jd}dj|dd}|d} ||\}}|s/|j ||} |df||<| r|j |d| ftjj||dz} |j|| s|j ||| f|S#t$r|j |}d}YwxYw)aFinds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. r6rrZr7__init__.py) rr;r:r\r8rcr>r9r+rh) rr"rprfr+r module_basercheckedrbrgs r find_moduleszbuild_py.find_moduless  ooF<<$DhhtAbz*Gr(K )1'):&g ,,WkB%0!$4!NNGZ#AB '',,{K%4GHK$$V[9 NNG[+> ?1&4' "227;  sCC%$C%cg}|jr|j|j|jrE|jD]6}|j |}|j ||}|j|8|S)a4Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.)rrJryr"r8rs)rrprrms rfind_all_moduleszbuild_py.find_all_modulesso  ?? NN4,,. / ===="227; --g{Cq!)rcN|jDcgc]}|d c}Scc}w)NrZ)r|)rrfs rget_source_fileszbuild_py.get_source_files.s))-)>)>)@A)@vr )@AAAs "cf|gt|z|dzgz}tjj|S)Nrv)listr9r+r:)rrArrf outfile_paths rget_module_outfilezbuild_py.get_module_outfile1s1!{T']2fun5EE ww||\**rc |j}g}|D]\}}}|jd}|j|j||}|j ||sI|j r0|j t jj|d|jdkDs|j t jj||j||jD cgc].\}}} } | D]"}tjj| |$0c}} } }}z }|Scc}} } }}w)Nr6rF) optimizationr)r|r;rrr>r importlibutilcache_from_sourcerr%r9r+r:) rr.rpoutputsrrfrgrWr@rArDs rr3zbuild_py.get_outputs5s''),3 (GV[mmC(G..t~~wOH NN8 $<<NN!88PR8S==1$NN!88$4==9-4 :>// :I6)Y% GGLLH -% .:I     s93D7cJt|tr|jd}n!t|ttfs t d|j |j||}tjj|}|j||j||dS)Nr6z:'package' must be a string (dot-separated), list, or tuplerrR) r&strr;rtuple TypeErrorrrr9r+rUrTrV)rrfrgroutfiledirs r build_modulezbuild_py.build_modulePs gs #mmC(GGdE]3L ))$..'6Jggoog& C~~k7!~DDrc`|j}|D]\}}}|j|||yN)ryr)rrprrfrgs rr/zbuild_py.build_modules`s5##%,3 (GV[   fk7 ; -4rc|jD]J}|j|}|j||}|D] \}}}||k(sJ|j|||"Lyr)r"r8rsr)rrrrppackage_rfrgs rr0zbuild_py.build_packagesisg}}G..w7K//EG29-&+(***!!&+w?29%rctjr|jdyddlm}|j }|dt jk7r|t jz}|jr!||d|j||j|jdkDr,|||j|j||jyy)Nz%byte-compiling is disabled, skipping.r)r2rZr)rrprefixdry_run) sysdont_write_bytecodewarnrr2rr9sepr rrr)rrMr2rs rr2zbuild_py.byte_compile}s  " " II= > ' ": bff_F << FDLL  ==1  jj   rN)r7)__name__ __module__ __qualname__ description user_optionsboolean_options negative_optrr,r4r$r=r1r8rcrhrsryr|r~rr3rr/r0r2rrr r sKK L!'*O ),LJ2@<, %N4 2h B+6E <@(rr )__doc__r9importlib.utilrrrHcorererrorsrrrrdistutils._logrr rrrrs20  =FwFr