a XC?h�h�@sdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZdZdddddd�Zdddddd�dddddd�ed�Ze�rdddddd�ed <ddd!d"dd�ed#<dZGd$d%�d%e�ZdS)&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)�purelib�platlib�headers�scripts�dataz/$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_home�ntz $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@seZdZdZgd�Zgd�Zer>e�dddef�e�d�ddiZ d d �Z d d �Z d d�Z dd�Z dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3efd4efd5efd6efd7d8d9�fgZdS):�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=Nz/opt/alt/python39/lib64/python3.9/distutils/command/install.py�initialize_options�s2 zinstall.initialize_optionsc Csz|js|js|jr&|js|jr&td��|jr@|js8|jr@td��|jrl|jsd|jsd|jsd|jsd|jrltd��tjdkr�|jr�|� d�d|_|� d�tjdkr�|� �n|� �|� d�t j��d }td d �\}}z t j}Wnty�d }Yn0|j��|j��|j��|d t jdd�dt jdd�|||||t jd� |_t�rh|j|jd<|j|jd<|��|� d�|j|jd<|j|jd<t�r�d dlm}t d�||j�|�!�|� d�|j�r�|�"�|j#du�r|jj$�r�|j%|_#n|j&|_#|�'dddddddd�|�(�|j#|_)tj*�+|j#|j,�|_#|j-du�r^|�.ddddddd�|� d �|�/d!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)base�posixz+exec-prefix option ignored on this platformNzpre-finalize_{unix,other}zpost-finalize_{unix,other}()rr"r#�z%d.%d�z%d%d) Z dist_nameZ dist_versionZ dist_fullname� py_versionZpy_version_shortZpy_version_nodotZ sys_prefixr"Zsys_exec_prefixr#�abiflags� platlibdir�userbaseZusersitezpost-expand_basedirs()�baseZplatbase)�pprintz config vars:zpost-expand_dirs()�librrrrrZlibbasezafter prepending root�build)r5r5)r6r6)0r"r#r$r%r&r r �os�name�warn� dump_dirs� finalize_unix�finalize_other�sys�version�splitrrA�AttributeError� distributionZget_nameZ get_versionZ get_fullname� version_inforB� config_vars� HAS_USER_SITEr.r/�expand_basedirsrrE�print� expand_dirs�create_home_pathr+Z ext_modulesr)r(� convert_paths�handle_extra_path�install_libbase�path�join� extra_dirsr'� change_rootsZset_undefined_options)r9r@r"r#rArEr:r:r;�finalize_options�s�������         �            �   � �zinstall.finalize_optionscCs�tsdSddlm}t�|d�|jD]r}|d}|ddkrL|dd�}||jvrx|j|}|�|�}t||� }n|�|�}t||�}t�d||�q(dS)zDumps the list of user options.Nr)� longopt_xlate�:������=z %s: %s) rZdistutils.fancy_getoptrbr�debug� user_options� negative_opt� translate�getattr)r9�msgrb�optZopt_name�valr:r:r;rKvs         zinstall.dump_dirscCs"|jdus|jdur\|jdur2|jdur2|jdusP|jdusP|jdusP|jdurXtd��dS|j r�|j durtt d��|j |_|_|� d�n�|j dur�|j |_|_|� d�nl|jdur�|jdur�td��tj�tj�|_tj�tj�|_n|jdu�r|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 prefixr)r%r&r+r(r)r*r,r-r r r.r� select_schemer$r"r#rHr]�normpathrNr8r:r:r;rL�sL ������ �     � zinstall.finalize_unixcCs�|jr8|jdurtd��|j|_|_|�tjd�n~|jdur\|j|_|_|�d�nZ|j durvtj � t j �|_ |j |_|_z|�tj�Wn t y�tdtj��Yn0dS)z)Finalizes options for non-posix platformsNrnZ_userrz)I don't know how to install stuff on '%s')r r.rr%r&rorHrIr$r"r]rprN�KeyErrorr8r:r:r;rM�s& �    �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_KEYSrj�setattr)r9rIZscheme�key�attrnamer:r:r;ro�s zinstall.select_schemecCsX|D]N}t||�}|durtjdks.tjdkr:tj�|�}t||j�}t|||�qdS)Nr=r)rjrHrIr]� expanduserr rTru)r9�attrs�attrrmr:r:r;� _expand_attrs�s   zinstall._expand_attrscCs|�gd��dS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r%r&r'N�r{r8r:r:r;rV�szinstall.expand_basedirscCs|�gd��dS)z+Calls `os.path.expanduser` on install dirs.)r(r)r+r*r,r-Nr|r8r:r:r;rX�szinstall.expand_dirscGs,|D]"}d|}t||tt||���qdS)z!Call `convert_path` over `names`.rrN)rurrj�r9�namesrIrzr:r:r;rZ�szinstall.convert_pathscCs�|jdur|jj|_|jdur�t�d�t|jt�rB|j�d�|_t|j�dkr`|jd}}n"t|j�dkrz|j\}}ntd��t |�}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� isinstance�strrP�lenr r� path_filer_)r9r�r_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.rrN)rur r'rjr}r:r:r;r` szinstall.change_rootscCsb|js dSttj�d��}|j��D]8\}}|�|�r$tj�|�s$|� d|�t� |d�q$dS)zCreate directories under ~.N�~zos.makedirs('%s', 0o700)i�) r rrHr]rxrT�items� startswith�isdirZ debug_print�makedirs)r9r$rIr]r:r:r;rYszinstall.create_home_pathcCs"|js6|�d�|j�d�j}|jr6|t�kr6td��|��D]}|�|�q>|j r\|� �|j r�|� �}|j r�t|j �}tt|��D]}|||d�||<q�|�t|j |fd|j �ttjjtj�}ttjj|�}tj�tj�|j��}|j�r|j �r|j�s||v�rt�d|j�dS)zRuns the command.rGz"Can't install when cross-compilingNz'writing list of installed files to '%s'z�modules 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 r�get_sub_commandsr��create_path_filer7� get_outputsr'r��range�executer�maprHr]rprN�normcaser+r2rrf)r9Z build_plat�cmd_name�outputsZroot_lenZcounterZsys_pathr+r:r:r;�runsD    ������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\r�r2r�rr_rJ)r9�filenamer:r:r;r�Js � �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�) r��get_finalized_commandr��appendr�r2rHr]r^r\)r9r�r��cmdr�r:r:r;r�Xs    �zinstall.get_outputscCs.g}|��D]}|�|�}|�|���q |S)z*Returns the inputs of all the sub-commands)r�r��extend� get_inputs)r9Zinputsr�r�r:r:r;r�is   zinstall.get_inputscCs|j��p|j��S)zSReturns true if the current distribution has any Python modules to install.)rRZhas_pure_modulesZhas_ext_modulesr8r:r:r;�has_libus �zinstall.has_libcCs |j��S)zLReturns true if the current distribution has any headers to install.)rR� has_headersr8r:r:r;r�{szinstall.has_headerscCs |j��S)zMReturns true if the current distribution has any scripts to. install.)rR� has_scriptsr8r:r:r;r��szinstall.has_scriptscCs |j��S)zJReturns true if the current distribution has any data to. install.)rRZhas_data_filesr8r:r:r;�has_data�szinstall.has_datar+r*r,r-Zinstall_egg_infocCsdS)NTr:r8r:r:r;���zinstall.) �__name__� __module__� __qualname__Z descriptionrgZboolean_optionsrUr�rrhr<rarKrLrMror{rVrXrZr[r`rYr�r�r�r�r�r�r�r�Z sub_commandsr:r:r:r;rIsJ;� N(  " ,  �r)�__doc__rNrHZ distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrr r r r Zsiter rrUZWINDOWS_SCHEMErsrtrr:r:r:r;�sb          � ���� �