o
    Ëý°jÍ   ã                   @   sL   d Z ddlZddlZddlZddlmZ ddlmZ dZ	G dd„ deƒZ
dS )zkdistutils.command.install_lib

Implements the Distutils 'install_lib' command
(install all Python modules).é    N)ÚCommand)ÚDistutilsOptionErrorz.pyc                   @   sx   e Zd ZdZg d¢Zg d¢ZddiZdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )Úinstall_libz7install all Python modules (extensions and pure Python)))zinstall-dir=Údzdirectory to install to)z
build-dir=Úbz'build directory (where to install from))ÚforceÚfz-force installation (overwrite existing files))ÚcompileÚczcompile .py to .pyc [default])ú
no-compileNzdon't compile .py files)z	optimize=ÚOzlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])ú
skip-buildNzskip the build steps)r   r	   r   r   r	   c                 C   s(   d | _ d | _d| _d | _d | _d | _d S )Nr   )Úinstall_dirÚ	build_dirr   r	   ÚoptimizeÚ
skip_build©Úself© r   úœ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.pyÚinitialize_options3   s   
zinstall_lib.initialize_optionsc              	   C   s‚   |   ddddddd¡ | jd u rd| _| jd u rd	| _t| jtƒs?zt| jƒ| _| jd
vr/t‚W d S  ttfy>   tdƒ‚w d S )NÚinstall)Ú	build_libr   )r   r   )r   r   )r	   r	   )r   r   )r   r   TF)r   é   é   zoptimize must be 0, 1, or 2)Úset_undefined_optionsr	   r   Ú
isinstanceÚintÚAssertionErrorÚ
ValueErrorr   r   r   r   r   Úfinalize_options<   s,   ú
	

ÿÿûzinstall_lib.finalize_optionsc                 C   s8   |   ¡  |  ¡ }|d ur| j ¡ r|  |¡ d S d S d S ©N)Úbuildr   ÚdistributionÚhas_pure_modulesÚbyte_compile©r   Úoutfilesr   r   r   ÚrunV   s
   ÿzinstall_lib.runc                 C   s:   | j s| j ¡ r|  d¡ | j ¡ r|  d¡ d S d S d S )NÚbuild_pyÚ	build_ext)r   r#   r$   Úrun_commandÚhas_ext_modulesr   r   r   r   r"   f   s   


üzinstall_lib.buildc                 C   s6   t j | j¡r|  | j| j¡}|S |  d| j ¡ d S )Nz3'%s' does not exist -- no Python modules to install)ÚosÚpathÚisdirr   Ú	copy_treer   Úwarnr&   r   r   r   r   m   s   ýÿzinstall_lib.installc                 C   sv   t jr
|  d¡ d S ddlm} |  d¡j}| jr$||d| j|| j	d� | j
dkr9||| j
| j|| j| j	d� d S d S )Nz%byte-compiling is disabled, skipping.r   )r%   r   )r   r   ÚprefixÚdry_run)r   r   r2   Úverboser3   )ÚsysÚdont_write_bytecoder1   Údistutils.utilr%   Úget_finalized_commandÚrootr	   r   r3   r   r4   )r   Úfilesr%   Úinstall_rootr   r   r   r%   v   s    
þ

þÿzinstall_lib.byte_compilec           
   	   C   sd   |sg S |   |¡}| ¡ }t||ƒ}t|ƒttjƒ }g }|D ]}	| tj ||	|d … ¡¡ q|S r!   )	r8   Úget_outputsÚgetattrÚlenr-   ÚsepÚappendr.   Újoin)
r   Úhas_anyÚ	build_cmdÚ
cmd_optionÚ
output_dirÚbuild_filesr   Ú
prefix_lenÚoutputsÚfiler   r   r   Ú_mutate_outputs�   s   

zinstall_lib._mutate_outputsc                 C   sr   g }|D ]2}t j t j |¡¡d }|tkrq| jr%| tjj	|dd�¡ | j
dkr6| tjj	|| j
d�¡ q|S )Nr   Ú )Úoptimizationr   )r-   r.   ÚsplitextÚnormcaseÚPYTHON_SOURCE_EXTENSIONr	   r@   Ú	importlibÚutilÚcache_from_sourcer   )r   Úpy_filenamesÚbytecode_filesÚpy_fileÚextr   r   r   Ú_bytecode_filenamesž   s   
ÿ

ÿ€zinstall_lib._bytecode_filenamesc                 C   sR   |   | j ¡ dd| j¡}| jr|  |¡}ng }|   | j ¡ dd| j¡}|| | S )zÁReturn the list of files that would be installed if this command
        were actually run.  Not affected by the "dry-run" flag or whether
        modules have actually been built yet.
        r)   r   r*   )rJ   r#   r$   r   r	   rW   r,   )r   Úpure_outputsÚbytecode_outputsÚext_outputsr   r   r   r<   ´   s   þÿþÿzinstall_lib.get_outputsc                 C   sL   g }| j  ¡ r|  d¡}| | ¡ ¡ | j  ¡ r$|  d¡}| | ¡ ¡ |S )zþGet the list of files that are input to this command, ie. the
        files that get installed as they are named in the build tree.
        The files in this list correspond one-to-one to the output
        filenames returned by 'get_outputs()'.
        r)   r*   )r#   r$   r8   Úextendr<   r,   )r   Úinputsr)   r*   r   r   r   Ú
get_inputsÉ   s   



zinstall_lib.get_inputsN)Ú__name__Ú
__module__Ú__qualname__ÚdescriptionÚuser_optionsÚboolean_optionsÚnegative_optr   r    r(   r"   r   r%   rJ   rW   r<   r]   r   r   r   r   r      s    		r   )Ú__doc__r-   Úimportlib.utilrP   r5   Údistutils.corer   Údistutils.errorsr   rO   r   r   r   r   r   Ú<module>   s    