f _jc@sdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZdZddddddZddddddddddddedZerdddddded <ddd!d"dded#<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_name) unix_prefix 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@seZdZdZgdZgdZer>edddefedddiZ 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=NzZprint expand_dirscreate_home_pathr'Z ext_modulesr%r$ convert_pathshandle_extra_pathinstall_libbasepathjoin extra_dirsr# change_rootsZset_undefined_options)r4r;rrr<r>r5r5r6finalize_optionss                         zinstall.finalize_optionscCstsdSddlm}t|d|jD]r}|d}|ddkrL|dd}||jvrx|j|}||}t|| }n||}t||}td||q(dS)zDumps the list of user options.Nr) longopt_xlatez:iz=z %s: %s) rZdistutils.fancy_getoptrVrdebug user_options negative_optZ translategetattr)r4ZmsgrVZoptZopt_namevalr5r5r6rCvs         zinstall.dump_dirscCsV|jdus|jdur\|jdur2|jdur2|jdusP|jdusP|jdusP|jdurXtddS|j r|j durtt d|j |_|_| dn|j dur|j |_|_| dn|jdur$|jdurtdttdstjtjksdtjvrd }nd }tjtj||_tjtj||_n|jdur8|j|_|j|_|j|_| d dS) 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 prefixZ real_prefixZRPM_BUILD_ROOTz/localr9r)r!r"r'r$r%r&r(r)r rr*r select_schemer rrZhasattrrFZ base_prefixr@ZenvironrQnormpath)r4Zadditionr5r5r6rDsZ          zinstall.finalize_unixcCs|jr8|jdurtd|j|_|_|tjdn~|jdur\|j|_|_|dnZ|j durvtj t j |_ |j |_|_z|tjWn t ytdtjYn0dS)z)Finalizes options for non-posix platformsNr\Z_userrz)I don't know how to install stuff on '%s')rr*rr!r"r]r@rAr rrQr^rFZKeyErrorr3r5r5r6rEs&     zinstall.finalize_othercCs<t|}tD]*}d|}t||dur t||||q dS)z=Sets the install directories by applying the install schemes.install_N)INSTALL_SCHEMES SCHEME_KEYSrZsetattr)r4rAZschemeZkeyZattrnamer5r5r6r]s zinstall.select_schemecCsX|D]N}t||}|durtjdks.tjdkr:tj|}t||j}t|||qdS)Nr8r)rZr@rArQ expanduserrrIrb)r4Zattrsattrr[r5r5r6 _expand_attrss   zinstall._expand_attrscC|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r!r"r#Nrer3r5r5r6rKzinstall.expand_basedirscCrf)z+Calls `os.path.expanduser` on install dirs.)r$r%r'r&r(r)Nrgr3r5r5r6rLszinstall.expand_dirscGs,|D]"}d|}t||tt||qdS)z!Call `convert_path` over `names`.r_N)rbrrZr4ZnamesrArdr5r5r6rNzinstall.convert_pathscCs|jdur|jj|_|jdurtdt|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.z,rrr:zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr9) r,rHrrBZ isinstanceZstrrGlenr r path_filerS)r4rlrSr5r5r6rOs(      zinstall.handle_extra_pathc Gs0|D]&}d|}t||t|jt||qdS)z:Change the install directories pointed by name using root.r_N)rbr r#rZrir5r5r6rTrjzinstall.change_rootscCsb|js dSttjd}|jD]8\}}||r$tj|s$| d|t |dq$dS)zCreate directories under ~.Nz~zos.makedirs('%s', 0o700)i) rrr@rQrcrIZitemsZ startswithZisdirZ debug_printZmakedirs)r4r rArQr5r5r6rMszinstall.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||vrtd|jdS)zRuns the command.r?z"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)r.Z run_commandrHZget_command_objZ plat_namer/r rget_sub_commandsrlcreate_path_filer2 get_outputsr#rkZrangeexecuterZmapr@rQr^rFZnormcaser'r-rrW)r4Z build_platcmd_nameoutputsZroot_lenZcounterZsys_pathr'r5r5r6run)sD    z install.runcCsJtj|j|jd}|jr8|t||jgfd|n| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) r@rQrRrPrlr-rprrSrB)r4filenamer5r5r6rnUs  zinstall.create_path_filecCshg}|D].}||}|D]}||vr"||q"q |jrd|jrd|tj|j |jd|S)z.Assembles the outputs of all the sub-commands.rt) rmget_finalized_commandroappendrlr-r@rQrRrP)r4rrrqcmdrur5r5r6rocs    zinstall.get_outputscCs.g}|D]}||}||q |S)z*Returns the inputs of all the sub-commands)rmrvZextend get_inputs)r4Zinputsrqrxr5r5r6ryts   zinstall.get_inputscCs|jp|jS)zSReturns true if the current distribution has any Python modules to install.)rHZhas_pure_modulesZhas_ext_modulesr3r5r5r6has_libs zinstall.has_libcC |jS)zLReturns true if the current distribution has any headers to install.)rH has_headersr3r5r5r6r|rhzinstall.has_headerscCr{)zMReturns true if the current distribution has any scripts to. install.)rH has_scriptsr3r5r5r6r}rhzinstall.has_scriptscCr{)zJReturns true if the current distribution has any data to. install.)rHZhas_data_filesr3r5r5r6has_datarhzinstall.has_datar'r&r(r)Zinstall_egg_infocCsdS)NTr5r3r5r5r6Zszinstall.) Z__name__Z __module__Z __qualname__Z descriptionrXZboolean_optionsrJrwr rYr7rUrCrDrEr]rerKrLrNrOrTrMrsrnroryrzr|r}r~Z sub_commandsr5r5r5r6rIsJ; N3  " ,  r)Z__doc__rFr@Z distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrrr r r Zsiter r rJZWINDOWS_SCHEMEr`rarr5r5r5r6Zsb