a oeu @sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddlm Z ddl mZdd lmZmZmZdd lmZdd lmZmZd d lmZddlmZddlmZddlmZdZddddddZddddddddddddeddddddddddddd Z erJd!d!d"d#d$de d%<d!d!d&d'd$de d(<e !ej"dZ#d)d*Z$d+d,Z%d-d.Z&d/d0Z'd1d2Z(d3d4Z)d5d6Z*d7d8Z+d9d: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) write_file) convert_path subst_vars change_root) get_platform)DistutilsOptionErrorDistutilsPlatformError)_framework_compat) _collections) 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_homentpypyZpypy_ntz {usersite}zF{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}z:{userbase}/{implementation}{py_version_nodot_plat}/Scriptsz {userbase}Znt_userzQ{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z{userbase}/bin posix_usercCs@tt"ddtDWdS1s20YdS)NcSsi|]}|tj|ddqS)F)expand) sysconfigZ get_paths.0schemer"FC:\Program Files\Certbot\pkgs\setuptools\_distutils\command\install.py esz+_load_sysconfig_schemes..) contextlibsuppressAttributeErrorrZget_scheme_namesr"r"r"r#_load_sysconfig_schemescs r(cs(tpifddtttDS)z= Extend default schemes with schemes from sysconfig. cs*i|]"}|it|i|iqSr")INSTALL_SCHEMESgetrZsysconfig_schemesr"r#r$rs   z!_load_schemes..)r(set itertoolschainr)r"r"r+r# _load_schemesks  r/cCsttdrdSdSdS)Npypy_version_infoZPyPyPython)hasattrsysr"r"r"r#_get_implementation{s r4cCs.t|tt|}t|t|t|dSN)_inject_headers _load_scheme_resolve_schemevarsupdate _remove_set _scheme_attrs)obnamer!r"r"r#_select_schemesr?csfdd|DS)z1 Include only attrs that are None in ob. cs$i|]\}}t|dur||qSr5)getattr)r keyvaluer=r"r#r$z_remove_set..)items)r=attrsr"rCr#r;sr;cCsD|d\}}}zt|}Wn ty>tt|}Yn0|S)N_) partitionrZget_preferred_scheme Exceptionfwr! _pypy_hack)r>Zos_nameseprAZresolvedr"r"r#r8s  r8cCs t|Sr5)r/)r>r"r"r#r7sr7cCs tt|}|d|d|S)z Given a scheme name and the resolved scheme, if the scheme does not include headers, resolve the fallback scheme for the name and use headers from it. pypa/distutils#88 r)r7rK setdefault)r>r!fallbackr"r"r#r6s r6csfddtDS)z.) SCHEME_KEYSrPr"rPr#r<sr<cCsFtjdk}ttdo|}|d }ddtjdk}|rB|rB|S|S)N)r0)_user_homerZ_ntr)r3 version_infor2endswithosr>)r>ZPY37Zold_pypyprefixZ pypy_namer"r"r#rKs   rKc@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=Nzwarn dump_dirs finalize_unixfinalize_otherr3versionsplitrrr' distributionZget_nameZ get_versionZ get_fullnamerVr@r4lowerdictreplace HAS_USER_SITErnrorZ DictStackrJr9r config_varsexpand_basedirsrrprint expand_dirscreate_home_pathrkhas_ext_modulesrirh convert_pathshandle_extra_pathinstall_libbasepathjoin extra_dirsrg change_rootsZset_undefined_options)ryrrYrcrZ local_varsZ compat_varsrr"r"r#finalize_optionsLs                      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_xlate:r=z %s: %s) rZ fancy_getoptrrdebug user_options negative_opt translater@)rymsgroptZopt_namevalr"r"r#rs         zinstall.dump_dirscCs<|jdus|jdur`|jdur2|jdur2|jdupN|jdupN|jdupN|jdu}|r\tddS|j r|j durxt d|j |_|_| dn|j dur|j |_|_| dn|jdur |jdurtdttdd}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)rerfrkrhrirjrlrmr rbrnr select_schemerdrYrcr@rrXrnormpathr3)ryZincomplete_schemerr"r"r#rsL          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 platformsNrrTrz)I don't know how to install stuff on '%s')rbrnr rerfrrXr>rdrYrrr3KeyErrorrxr"r"r#rFs"     zinstall.finalize_othercCst||dSr5)r?)ryr>r"r"r#r\szinstall.select_schemecCsN|D]D}t||}|durtjdvr0tj|}t||j}t|||qdS)N)r{r)r@rXr>r expanduserr rsetattr)ryrFattrrr"r"r# _expand_attrs_s    zinstall._expand_attrscCs|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)rerfrgNrrxr"r"r#rhszinstall.expand_basedirscCs|gddS)z+Calls `os.path.expanduser` on install dirs.)rhrirkrjrlrmNrrxr"r"r#rmszinstall.expand_dirscGs,|D]"}d|}t||tt||qdS)z!Call `convert_path` over `names`.rON)rrr@rynamesr>rr"r"r#rzszinstall.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.,rrrzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr|) rqrrZwarning isinstancestrrlenr r path_filer)ryrrr"r"r#rs(      zinstall.handle_extra_pathc Gs0|D]&}d|}t||t|jt||qdS)z:Change the install directories pointed by name using root.rON)rr rgr@rr"r"r#rszinstall.change_rootscCsf|js dSttjd}|jD]<\}}t||r$tj |s$| d|t |dq$dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) rbrrXrrrrEr startswithisdirZ debug_printmakedirs)ryrdr>rr"r"r#rszinstall.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.rz"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)rsZ run_commandrZget_command_objZ plat_namertr r get_sub_commandsrcreate_path_filerw get_outputsrgrrangeexecutermaprXrrr3normcaserkrrrr)ryZ build_platcmd_nameoutputsZroot_lenZcounterZsys_pathrkr"r"r#runsF    z install.runcCsJtj|j|jd}|jr8|t||jgfd|n| d|dS)zCreates the .pth file.pthz creating %szpath file '%s' not createdN) rXrrrrrrrrrr)ryfilenamer"r"r#rs 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_commandrappendrrrrXrrr)ryrrcmdrr"r"r#rs    zinstall.get_outputscCs.g}|D]}||}||q |S)z*Returns the inputs of all the sub-commands)rrextend get_inputs)ryZinputsrrr"r"r#rs   zinstall.get_inputscCs|jp|jS)zSReturns true if the current distribution has any Python modules to install.)rZhas_pure_modulesrrxr"r"r#has_libszinstall.has_libcCs |jS)zLReturns true if the current distribution has any headers to install.)r has_headersrxr"r"r#rszinstall.has_headerscCs |jS)zMReturns true if the current distribution has any scripts to. install.)r has_scriptsrxr"r"r#rszinstall.has_scriptscCs |jS)zJReturns true if the current distribution has any data to. install.)rZhas_data_filesrxr"r"r#has_data szinstall.has_datarkrjrlrmZinstall_egg_infocCsdS)NTr"rxr"r"r#,rDzinstall.) __name__ __module__ __qualname__ descriptionrZboolean_optionsrrrrrzrrrrrrrrrrrrrrrrrrrrZ sub_commandsr"r"r"r#rZsJ<  M61  # 2   rZ)/__doc__r3rXr%rr-Zdistutils._logrZcorerrrrZ file_utilrutilrr r r errorsr r r|rrJrZsiterrrZWINDOWS_SCHEMEr)r:ZschemesrQr(r/r4r?r;r8r7r6r<rKrZr"r"r"r#s            #