U ia`k @s:dZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZdZddddddZddddddddddddedddddddddddddZer"dddd d!ded"<ddd#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-packagesz;$platbase/$platlibdir/python$py_version_short/site-packagesz9$base/include/python$py_version_short$abiflags/$dist_namez $base/binz$base/lib/pythonz$base/$platlibdir/pythonz$base/include/python/$dist_namez$base/site-packagesz$base/include/$dist_name) unix_prefix unix_homentpypypypy_ntz $usersitez4$userbase/Python$py_version_nodot/Include/$dist_namez)$userbase/Python$py_version_nodot/Scriptsz $userbasent_userz=$userbase/include/python$py_version_short$abiflags/$dist_namez $userbase/bin unix_userc@s:eZdZdZdddddddd d d d d ddddddgZdddgZer`edddefedddiZ ddZ ddZ dd Z d!d"Z d#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Zd?d@ZdAdBZdCdDZdEefdFefdGefdHefdIdJdKfgZdS)Linstallz'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]r}|d}|ddkrL|dd}||jkrx|j|}||}t|| }n||}t||}td||q(dS)zDumps the list of user options.Nr) longopt_xlate:=z %s: %s) rdistutils.fancy_getoptrurdebug user_options negative_opt translaterd)r<msgruoptopt_namevalr=r=r>rXs         zinstall.dump_dirscCs"|jdk s|jdk r\|jdkr2|jdkr2|jdksP|jdksP|jdksP|jdkrXtddS|j r|j dkrtt d|j |_|_| dn|j dk r|j |_|_| dnl|jdkr|jdk rtdtjtj|_tjtj|_n|jdkr|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/r0r r#r1r select_schemer'r%r&rUronormpathr[r;r=r=r>rYsL        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 platformsNr_userrz)I don't know how to install stuff on '%s')r#r1rr(r)rrUrVr'r%rorr[KeyErrorr;r=r=r>rZs&    zinstall.finalize_othercCsdttdr(|ds(tjdkr$d}nd}t|}tD]*}d|}t||dkr4t||||q4dS)z=Sets the install directories by applying the install schemes.pypy_version_info)r_homerrrinstall_N) hasattrr[endswithrUrVINSTALL_SCHEMES SCHEME_KEYSrdsetattr)r<rVschemekeyattrnamer=r=r>rs  zinstall.select_schemecCsX|D]N}t||}|dk rtjdks.tjdkr:tj|}t||j}t|||qdS)Nr@r)rdrUrVro expanduserr rer)r<attrsattrrr=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>rgszinstall.expand_basedirscCs|ddddddgdS)z+Calls `os.path.expanduser` on install dirs.r+r,r.r-r/r0Nrr;r=r=r>ris zinstall.expand_dirscGs,|D]"}d|}t||tt||qdS)z!Call `convert_path` over `names`.rN)rrrdr<namesrVrr=r=r>rlszinstall.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$rrBzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsrA) r4r_rrW isinstancestrr]lenr r path_filerq)r<rrqr=r=r>rms(      zinstall.handle_extra_pathc Gs0|D]&}d|}t||t|jt||qdS)z:Change the install directories pointed by name using root.rN)rr r*rdrr=r=r>rr szinstall.change_rootscCsb|js dSttjd}|jD]8\}}||r$tj|s$| d|t |dq$dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r#rrUrorreitems startswithisdir debug_printmakedirs)r<r'rVror=r=r>rj&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.rTz"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)r6 run_commandr_get_command_obj plat_namer7r rget_sub_commandsrcreate_path_filer: get_outputsr*rrangeexecutermaprUrorr[normcaser.r5rrz)r< build_platcmd_nameoutputsroot_lencountersys_pathr.r=r=r>run2sD    z install.runcCsJtj|j|jd}|jr8|t||jgfd|n| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rUrorprnrr5rrrqrW)r<filenamer=r=r>r^s  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_commandrappendrr5rUrorprn)r<rrcmdrr=r=r>rls    zinstall.get_outputscCs.g}|D]}||}||q |S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)r<inputsrrr=r=r>r}s   zinstall.get_inputscCs|jp|jS)zSReturns true if the current distribution has any Python modules to install.)r_has_pure_modulesrkr;r=r=r>has_libs zinstall.has_libcCs |jS)zLReturns true if the current distribution has any headers to install.)r_ has_headersr;r=r=r>rszinstall.has_headerscCs |jS)zMReturns true if the current distribution has any scripts to. install.)r_ has_scriptsr;r=r=r>rszinstall.has_scriptscCs |jS)zJReturns true if the current distribution has any data to. install.)r_has_data_filesr;r=r=r>has_dataszinstall.has_datar.r-r/r0install_egg_infocCsdS)NTr=r;r=r=r>zinstall.) __name__ __module__ __qualname__ descriptionr{boolean_optionsrfrrr|r?rtrXrYrZrrrgrirlrmrrrjrrrrrrrr sub_commandsr=r=r=r>rWsn ;  N( " ,  r)__doc__r[rU distutilsrdistutils.corerdistutils.debugrdistutils.sysconfigrdistutils.errorsrdistutils.file_utilrdistutils.utilrr r r r siter rrfWINDOWS_SCHEMErrrr=r=r=r>sz           !