o _a*q @shdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZddlmZdd lmZmZmZdd lmZdd lmZdd lmZdd lmZdZddddddZddddddddddddedddddddddddddZerdddd d!ded"<ddd#d$d!ded%<dZd&d'Zd(d)Z d*d+Z!Gd,d-d-e Z"dS).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_name}z{base}/Scriptsz{base})purelibplatlibheadersscriptsdatazA{base}/lib/{implementation_lower}{py_version_short}/site-packageszN{platbase}/{platlibdir}/{implementation_lower}{py_version_short}/site-packageszM{base}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z {base}/binz!{base}/lib/{implementation_lower}z*{base}/{platlibdir}/{implementation_lower}z1{base}/include/{implementation_lower}/{dist_name}z{base}/site-packagesz{base}/include/{dist_name}) posix_prefix posix_homentpypypypy_ntz {usersite}zA{userbase}/{implementation}{py_version_nodot}/Include/{dist_name}z5{userbase}/{implementation}{py_version_nodot}/Scriptsz {userbase}nt_userzQ{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z{userbase}/bin posix_usercCs@ttddtDWdS1swYdS)NcSsi|] }|tj|ddqS)F)expand) sysconfig get_paths.0schemer!G/usr/lib/python3/dist-packages/setuptools/_distutils/command/install.py \sz+_load_sysconfig_schemes..) contextlibsuppressAttributeErrorrget_scheme_namesr!r!r!r"_load_sysconfig_schemesZs $r(cs(tpifddtttDS)z= Extend default schemes with schemes from sysconfig. cs*i|]}|it|i|iqSr!)INSTALL_SCHEMESgetrsysconfig_schemesr!r"r#is  z!_load_schemes..)r(set itertoolschainr)r!r!r+r" _load_schemesbs  r0cCsttdrdSdS)Npypy_version_infoPyPyPython)hasattrsysr!r!r!r"_get_implementationrs r6c@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=NzuserNz!install in user site-package '%s'r:r8cCsd|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ t |_t|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)zInitializes options.Nr)prefix exec_prefixhomer? install_baseinstall_platbaserootinstall_purelibinstall_platlibinstall_headers install_libinstall_scripts install_datar install_userbaserinstall_usersiter8optimize extra_pathinstall_path_filer< skip_buildwarn_dir build_base build_librecordselfr!r!r"initialize_optionss2  zinstall.initialize_optionscCs|js |js |jr|js|jrtd|jr |js|jr td|jr6|js2|js2|js2|js2|jr6tdtjdkrF|jrF| dd|_| dtjdkrU| n| | dt jd }td d \}}zt j}Wn ty|d }Ynw|j|j|j|d t jdddt jdd|||||tt ddttd|_tr|j|jd<|j|jd<|| d|j|jd<|j|jd<t d|jd<t!rd dl"m"}t#d||j|$| d|jr|%|j&dur|j'r |j(|_&n|j)|_&|*dddddd dd|+|j&|_,tj-.|j&|j/|_&|j0dur?|1d!dddddd | d"|2d#d$d%dS)&zFinalizes options.zWmust supply either prefix/exec-prefix/home or install-base/install-platbase -- not bothz9must supply either home or prefix/exec-prefix -- not bothzGcan't combine user with prefix, exec_prefix/home, or install_(plat)baseposixz+exec-prefix option ignored on this platformNzpre-finalize_{unix,other}zpost-finalize_{unix,other}()rrArBz%d.%dz%d%d platlibdirlib) dist_name dist_version dist_fullname py_versionpy_version_shortpy_version_nodot sys_prefixrAsys_exec_prefixrBabiflagsr]implementation_lowerimplementationuserbaseusersitezpost-expand_basedirs()baseplatbaseinstalled_base)pprintz config vars:zpost-expand_dirs()rrrrrlibbasezafter prepending rootbuild)rTrT)rUrU)3rArBrCrDrEr r?osnamewarn dump_dirs finalize_unixfinalize_otherr5versionsplitrrgr& distributionget_name get_version get_fullname version_infogetattrr6lower config_vars HAS_USER_SITErMrNexpand_basedirsrrroprint expand_dirscreate_home_pathrJhas_ext_modulesrHrG convert_pathshandle_extra_pathinstall_libbasepathjoin extra_dirsrF change_rootsset_undefined_options)rXrbrArBrgror!r!r"finalize_optionss                         zinstall.finalize_optionscCstsdSddlm}t|d|jD]9}|d}|ddkr&|dd}||jvr<|j|}||}t|| }n ||}t||}td||qdS)zDumps the list of user options.Nr) longopt_xlate:=z %s: %s) rdistutils.fancy_getoptrrdebug user_options negative_opt translater)rXmsgroptopt_namevalr!r!r"rus          zinstall.dump_dirscCs8|jdus |jdur.|jdur|jdur|jdus(|jdus(|jdus(|jdur,tddS|j rH|j dur:t d|j |_|_| ddS|j dur[|j |_|_| ddS|jdur|jduritdttdd}tjtj||_tjtj||_n |jdur|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 prefix_prefix_additionr[r)rDrErJrGrHrIrKrLr r?rMr select_schemerCrArBrrrrrnormpathr5)rXrr!r!r"rvsH            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?rMrrDrErrrrsrCrArrr5KeyErrorrWr!r!r"rws(    zinstall.finalize_othercCspttdrtjdkr|dstjdkrd}nd}t|}tD]}d|}t||dur5t ||||q dS) z=Sets the install directories by applying the install schemes.r1))r_homerrrinstall_N) r4r5r~endswithrrrsr0 SCHEME_KEYSrsetattr)rXrsr keyattrnamer!r!r"rs    zinstall.select_schemecCsX|D]'}t||}|dur)tjdkstjdkrtj|}t||j}t|||qdS)NrZr)rrrrsr expanduserr rr)rXattrsattrrr!r!r" _expand_attrss    zinstall._expand_attrscC|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)rDrErFNrrWr!r!r"rszinstall.expand_basedirscCr)z+Calls `os.path.expanduser` on install dirs.)rGrHrJrIrKrLNrrWr!r!r"rszinstall.expand_dirscGs,|D]}d|}t||tt||qdS)z!Call `convert_path` over `names`.rN)rrrrXnamesrsrr!r!r"r$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@rr\zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr[) rPrzrrt isinstancestrrylenr r path_filer)rXrrr!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.rN)rr rFrrr!r!r"rLszinstall.change_rootscCsb|jsdSttjd}|jD]\}}||r.tj|s.| d|t |dqdS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) r?rrrrrritems startswithisdir debug_printmakedirs)rXrCrsrr!r!r"rRs 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.rqz"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)rR run_commandrzget_command_obj plat_namerSr rget_sub_commandsrcreate_path_filerV get_outputsrFrrangeexecutermaprrrrr5normcaserJrQrr)rX build_platcmd_nameoutputsroot_lencountersys_pathrJr!r!r"run^sH    z install.runcCsLtj|j|jd}|jr|t||jgfd|dS| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rrrrrrrQrrrrt)rXfilenamer!r!r"rs  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_commandrappendrrQrrrrr)rXrrcmdrr!r!r"rs     zinstall.get_outputscCs.g}|D]}||}||q|S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)rXinputsrrr!r!r"rs   zinstall.get_inputscCs|jp |jS)zSReturns true if the current distribution has any Python modules to install.)rzhas_pure_modulesrrWr!r!r"has_libs zinstall.has_libcC |jS)zLReturns true if the current distribution has any headers to install.)rz has_headersrWr!r!r"r zinstall.has_headerscCr)zMReturns true if the current distribution has any scripts to. install.)rz has_scriptsrWr!r!r"rrzinstall.has_scriptscCr)zJReturns true if the current distribution has any data to. install.)rzhas_data_filesrWr!r!r"has_datarzinstall.has_datarJrIrKrLinstall_egg_infocCsdS)NTr!rWr!r!r"szinstall.) __name__ __module__ __qualname__ descriptionrboolean_optionsrrrrrYrrurvrwrrrrrrrrrrrrrrrr sub_commandsr!r!r!r"r7ysL; N- " ,  r7)#__doc__r5rrr$rr. distutilsrdistutils.corerdistutils.debugrdistutils.sysconfigrdistutils.errorsrdistutils.file_utilrdistutils.utilrr r r r siter rrWINDOWS_SCHEMEr)rr(r0r6r7r!r!r!r"s           !