B ���juh�@sddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZdd lmZdd l mZdd lmZdd lmZd Zdddddd�Zdddddd�dddddd�ed�Ze�rdddddd�ed<ddd d!dd�ed"<dZGd#d$�d$e�ZdS)%�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-packagesz5$platbase/lib64/python$py_version_short/site-packagesz9$base/include/python$py_version_short$abiflags/$dist_namez $base/binz$base/lib/pythonz$base/lib64/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@s:eZdZdZdddddddd d d d d ddddddgZdddgZer`e�dddef�e�d�ddiZ dd�Z dd�Z dd �Z d!d"�Z d#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�ZdEefdFefdGefdHefdIdJdK�fgZdS)L�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<install everything relative to this alternate root directory)zinstall-purelib=Nz;installation directory for pure Python module distributions)zinstall-platlib=Nz8installation directory for non-pure module distributions)z install-lib=Nzginstallation directory for all module distributions (overrides --install-purelib and --install-platlib))zinstall-headers=Nz(installation directory for C/C++ headers)zinstall-scripts=Nz)installation directory for Python scripts)z install-data=Nz%installation directory for data files)�compile�czcompile .py to .pyc [default])z no-compileNzdon't compile .py files)z optimize=�Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])�force�fz1force installation (overwrite any existing files))z skip-buildNz2skip rebuilding everything (for testing/debugging))zrecord=Nz3filename in which to record list of installed filesrrz skip-build�userNz!install in user site-package '%s'z no-compilecCs�d|_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)Nr�)�prefix� exec_prefix�homer� install_base�install_platbase�root�install_purelib�install_platlib�install_headers� install_lib�install_scripts� install_datar �install_userbaser�install_usersiter�optimize� extra_path�install_path_filer� skip_build�warn_dir� build_base� build_lib�record)�self�r7�>/opt/alt/python37/lib64/python3.7/distutils/command/install.py�initialize_options�s2 zinstall.initialize_optionsc Csx|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 �\}}y t j}Wntk r�d }YnX|j��|j��|j��|d t jdd �dt jdd �|||||d� |_t�rf|j|jd<|j|jd<|��|� d�|j|jd<|j|jd<t�r�ddlm}td�||j�|� �|� d�|j�r�|�!�|j"dk�r�|jj#�r�|j$|_"n|j%|_"|�&dddddddd�|�'�|j"|_(tj)�*|j"|j+�|_"|j,dk �r\|�-ddddddd�|� d�|�.d d!d"�dS)#NzWmust 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 platformzpre-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�userbaseZusersitezpost-expand_basedirs()�baseZplatbase)�pprintz config vars:zpost-expand_dirs()�librrrrrZlibbasezafter prepending root�build)r3r3)r4r4)/r r!r"r#r$r r�os�name�warn� dump_dirs� finalize_unix�finalize_other�sys�version�splitrr>�AttributeError� distributionZget_nameZ get_versionZ get_fullname� version_info� config_vars� HAS_USER_SITEr,r-�expand_basedirsrrA�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)r6r=r r!r>rAr7r7r8�finalize_options�s�                           zinstall.finalize_optionscCs�tsdSddlm}t�|d�x||jD]r}|d}|ddkrN|dd�}||jkrz|j|}|�|�}t||� }n|�|�}t||�}t�d||�q*WdS)Nr)� longopt_xlate�:����=z %s: %s) rZdistutils.fancy_getoptr^r�debug� user_options� negative_opt� translate�getattr)r6�msgr^�optZopt_name�valr7r7r8rGus         zinstall.dump_dirscCs"|jdk s|jdk r\|jdkr2|jdkr2|jdksP|jdksP|jdksP|jdkrXtd��dS|j r�|j dkrtt d��|j |_|_|� d�n�|j dk r�|j |_|_|� d�nl|jdkr�|jdk r�td��tj�tj�|_tj�tj�|_n|jdk�r|j|_|j|_|j|_|� d�dS)NzPinstall-base or install-platbase supplied, but installation scheme is incompletez$User base directory is not specifiedrrz*must not supply exec-prefix without prefixr)r#r$r)r&r'r(r*r+r rr,r� select_schemer"r r!rDrY�normpathrJ)r6r7r7r8rH�s<             zinstall.finalize_unixcCs�|jr8|jdkrtd��|j|_|_|�tjd�n�|jdk r\|j|_|_|�d�n\|j dkrvtj � t j �|_ |j |_|_y|�tj�Wn"t k r�tdtj��YnXdS)Nz$User base directory is not specifiedZ_userrz)I don't know how to install stuff on '%s')rr,rr#r$rjrDrEr"r rYrkrJ�KeyError)r6r7r7r8rI�s"    zinstall.finalize_othercCs@t|}x2tD]*}d|}t||�dkrt||||�qWdS)N�install_)�INSTALL_SCHEMES� SCHEME_KEYSrf�setattr)r6rEZscheme�keyZattrnamer7r7r8rj�s  zinstall.select_schemecCs\xV|D]N}t||�}|dk rtjdks0tjdkr<tj�|�}t||j�}t|||�qWdS)Nr:r)rfrDrErY� expanduserr rPrp)r6Zattrs�attrrir7r7r8� _expand_attrs�s    zinstall._expand_attrscCs|�dddg�dS)Nr#r$r%)rt)r6r7r7r8rR�szinstall.expand_basedirscCs|�ddddddg�dS)Nr&r'r)r(r*r+)rt)r6r7r7r8rT�szinstall.expand_dirscGs0x*|D]"}d|}t||tt||���qWdS)Nrm)rprrf)r6�namesrErsr7r7r8rV�s zinstall.convert_pathscCs�|jdkr|jj|_|jdk r�t�d�t|jt�rB|j�d�|_t|j�dkr`|jd}}n"t|j�dkrz|j\}}ntd��t |�}nd}d}||_ ||_ dS)NzIDistribution option extra_path is deprecated. See issue27919 for details.�,rrr<zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr;) r/rNrrF� isinstance�strrL�lenr r� path_filer[)r6rzr[r7r7r8rW�s$      zinstall.handle_extra_pathc Gs4x.|D]&}d|}t||t|jt||���qWdS)Nrm)rpr r%rf)r6rurErsr7r7r8r\ s zinstall.change_rootscCsf|js dSttj�d��}xF|j��D]8\}}|�|�r&tj�|�s&|� d|�t� |d�q&WdS)N�~zos.makedirs('%s', 0o700)i�) rrrDrYrrrP�items� startswith�isdirZ debug_print�makedirs)r6r"rErYr7r7r8rUszinstall.create_home_pathcCs*|js6|�d�|j�d�j}|jr6|t�kr6td��x|��D]}|�|�q@W|j r`|� �|j r�|� �}|j r�t|j �}x(tt|��D]}|||d�||<q�W|�t|j |fd|j �ttjjtj�}ttjj|�}tj�tj�|j��}|j�r&|j �r|j�s&||k�r&t�d|j�dS)NrCz"Can't install when cross-compilingz'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)r1Z run_commandrNZget_command_objZ plat_namer2r r�get_sub_commandsrz�create_path_filer5� get_outputsr%ry�range�executer�maprDrYrkrJ�normcaser)r0rrb)r6Z build_plat�cmd_name�outputsZroot_lenZcounterZsys_pathr)r7r7r8�runs6    z install.runcCsJtj�|j|jd�}|jr8|�t||jgfd|�n|� d|�dS)Nz.pthz creating %szpath file '%s' not created) rDrYrZrXrzr0r�rr[rF)r6�filenamer7r7r8r�Is    zinstall.create_path_filecCspg}x>|��D]2}|�|�}x"|��D]}||kr&|�|�q&WqW|jrl|jrl|�tj�|j |jd��|S)Nz.pth) r��get_finalized_commandr��appendrzr0rDrYrZrX)r6r�r��cmdr�r7r7r8r�Ws  zinstall.get_outputscCs2g}x(|��D]}|�|�}|�|���qW|S)N)r�r��extend� get_inputs)r6Zinputsr�r�r7r7r8r�hs  zinstall.get_inputscCs|j��p|j��S)N)rNZhas_pure_modulesZhas_ext_modules)r6r7r7r8�has_libts zinstall.has_libcCs |j��S)N)rN� has_headers)r6r7r7r8r�zszinstall.has_headerscCs |j��S)N)rN� has_scripts)r6r7r7r8r�szinstall.has_scriptscCs |j��S)N)rNZhas_data_files)r6r7r7r8�has_data�szinstall.has_datar)r(r*r+Zinstall_egg_infocCsdS)NTr7)r6r7r7r8�<lambda>��zinstall.<lambda>) �__name__� __module__� __qualname__� descriptionrcZboolean_optionsrQr�rrdr9r]rGrHrIrjrtrRrTrVrWr\rUr�r�r�r�r�r�r�r�Z sub_commandsr7r7r7r8rIsh    N(  " , r)rJrDZ distutilsrZdistutils.corerZdistutils.debugrZdistutils.sysconfigrZdistutils.errorsrZdistutils.file_utilrZdistutils.utilrr r r r Zsiter rrQZWINDOWS_SCHEMErnrorr7r7r7r8�<module>sT