a ? ^j@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=Nzr)r%r&r+r(r)r*r,r-r r r.r select_schemer$r"r#hasattrrN base_prefixrHenvironr^normpath)r9Zadditionr:r:r;rLsZ          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 platformsNro_userrz)I don't know how to install stuff on '%s')r r.rr%r&rqrHrIr$r"r^rurNKeyErrorr8r:r:r;rMs&     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_KEYSrksetattr)r9rIschemekeyattrnamer:r:r;rqs zinstall.select_schemecCsX|D]N}t||}|durtjdks.tjdkr:tj|}t||j}t|||qdS)Nr=r)rkrHrIr^ expanduserr rUr{)r9attrsattrrnr:r:r; _expand_attrss   zinstall._expand_attrscCs|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r%r&r'Nrr8r:r:r;rWszinstall.expand_basedirscCs|gddS)z+Calls `os.path.expanduser` on install dirs.)r(r)r+r*r,r-Nrr8r:r:r;rYszinstall.expand_dirscGs,|D]"}d|}t||tt||qdS)z!Call `convert_path` over `names`.rxN)r{rrkr9namesrIrr:r:r;r[szinstall.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.,r!rr?zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr>) r1rRrrJ isinstancestrrPlenr r path_filer`)r9rr`r: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'rkrr:r:r;raszinstall.change_rootscCsb|js dSttjd}|jD]8\}}||r$tj|s$| d|t |dq$dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r rrHr^rrUitems startswithisdirZ debug_printmakedirs)r9r$rIr^r:r:r;rZszinstall.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.rGz"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)r3Z run_commandrRZget_command_objZ plat_namer4r rget_sub_commandsrcreate_path_filer7 get_outputsr'rrangeexecutermaprHr^rurNnormcaser+r2rrg)r9Z build_platcmd_nameoutputsZroot_lenZcounterZsys_pathr+r:r:r;run)sD    z install.runcCsJtj|j|jd}|jr8|t||jgfd|n| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rHr^r_r]rr2rrr`rJ)r9filenamer:r:r;rUs  zinstall.create_path_filecCshg}|D].}||}|D]}||vr"||q"q |jrd|jrd|tj|j |jd|S)z.Assembles the outputs of all the sub-commands.r) rget_finalized_commandrappendrr2rHr^r_r])r9rrcmdrr:r:r;rcs    zinstall.get_outputscCs.g}|D]}||}||q |S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)r9Zinputsrrr:r:r;rts   zinstall.get_inputscCs|jp|jS)zSReturns true if the current distribution has any Python modules to install.)rRZhas_pure_modulesZhas_ext_modulesr8r:r:r;has_libs zinstall.has_libcCs |jS)zLReturns true if the current distribution has any headers to install.)rR has_headersr8r:r:r;rszinstall.has_headerscCs |jS)zMReturns true if the current distribution has any scripts to. install.)rR has_scriptsr8r:r:r;rszinstall.has_scriptscCs |jS)zJReturns true if the current distribution has any data to. install.)rRZhas_data_filesr8r:r:r;has_dataszinstall.has_datar+r*r,r-Zinstall_egg_infocCsdS)NTr:r8r:r:r;zinstall.) __name__ __module__ __qualname__ descriptionrhZboolean_optionsrVrrrir<rbrKrLrMrqrrWrYr[r\rarZrrrrrrrrZ sub_commandsr:r:r:r;rIsJ; N3  " ,  r)__doc__rNrHZ distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrr r r r Zsiter rrVZWINDOWS_SCHEMEryrzrr:r:r:r;sb