a ` @sLdZddlZddlZddlZddlmZddlmZdZ GdddeZ dS)zkdistutils.command.install_lib Implements the Distutils 'install_lib' command (install all Python modules).N)Command)DistutilsOptionErrorz.pyc@sxeZdZdZgdZgdZddiZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZdS) install_libz7install all Python modules (extensions and pure Python)))z install-dir=dzdirectory to install to)z build-dir=bz'build directory (where to install from))forcefz-force installation (overwrite existing files))compileczcompile .py to .pyc [default]) no-compileNzdon't compile .py files)z optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]) skip-buildNzskip the build steps)rr r r r cCs(d|_d|_d|_d|_d|_d|_dS)Nr) install_dir build_dirrr optimize skip_buildselfr@/usr/local/src/Python-3.9.6/Lib/distutils/command/install_lib.pyinitialize_options3s zinstall_lib.initialize_optionsc Cs|ddddddd|jdur&d|_|jdur6d |_t|jtszt|j|_|jd vr^tWnttfy~td Yn0dS) Ninstall) build_libr)rr)rr)r r )rr)rrTF)rzoptimize must be 0, 1, or 2)set_undefined_optionsr r isinstanceintAssertionError ValueErrorrrrrrfinalize_options<s&     zinstall_lib.finalize_optionscCs0||}|dur,|jr,||dSN)buildr distributionhas_pure_modules byte_compileroutfilesrrrrunVszinstall_lib.runcCs2|js.|jr|d|jr.|ddS)Nbuild_py build_ext)rr#r$ run_commandhas_ext_modulesrrrrr"fs    zinstall_lib.buildcCs8tj|jr ||j|j}n|d|jdS|S)Nz3'%s' does not exist -- no Python modules to install)ospathisdirr copy_treerwarnr&rrrrmszinstall_lib.installcCsrtjr|ddSddlm}|dj}|jrH||d|j||j d|j dkrn|||j |j||j |j ddS)Nz%byte-compiling is disabled, skipping.r)r%r)rrprefixdry_run)rrr2verboser3) sysdont_write_bytecoder1distutils.utilr%get_finalized_commandrootr rr3rr4)rfilesr%Z install_rootrrrr%vs    zinstall_lib.byte_compilec Csd|sgS||}|}t||}t|ttj}g}|D] } |tj|| |dq>|Sr!) r8 get_outputsgetattrlenr-sepappendr.join) rZhas_anyZ build_cmdZ cmd_option output_dirZ build_filesr prefix_lenoutputsfilerrr_mutate_outputss  zinstall_lib._mutate_outputscCsrg}|D]d}tjtj|d}|tkr.q|jrJ|tjj |dd|j dkr|tjj ||j dq|S)Nr) optimizationr) r-r.splitextnormcasePYTHON_SOURCE_EXTENSIONr r? importlibutilcache_from_sourcer)rZ py_filenamesZbytecode_filesZpy_fileextrrr_bytecode_filenamess    zinstall_lib._bytecode_filenamescCsR||jdd|j}|jr*||}ng}||jdd|j}|||S)zReturn the list of files that would be installed if this command were actually run. Not affected by the "dry-run" flag or whether modules have actually been built yet. r)rr*)rEr#r$rr rOr,)rZ pure_outputsZbytecode_outputsZ ext_outputsrrrr;s   zinstall_lib.get_outputscCsLg}|jr&|d}|||jrH|d}|||S)zGet the list of files that are input to this command, ie. the files that get installed as they are named in the build tree. The files in this list correspond one-to-one to the output filenames returned by 'get_outputs()'. r)r*)r#r$r8extendr;r,)rinputsr)r*rrr get_inputss    zinstall_lib.get_inputsN)__name__ __module__ __qualname__ description user_optionsboolean_options negative_optrr r(r"rr%rErOr;rRrrrrrs   r) __doc__r-importlib.utilrKr5distutils.corerdistutils.errorsrrJrrrrrs