o ?Og&C@sx ddlZddlZddlZddlZddlmZddlTddlm Z m Z ddl m Z GdddeZ Gdd d e e ZdS) N)Command)*) convert_path Mixin2to3)logc@seZdZdZgdZddgZddiZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZddZddZd d!Zd.d#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-S)/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 r r cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr) build_lib py_modulespackage package_data package_dirr optimizer selfrA/opt/alt/python310/lib64/python3.10/distutils/command/build_py.pyinitialize_options s zbuild_py.initialize_optionsc Cs|ddd|jj|_|jj|_|jj|_i|_|jjr/|jjD] \}}t||j|<q#||_ t |j t sQz t |j |_ WdSt tfyPtdwdS)NZbuild)rr)r r zoptimize must be 0, 1, or 2)Zset_undefined_options distributionpackagesrrritemsrget_data_files data_files isinstancerint ValueErrorAssertionErrorZDistutilsOptionError)rnamepathrrrfinalize_options*s&     zbuild_py.finalize_optionscCs:|jr||jr||||jdddSNr)include_bytecode)r build_modulesrbuild_packagesbuild_package_data byte_compile get_outputsrrrrrunCs z build_py.runcs g}|js|S|jD]4}||}tjj|jg|d}d|r)t|dfdd|||D}| ||||fq |S)N.rcsg|]}|dqSNr).0fileZplenrr ss z+build_py.get_data_files..) rget_package_dirosr$joinrsplitlenfind_data_filesappend)rdatarsrc_dir build_dir filenamesrr3rras     zbuild_py.get_data_filescsf |jdg|j|g}g|D]}ttjt|t|}fdd|DqS)Ncs$g|]}|vrtj|r|qSr)r6r$isfile)r1fnfilesrrr4s  z,build_py.find_data_files..) rgetglobr6r$r7escaperextend)rrr=ZglobspatternZfilelistrrCrr:ys  zbuild_py.find_data_filescCsb d}|jD](\}}}}|D]}tj||}|tj||jtj|||ddqqdS)NFZ preserve_mode)rr6r$r7mkpathdirname copy_file)rZlastdirrr=r>r?filenametargetrrrr*szbuild_py.build_package_datacCs |d}|js|rtjj|SdSg}|rDz |jd|}Wnty5|d|d|d=Yn w|d|tjj|S|s|jd}|durT|d||r\tjj|SdS)Nr.r@r)r8rr6r$r7KeyErrorinsertrE)rrr$tailZpdirrrrr5s.         zbuild_py.get_package_dircCsj|dkrtj|std|tj|std||r3tj|d}tj|r-|Std|dS)Nr@z%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz __init__.pyz8package init file '%s' not found (or not a regular file)) r6r$existsZDistutilsFileErrorisdirr7rArwarn)rrrinit_pyrrr check_packages&   zbuild_py.check_packagecCs"tj|std||dSdS)Nz!file %s (for module %s) not foundFT)r6r$rArrV)rmodule module_filerrr check_modules zbuild_py.check_modulec Cs|||ttjt|d}g}tj|jj}|D](}tj|}||kr@tj tj |d}| |||fq| d|q|S)Nz*.pyrz excluding %s) rXrFr6r$r7rGabspathrZ script_namesplitextbasenamer;Z debug_print) rrrZ module_filesmodulesZ setup_scriptrZabs_frYrrrfind_package_moduless  zbuild_py.find_package_modulesc Cs i}g}|jD]]}|d}d|dd}|d}z||\}}Wnty4||}d}Ynw|sM|||} |df||<| rM||d| ftj||d} | || s]q|||| fq|S)Nr.rrPr/__init__.py) rr8r7rQr5rXr;r6r$r[) rrr_rYr$rZ module_basercheckedrWrZrrr find_moduless.       zbuild_py.find_modulescCsP g}|jr |||jr&|jD]}||}|||}||q|Sr0)rrHrdrr5r`)rr_rrmrrrfind_all_moduless    zbuild_py.find_all_modulescCsdd|DS)NcSsg|]}|dqS)rPr)r1rYrrrr4-sz-build_py.get_source_files..)rfrrrrget_source_files,szbuild_py.get_source_filescCs$|gt||dg}tjj|S)Nrb)listr6r$r7)rr>rrYZ outfile_pathrrrget_module_outfile/s zbuild_py.get_module_outfiler/cCs|}g}|D]8\}}}|d}||j||}|||r@|jr/|tjj|dd|j dkr@|tjj||j dq|dd|j D7}|S)Nr.r@) optimizationrcSs,g|]\}}}}|D] }tj||q qSr)r6r$r7)r1rr=r>r?rNrrrr4Bs  z(build_py.get_outputs..) rfr8rirr;r importlibutilcache_from_sourcerr)rr'r_ZoutputsrrYrZrNrrrr,3s(     zbuild_py.get_outputscCsbt|tr |d}n t|ttfstd||j||}tj |}| ||j ||ddS)Nr.z:'package' must be a string (dot-separated), list, or tuplerrJ) rstrr8rhtuple TypeErrorrirr6r$rLrKrM)rrYrZrZoutfiledirrrr build_moduleJs    zbuild_py.build_modulecCs*|}|D] \}}}||||qdSr0)rdrr)rr_rrYrZrrrr(Yszbuild_py.build_modulescCsD|jD]}||}|||}|D] \}}}||||qqdSr0)rr5r`rr)rrrr_Zpackage_rYrZrrrr)bs  zbuild_py.build_packagescCstjr |ddSddlm}|j}|dtjkr|tj}|jr-||d|j ||j d|j dkr@|||j |j ||j ddSdS)Nz%byte-compiling is disabled, skipping.r)r+rP)rr prefixdry_run) sysdont_write_bytecoderVdistutils.utilr+rr6sepr r rtr)rrDr+rsrrrr+vs        zbuild_py.byte_compileN)r/)__name__ __module__ __qualname__ descriptionZ user_optionsZboolean_optionsZ negative_optrr%r-rr:r*r5rXr[r`rdrfrgrir,rrr(r)r+rrrrrs0    '4  rc@seZdZddZddZdS) build_py_2to3cCsLg|_|jr ||jr||||j||jdddSr&) updated_filesrr(rr)r*Zrun_2to3r+r,rrrrr-s zbuild_py_2to3.runcCs,t||||}|dr|j|d|S)Nr/r)rrrr~r;)rrYrZrresrrrrrszbuild_py_2to3.build_moduleN)ryrzr{r-rrrrrrr}s r})r6importlib.utilrkrurFZdistutils.corerZdistutils.errorsrwrrZ distutilsrrr}rrrrs  }