o
     JAf                      @   sJ   	 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 )    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   4/usr/lib/python3.10/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)Z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   Z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#   Z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   Z	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   r/   verboser0   )sysdont_write_bytecoder.   Zdistutils.utilr$   get_finalized_commandrootr	   r   r0   r   r1   )r   filesr$   Z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    )	r4   get_outputsgetattrlenr+   sepappendr,   join)
r   Zhas_anyZ	build_cmdZ
cmd_optionZ
output_dirZbuild_filesr   
prefix_lenZ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   Zpy_filenamesZbytecode_filesZpy_fileextr   r   r   _bytecode_filenames   s   


zinstall_lib._bytecode_filenamesc                 C   sT   	 |  | j dd| j}| jr| |}ng }|  | j dd| j}|| | S )Nr(   r   r)   )r?   r"   r#   r   r	   rI   r*   )r   Zpure_outputsZbytecode_outputsZext_outputsr   r   r   r7      s   zinstall_lib.get_outputsc                 C   sN   	 g }| j  r| d}||  | j  r%| d}||  |S r'   )r"   r#   r4   extendr7   r*   )r   Zinputsr(   r)   r   r   r   
get_inputs   s   



zinstall_lib.get_inputsN)__name__
__module____qualname__descriptionZuser_optionsZboolean_optionsZnegative_optr   r   r&   r!   r   r$   r?   rI   r7   rK   r   r   r   r   r      s    		r   )
r+   importlib.utilrE   r2   Zdistutils.corer   Zdistutils.errorsr   rD   r   r   r   r   r   <module>   s    