U A`Gp @s:dZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZdZddddddZddddddddddddddddddd d d!ddded"Zer"d#d#d$d%d&ded'<d#d#d(d)d&ded*<dZGd+d,d,eZdS)-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_SITETz$base/Lib/site-packagesz$base/Include/$dist_namez $base/Scriptsz$base)purelibplatlibheadersscriptsdataz/$base/lib/python$py_version_short/site-packagesz3$platbase/lib/python$py_version_short/site-packagesz9$base/include/python$py_version_short$abiflags/$dist_namez $base/binz5$base/local/lib/python$py_version_short/dist-packagesz9$platbase/local/lib/python$py_version_short/dist-packagesz6$base/local/include/python$py_version_short/$dist_namez$base/local/binz $base/localz$base/lib/python3/dist-packagesz#$platbase/lib/python3/dist-packagesz0$base/include/python$py_version_short/$dist_namez$base/lib/pythonz$base/include/python/$dist_name) unix_prefix unix_local deb_system unix_homentz $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@s<eZdZdZdddddddd d d d d dddddddgZdddgZerbedddefedddiZ ddZ ddZ d d!Z d"d#Z d$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Zd@dAZdBdCZdDdEZdFefdGefdHefdIefdJdKdLfgZdS)Minstallz'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=NzrEr$r%rFrHr?r?r@finalize_optionss                         zinstall.finalize_optionscCstsdSddlm}t|d|jD]r}|d}|ddkrL|dd}||jkrx|j|}||}t|| }n||}t||}td||q(dS)zDumps the list of user options.Nr) longopt_xlate:=z %s: %s) rZdistutils.fancy_getoptrdrdebug user_options negative_opt translategetattr)r>msgrdZoptZopt_namevalr?r?r@rMs         zinstall.dump_dirscCs|jdk s|jdk r\|jdkr2|jdkr2|jdksP|jdksP|jdksP|jdkrXtddS|j r|j dkrtt d|j |_|_| dn~|j dk r|j |_|_| dnX|j|_|jdkr|jdk rtdtjtj|_tjtj|_n|jdkr|j|_|j|_|j|_|jr~|jdkrXddl}|d |_| d n$|jd krt| d ntd n|jrtj|jdkstjtjksdtjksdtjksdtjkr| d n6tj|jdkrd|_|_d|_|_| 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 prefix)ZdebrZ MULTIARCHr)Zunixrz"unknown value for --install-layoutz /usr/localZPYTHONUSERBASEZ VIRTUAL_ENVZ real_prefixz/usrr)r(r)r.r+r,r-r/r0r r"r1r select_schemer&r$r'r%rJr_normpathrPr3lower sysconfigZget_config_varr4 base_prefixenviron__dict__)r>rsr?r?r@rNs             zinstall.finalize_unixcCs|jr8|jdkrtd|j|_|_|tjdn|jdk r\|j|_|_|dn\|j dkrvtj t j |_ |j |_|_z|tjWn"t k rtdtjYnXdS)z)Finalizes options for non-posix platformsNroZ_userrz)I don't know how to install stuff on '%s')r"r1rr(r)rprJrKr&r$r_rqrPKeyErrorr=r?r?r@rOs&    zinstall.finalize_othercCs<t|}tD]*}d|}t||dkr t||||q dS)z=Sets the install directories by applying the install schemes.install_N)INSTALL_SCHEMES SCHEME_KEYSrlsetattr)r>rKZschemekeyattrnamer?r?r@rps zinstall.select_schemecCsX|D]N}t||}|dk rtjdks.tjdkr:tj|}t||j}t|||qdS)NrBr)rlrJrKr_ expanduserr rVr{)r>Zattrsattrrnr?r?r@ _expand_attrss   zinstall._expand_attrscCs|dddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.r(r)r*Nrr=r?r?r@rXszinstall.expand_basedirscCs|ddddddgdS)z+Calls `os.path.expanduser` on install dirs.r+r,r.r-r/r0Nrr=r?r?r@rZ s zinstall.expand_dirscGs,|D]"}d|}t||tt||qdS)z!Call `convert_path` over `names`.rxN)r{rrlr>namesrKrr?r?r@r\szinstall.convert_pathscCs|jdkr|jj|_|jdk rtdt|jtrB|jd|_t|jdkr`|jd}}n"t|jdkrz|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#rrDzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsrC) r6rTrrL isinstancestrrRlenr r path_filera)r>rrar?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.rxN)r{r r*rlrr?r?r@rb7szinstall.change_rootscCsb|js dSttjd}|jD]8\}}||r$tj|s$| d|t |dq$dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r"rrJr_r~rVitems startswithisdirZ debug_printmakedirs)r>r&rKr_r?r?r@r[=szinstall.create_home_pathcCs"|js6|d|jdj}|jr6|tkr6td|D]}||q>|j r\| |j r| }|j rt|j }tt|D]}|||d||<q|t|j |fd|j ttjjtj}ttjj|}tjtj|j}|jr|j r|js||krtd|jdS)zRuns the command.rIz"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)r8Z run_commandrTZget_command_objZ plat_namer9r rget_sub_commandsrcreate_path_filer< get_outputsr*rrangeexecutermaprJr_rqrPnormcaser.r7rrh)r>Z build_platcmd_nameoutputsZroot_lenZcounterZsys_pathr.r?r?r@runIsD    z install.runcCsJtj|j|jd}|jr8|t||jgfd|n| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rJr_r`r^rr7rrrarL)r>filenamer?r?r@rus  zinstall.create_path_filecCshg}|D].}||}|D]}||kr"||q"q |jrd|jrd|tj|j |jd|S)z.Assembles the outputs of all the sub-commands.r) rget_finalized_commandrappendrr7rJr_r`r^)r>rrcmdrr?r?r@rs    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.)rTZhas_pure_modulesZhas_ext_modulesr=r?r?r@has_libs zinstall.has_libcCs |jS)zLReturns true if the current distribution has any headers to install.)rT has_headersr=r?r?r@rszinstall.has_headerscCs |jS)zMReturns true if the current distribution has any scripts to. install.)rT has_scriptsr=r?r?r@rszinstall.has_scriptscCs |jS)zJReturns true if the current distribution has any data to. install.)rTZhas_data_filesr=r?r?r@has_dataszinstall.has_datar.r-r/r0Zinstall_egg_infocCsdS)NTr?r=r?r?r@zinstall.) __name__ __module__ __qualname__Z descriptionriZboolean_optionsrWrrrjrArcrMrNrOrprrXrZr\r]rbr[rrrrrrrrZ sub_commandsr?r?r?r@rWsp >  S>  " ,  r)__doc__rPrJZ distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrr r r r Zsiter rrWZWINDOWS_SCHEMEryrzrr?r?r?r@sz           !