o bcRx @sdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlmZdd lmZmZmZdd lmZdd lmZdd lmZdd lmZeduZdZiiidZdddddddddd ed<dddddddddd ed<eD]"Zd D]\ZZ eZ!ej"e Z#ed!kree#vrd"Z!e#e!eee<qqeD]=Z$ee$%D]4\ZZ&e'd#d$e&Z&e&(d%d&Z&e&(d'd(Z&ed!kre&d)7Z&ej)d*kred+kre&(d,d-Z&e&ee$e<qqerd.d.d/d0d1ded2<d.d.d3d4d1ded5<Gd6d7d7eZ*dS)8zFdistutils.command.install Implements the Distutils 'install' command.N)log)Command)DEBUG)get_config_varsis_virtual_environment)DistutilsPlatformError) write_file) convert_path subst_vars change_root) get_platform)DistutilsOptionError) USER_BASE) USER_SITE)purelibplatlibheadersscriptsdata) unix_prefix unix_homentz6{installed_base}/{platlibdir}/python{py_version_short}z0{platbase}/{platlibdir}/python{py_version_short}z7{base}/local/lib/python{py_version_short}/dist-packageszD{platbase}/local/{platlibdir}/python{py_version_short}/dist-packagesz;{installed_base}/include/python{py_version_short}{abiflags}z7{base}/local/include/python{py_version_short}{abiflags}z?{installed_platbase}/include/python{py_version_short}{abiflags}z{base}/local/binz {base}/local) stdlib platstdlibrrincluder platincluderr unix_localz {base}/lib/python3/dist-packagesz-{platbase}/{platlibdir}/python3/dist-packagesz {base}/binz{base} deb_system))r posix_prefix)r posix_home)rrrrz \{(.+?)\}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 $userbasent_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=Nzlowerrsrur?r)rIrsrJrJrKrgsh              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 platformsNr_userrz)I don't know how to install stuff on '%s')r,r<rr2r3rrcrdr0r.r~rriKeyErrorrHrJrJrKrhs(    zinstall.finalize_othercCs<t|}tD]}d|}t||durt||||qdS)z=Sets the install directories by applying the install schemes.install_N)INSTALL_SCHEMES SCHEME_KEYSrsetattr)rIrdschemekeyattrnamerJrJrKrszinstall.select_schemecCsX|D]'}t||}|dur)tjdkstjdkrtj|}t||j}t|||qdS)NrMr)rrcrdr~ expanduserr rrr)rIattrsattrrrJrJrK _expand_attrss    zinstall._expand_attrscC|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r2r3r4NrrHrJrJrKrv"szinstall.expand_basedirscCr)z+Calls `os.path.expanduser` on install dirs.)r5r6r8r7r9r:NrrHrJrJrKrx'szinstall.expand_dirscGs,|D]}d|}t||tt||qdS)z!Call `convert_path` over `names`.rN)rr rrInamesrdrrJrJrKr{-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-rrOzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsrN) rArmrre isinstancestrrklenr r path_filer)rIrrrJrJrKr|3s(       zinstall.handle_extra_pathc Gs0|D]}d|}t||t|jt||qdS)z:Change the install directories pointed by name using root.rN)rr r4rrrJrJrKrUszinstall.change_rootscCsb|jsdSttjd}|jD]\}}||r.tj|s.| d|t |dqdS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r,r rcr~rrritems startswithisdir debug_printmakedirs)rIr0rdr~rJrJrKry[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.rbz"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)rC run_commandrmget_command_obj plat_namerDr rget_sub_commandsrcreate_path_filerG get_outputsr4rrangeexecutermaprcr~rrinormcaser8rBrr)rI build_platcmd_nameoutputsroot_lencountersys_pathr8rJrJrKrungsH    z install.runcCsLtj|j|jd}|jr|t||jgfd|dS| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rcr~rr}rrBrrrre)rIfilenamerJrJrKrs  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_commandrappendrrBrcr~rr})rIrrcmdrrJrJrKrs     zinstall.get_outputscCs.g}|D]}||}||q|S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)rIinputsrrrJrJrKrs   zinstall.get_inputscCs|jp |jS)zSReturns true if the current distribution has any Python modules to install.)rmhas_pure_moduleshas_ext_modulesrHrJrJrKhas_libs zinstall.has_libcC |jS)zLReturns true if the current distribution has any headers to install.)rm has_headersrHrJrJrKr zinstall.has_headerscCr)zMReturns true if the current distribution has any scripts to. install.)rm has_scriptsrHrJrJrKrrzinstall.has_scriptscCr)zJReturns true if the current distribution has any data to. install.)rmhas_data_filesrHrJrJrKhas_datarzinstall.has_datar8r7r9r:install_egg_infocCsdS)NTrJrHrJrJrKszinstall.) __name__ __module__ __qualname__ descriptionrboolean_optionsr;rrrrLrrfrgrhrrrvrxr{r|rryrrrrrrrr sub_commandsrJrJrJrKr$rsL> T;  " ,  r$)+__doc__rirsrcre distutilsrdistutils.corerdistutils.debugrdistutils.sysconfigrrdistutils.errorsrdistutils.file_utilrdistutils.utilr r r r r siterrr;rrrdistutils_scheme_namesys_scheme_namesys_key_INSTALL_SCHEMES sys_schememain_keyrvaluesubreplacerqr$rJrJrJrKs