B � f� �@sLdZddlZddlZddlZddlmZddlmZdZ Gdd�de�Z dS)zkdistutils.command.install_lib Implements the Distutils 'install_lib' command (install all Python modules).�N)�Command)�DistutilsOptionErrorz.pyc@s�eZdZdZdddddddgZd d d gZd d iZd d�Zdd�Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd �Zd!S)"� install_libz7install all Python modules (extensions and pure Python))z install-dir=�dzdirectory to install to)z build-dir=�bz'build directory (where to install from))�force�fz-force installation (overwrite existing 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])z skip-buildNzskip the build stepsrr z skip-buildz no-compilecCs(d|_d|_d|_d|_d|_d|_dS)Nr)� install_dir� build_dirrr �optimize� skip_build)�self�r�B/opt/alt/python37/lib64/python3.7/distutils/command/install_lib.py�initialize_options3s zinstall_lib.initialize_optionsc Cs�|�ddddddd�|jdkr&d|_|jdkr6d |_t|jt�s�yt|j�|_|jd kr^t�Wn ttfk r�td ��YnXdS) N�install)� build_libr )rr )rr)r r )rr)rrTF)r��zoptimize must be 0, 1, or 2)Zset_undefined_optionsr r� isinstance�int�AssertionError� ValueErrorr)rrrr�finalize_options<s$     zinstall_lib.finalize_optionscCs0|��|��}|dk r,|j��r,|�|�dS)N)�buildr� distribution�has_pure_modules� byte_compile)r�outfilesrrr�runVszinstall_lib.runcCs2|js.|j��r|�d�|j��r.|�d�dS)N�build_py� build_ext)rrrZ run_command�has_ext_modules)rrrrrfs    zinstall_lib.buildcCs8tj�|j�r |�|j|j�}n|�d|j�dS|S)Nz3'%s' does not exist -- no Python modules to install)�os�path�isdirr Z copy_treer �warn)rr!rrrrms  zinstall_lib.installcCsrtjr|�d�dSddlm}|�d�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)rrr*�verboser+) �sys�dont_write_bytecoder)Zdistutils.utilr �get_finalized_command�rootr rr+rr,)r�filesr Z install_rootrrrr vs     zinstall_lib.byte_compilec Csh|sgS|�|�}|��}t||�}t|�ttj�}g}x(|D] } |�tj�|| |d���q@W|S)N) r/� get_outputs�getattr�lenr&�sep�appendr'�join) rZhas_anyZ build_cmdZ cmd_optionZ output_dirZ build_filesr � prefix_lenZoutputs�filerrr�_mutate_outputs�s    zinstall_lib._mutate_outputscCsvg}xl|D]d}tj�tj�|��d}|tkr0q |jrL|�tjj |dd��|j dkr |�tjj ||j d��q W|S)Nr�)� optimizationr) r&r'�splitext�normcase�PYTHON_SOURCE_EXTENSIONr r6� importlib�util�cache_from_sourcer)rZ py_filenamesZbytecode_filesZpy_fileZextrrr�_bytecode_filenames�s     zinstall_lib._bytecode_filenamescCsR|�|j��dd|j�}|jr*|�|�}ng}|�|j��dd|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#rr$)r:rrr r rCr%)rZ pure_outputsZbytecode_outputsZ ext_outputsrrrr2�s   zinstall_lib.get_outputscCsLg}|j��r&|�d�}|�|���|j��rH|�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$)rrr/�extendr2r%)rZinputsr#r$rrr� get_inputs�s    zinstall_lib.get_inputsN)�__name__� __module__� __qualname__Z descriptionZ user_optionsZboolean_optionsZ negative_optrrr"rrr r:rCr2rErrrrrs(   r) �__doc__r&�importlib.utilr@r-Zdistutils.corerZdistutils.errorsrr?rrrrr�s