o =?hRn@sdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZeduZdZiiidZeD]"ZdD]\ZZeZ ej!eZ"edkree"vrdZ e"e eee<qjqfeD]=Z#ee#$D]4\ZZ%e&dde%Z%e%'ddZ%e%'ddZ%edkre%d7Z%ej(dkredkre%'ddZ%e%ee#e<qqerdddd d!ded"<ddd#d$d!ded%<Gd&d'd'eZ)dS)(zFdistutils.command.install Implements the Distutils 'install' command.N)log)Command)DEBUG)get_config_vars)DistutilsPlatformError) write_file) convert_path subst_vars change_root) get_platform)DistutilsOptionError) USER_BASE) USER_SITE)purelibplatlibheadersscriptsdata) unix_prefix unix_homent))rZ posix_prefix)rZ posix_home)rrrZincludez \{(.+?)\}z$\g<1>z$installed_basez$basez$py_version_nodot_platz$py_version_nodotz /$dist_name) rz/lib/z /$platlibdir/z $usersitez4$userbase/Python$py_version_nodot/Include/$dist_namez)$userbase/Python$py_version_nodot/Scriptsz $userbaseZnt_userz=$userbase/include/python$py_version_short$abiflags/$dist_namez $userbase/bin unix_userc@seZdZdZgdZgdZeredddefedddiZ d d Z d d Z d dZ ddZ ddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3efd4efd5efd6efd7d8d9fgZdS):installz'install everything from build directory))zprefix=Nzinstallation prefix)z exec-prefix=Nz.(Unix only) prefix for platform-specific files)zhome=Nz+(Unix only) home directory to install under)z install-base=Nz;base installation directory (instead of --prefix or --home))zinstall-platbase=Nz\base installation directory for platform-specific files (instead of --exec-prefix or --home))zroot=Nzfinalize_optionss                        zinstall.finalize_optionscCstsdSddlm}t|d|jD]9}|d}|ddkr&|dd}||jvr<|j|}||}t|| }n ||}t||}td||qdS)zDumps the list of user options.Nr) longopt_xlate:=z %s: %s) rZdistutils.fancy_getoptrerdebug user_options negative_opt translategetattr)r<msgreoptZopt_namevalr=r=r>rNs          zinstall.dump_dirscCs$|jdus |jdur.|jdur|jdur|jdus(|jdus(|jdus(|jdur,tddS|j rH|j dur:t d|j |_|_| ddS|j dur[|j |_|_| ddS|jdurz|jduritdtjtj|_tjtj|_n |jdur|j|_|j|_|j|_| ddS)z&Finalizes options for posix platforms.NzPinstall-base or install-platbase supplied, but installation scheme is incomplete$User base directory is not specifiedrrz*must not supply exec-prefix without prefixr)r'r(r-r*r+r,r.r/r r"r1r select_schemer&r$r%rKr`normpathrQr;r=r=r>rOsB           zinstall.finalize_unixcCs|jr|jdur td|j|_|_|tjddS|jdur0|j|_|_|ddS|j dur=tj t j |_ |j |_|_z |tjWdSt y[tdtjw)z)Finalizes options for non-posix platformsNrqZ_userrz)I don't know how to install stuff on '%s')r"r1rr'r(rrrKrLr&r$r`rsrQKeyErrorr;r=r=r>rPs(    zinstall.finalize_othercCs<t|}tD]}d|}t||durt||||qdS)z=Sets the install directories by applying the install schemes.install_N)INSTALL_SCHEMES SCHEME_KEYSrmsetattr)r<rLZschemekeyattrnamer=r=r>rrszinstall.select_schemecCsX|D]'}t||}|dur)tjdkstjdkrtj|}t||j}t|||qdS)Nr@r)rmrKrLr` expanduserr rWrx)r<Zattrsattrrpr=r=r> _expand_attrss    zinstall._expand_attrscC|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r'r(r)Nr}r;r=r=r>rYszinstall.expand_basedirscCr~)z+Calls `os.path.expanduser` on install dirs.)r*r+r-r,r.r/Nrr;r=r=r>r[szinstall.expand_dirscGs,|D]}d|}t||tt||qdS)z!Call `convert_path` over `names`.ruN)rxrrmr<namesrLr|r=r=r>r]szinstall.convert_pathscCs|jdur |jj|_|jdurFtdt|jtr!|jd|_t|jdkr0|jd}}nt|jdkr=|j\}}ntdt |}nd}d}||_ ||_ dS) z4Set `path_file` and `extra_dirs` using `extra_path`.NzIDistribution option extra_path is deprecated. See issue27919 for details.,r#rrBzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsrA) r4rUrrM isinstancestrrSlenr r path_filerb)r<rrbr=r=r>r^s(       zinstall.handle_extra_pathc Gs0|D]}d|}t||t|jt||qdS)z:Change the install directories pointed by name using root.ruN)rxr r)rmrr=r=r>rc"szinstall.change_rootscCsb|jsdSttjd}|jD]\}}||r.tj|s.| d|t |dqdS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r"rrKr`r{rWitems startswithisdirZ debug_printmakedirs)r<r&rLr`r=r=r>r\(s zinstall.create_home_pathcCs&|js|d|jdj}|jr|tkrtd|D]}||q|j r.| |j r]| }|j rPt|j }tt|D] }|||d||<qC|t|j |fd|j ttjjtj}ttjj|}tjtj|j}|jr|j r|js||vrtd|jdSdSdSdS)zRuns the command.rJz"Can't install when cross-compilingNz'writing list of installed files to '%s'zmodules installed to '%s', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself)r6Z run_commandrUZget_command_objZ plat_namer7r rget_sub_commandsrcreate_path_filer: get_outputsr)rrangeexecutermaprKr`rsrQnormcaser-r5rri)r<Z build_platcmd_nameoutputsZroot_lenZcounterZsys_pathr-r=r=r>run4sH    z install.runcCsLtj|j|jd}|jr|t||jgfd|dS| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rKr`rar_rr5rrrbrM)r<filenamer=r=r>r`s  zinstall.create_path_filecCshg}|D]}||}|D] }||vr||qq|jr2|jr2|tj|j |jd|S)z.Assembles the outputs of all the sub-commands.r) rget_finalized_commandrappendrr5rKr`rar_)r<rrcmdrr=r=r>rns     zinstall.get_outputscCs.g}|D]}||}||q|S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)r<Zinputsrrr=r=r>rs   zinstall.get_inputscCs|jp |jS)zSReturns true if the current distribution has any Python modules to install.)rUZhas_pure_modulesZhas_ext_modulesr;r=r=r>has_libs zinstall.has_libcC |jS)zLReturns true if the current distribution has any headers to install.)rU has_headersr;r=r=r>r zinstall.has_headerscCr)zMReturns true if the current distribution has any scripts to. install.)rU has_scriptsr;r=r=r>rrzinstall.has_scriptscCr)zJReturns true if the current distribution has any data to. install.)rUZhas_data_filesr;r=r=r>has_datarzinstall.has_datar-r,r.r/Zinstall_egg_infocCsdS)NTr=r;r=r=r>szinstall.) __name__ __module__ __qualname__ descriptionrjZboolean_optionsr0rrrkr?rdrNrOrPrrr}rYr[r]r^rcr\rrrrrrrrZ sub_commandsr=r=r=r>rZsL; O(  " ,  r)*__doc__rQrXrKreZ distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrr r r r Zsiter rr0rwrvryZdistutils_scheme_nameZsys_scheme_nameZsys_keyZ_INSTALL_SCHEMESZ sys_schemeZmain_keyrvaluesubreplacerVrr=r=r=r>sh