3 \� �@sHddlZddlZddlZddlmZddlmZdZGdd�de�Z dS)�N)�Command)�DistutilsOptionErrorz.pyc @s�eZdZdZd*d+d,d-d.d/d0gZdd dgZdd iZdd�Zdd�Zdd�Z dd�Z dd�Z d d!�Z d"d#�Z d$d%�Zd&d'�Zd(d)�ZdS)1� install_libz7install all Python modules (extensions and pure Python)� install-dir=�d�directory to install to� build-dir=�b�'build directory (where to install from)�force�f�-force installation (overwrite existing files)�compile�c�compile .py to .pyc [default]� no-compileN�don't compile .py files� optimize=�O�lalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]� skip-build�skip the build stepscCs(d|_d|_d|_d|_d|_d|_dS)Nr)� install_dir� build_dirr r�optimize� skip_build)�self�r�5/usr/lib64/python3.6/distutils/command/install_lib.py�initialize_options3s zinstall_lib.initialize_optionsc Cs�|jddddddd�|jdkr&d |_|jdkr6d |_t|jt�s�yt|j�|_|jdkr^t�Wn ttfk r�td��YnXdS)N�install� build_librrrr rrrTFr��zoptimize must be 0, 1, or 2)r!r)rr)r r )rr)rr)rr)rr"r#)Zset_undefined_optionsrr� isinstance�int�AssertionError� ValueErrorr)rrrr�finalize_options<s$     zinstall_lib.finalize_optionscCs0|j�|j�}|dk r,|jj�r,|j|�dS)N)�buildr � distribution�has_pure_modules� byte_compile)r�outfilesrrr�runVszinstall_lib.runcCs2|js.|jj�r|jd�|jj�r.|jd�dS)N�build_py� build_ext)rr*r+Z run_command�has_ext_modules)rrrrr)fs    zinstall_lib.buildcCs8tjj|j�r |j|j|j�}n|jd|j�dS|S)Nz3'%s' does not exist -- no Python modules to install)�os�path�isdirrZ copy_treer�warn)rr-rrrr ms  zinstall_lib.installcCsrtjr|jd�dSddlm}|jd�j}|jrH||d|j||j d�|j dkrn|||j |j||j |j d�dS)Nz%byte-compiling is disabled, skipping.r)r,r )rr �prefix�dry_run)rr r6�verboser7) �sys�dont_write_bytecoder5Zdistutils.utilr,�get_finalized_command�rootrr r7rr8)r�filesr,Z install_rootrrrr,vs     zinstall_lib.byte_compilec Csh|sgS|j|�}|j�}t||�}t|�ttj�}g}x(|D] } |jtjj|| |d���q@W|S)N) r;� get_outputs�getattr�lenr2�sep�appendr3�join) rZhas_anyZ build_cmdZ cmd_optionZ output_dirZ build_filesrZ prefix_lenZoutputs�filerrr�_mutate_outputs�s    zinstall_lib._mutate_outputscCsvg}xl|D]d}tjjtjj|��d}|tkr0q |jrL|jtjj |dd��|j dkr |jtjj ||j d��q W|S)Nr"�)� optimizationr) r2r3�splitext�normcase�PYTHON_SOURCE_EXTENSIONrrB� importlib�util�cache_from_sourcer)rZ py_filenamesZbytecode_filesZpy_fileZextrrr�_bytecode_filenames�s     zinstall_lib._bytecode_filenamescCsR|j|jj�dd|j�}|jr*|j|�}ng}|j|jj�dd|j�}|||S)Nr/r!r0)rEr*r+rrrNr1)rZ pure_outputsZbytecode_outputsZ ext_outputsrrrr>�s   zinstall_lib.get_outputscCsLg}|jj�r&|jd�}|j|j��|jj�rH|jd�}|j|j��|S)Nr/r0)r*r+r;�extendr>r1)rZinputsr/r0rrr� get_inputs�s    zinstall_lib.get_inputs)rrr)rr r )r r r )rrr)rNr)rrr)rNr)�__name__� __module__� __qualname__Z descriptionZ user_optionsZboolean_optionsZ negative_optrr(r.r)r r,rErNr>rPrrrrrs*   r) r2�importlib.utilrKr9Zdistutils.corerZdistutils.errorsrrJrrrrr�s