o
    Ee                      @   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   j/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.pyinitialize_options6   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      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   runZ   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"   j   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   q   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   r   prefixdry_run)r   r   r2   verboser3   )sysdont_write_bytecoder1   utilr%   get_finalized_commandrootr
   r   r3   r   r4   )r   filesr%   install_rootr   r   r   r%   {   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@   	importlibr7   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 )zReturn 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
   rV   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 )zGet 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   rV   r<   r\   r   r   r   r   r      s    	
!r   )__doc__r-   importlib.utilrP   r5   corer   errorsr   rO   r   r   r   r   r   <module>   s    