Your IP : 18.118.144.50


Current Path : /opt/alt/python34/lib64/python3.4/distutils/command/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/distutils/command/__pycache__/build_py.cpython-34.pyo

�
i f
C�@s�dZddlZddlZddlZddlmZddlmZddlTddl	m
Z
mZddlm
Z
Gdd	�d	e�ZGd
d�dee�ZdS)zHdistutils.command.build_py

Implements the Distutils 'build_py' command.�N)�glob)�Command)�*)�convert_path�	Mixin2to3)�logc@s+eZdZdZd8d9d:d;d<gZddgZidd6Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd	S)=�build_pyz5"build" pure Python modules (copy to build directory)�
build-lib=�d�directory to "build" (copy) to�compile�c�compile .py to .pyc�
no-compileN�!don't compile .py files [default]�	optimize=�O�lalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]�force�f�2forcibly build everything (ignore file timestamps)cCsLd|_d|_d|_d|_d|_d|_d|_d|_dS)Nr)�	build_lib�
py_modules�package�package_data�package_dirr�optimizer)�self�r�?/opt/alt/python34/lib64/python3.4/distutils/command/build_py.py�initialize_options s							zbuild_py.initialize_optionscCs�|jddd�|jj|_|jj|_|jj|_i|_|jjr�x6|jjj�D]\}}t|�|j|<qhWn|j�|_	t
|jt�s�yt|j�|_Wq�t
tfk
r�td��Yq�XndS)NZbuildrrzoptimize must be 0, 1, or 2)�	build_libr!)�forcer")Zset_undefined_options�distribution�packagesrrr�itemsr�get_data_files�
data_files�
isinstancer�int�
ValueError�AssertionErrorZDistutilsOptionError)r�name�pathrrr�finalize_options*s"		zbuild_py.finalize_optionscCsS|jr|j�n|jr6|j�|j�n|j|jdd��dS)N�include_bytecoder)r�
build_modulesr$�build_packages�build_package_data�byte_compile�get_outputs)rrrr�runCs	
	

zbuild_py.runcs�g}|js|Sx�|jD]�}|j|�}tjj|jg|jd��}d�|rvt|�d�n�fdd�|j||�D�}|j	||||f�qW|S)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples�.r�cs g|]}|�d��qS)Nr)�.0�file)�plenrr�
<listcomp>ts	z+build_py.get_data_files.<locals>.<listcomp>)
r$�get_package_dir�osr-�joinr�split�len�find_data_files�append)r�datar�src_dir�	build_dir�	filenamesr)r:rr&as	%%zbuild_py.get_data_filescs�|jjdg�|jj|g�}g�xO|D]G}ttjj|t|���}�j�fdd�|D��q5W�S)z6Return filenames for package's data files in 'src_dir'�cs4g|]*}|�krtjj|�r|�qSr)r=r-�isfile)r8�fn)�filesrrr;�s	z,build_py.find_data_files.<locals>.<listcomp>)r�getrr=r-r>r�extend)rrrDZglobs�patternZfilelistr)rJrrAys
!$zbuild_py.find_data_filescCs�d}x�|jD]v\}}}}xa|D]Y}tjj||�}|jtjj|��|jtjj||�|dd�q)WqWdS)z$Copy data files into build directoryN�
preserve_modeF)r'r=r-r>�mkpath�dirname�	copy_file)rZlastdirrrDrErF�filename�targetrrrr2�s
zbuild_py.build_package_datacCs|jd�}|js5|r.tjj|�SdSn�g}x�|r�y|jdj|�}Wn-tk
r�|jd|d�|d=Yq>X|jd|�tjj|�Sq>W|jjd�}|dk	r�|jd|�n|r�tjj|�SdSdS)z�Return the directory, relative to the top of the source
           distribution, where package 'package' should be found
           (at least according to the 'package_dir' option, if any).r6rGrr7N���rT)r?rr=r-r>�KeyError�insertrK)rrr-�tailZpdirrrrr<�s(		
	zbuild_py.get_package_dircCs�|dkrYtjj|�s1td|��ntjj|�sYtd|��qYn|r�tjj|d�}tjj|�r�|Stjdd|�ndS)NrGz%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz__init__.pyz!package init file '%s' not found z(or not a regular file))	r=r-�existsZDistutilsFileError�isdirr>rHr�warn)rrr�init_pyrrr�
check_package�s	zbuild_py.check_packagecCs1tjj|�s)tjd||�dSdSdS)Nz!file %s (for module %s) not foundFT)r=r-rHrrZ)r�module�module_filerrr�check_module�szbuild_py.check_modulec	Cs�|j||�ttjj|d��}g}tjj|jj�}xx|D]p}tjj|�}||kr�tjjtjj	|��d}|j
|||f�qP|jd|�qPW|S)Nz*.pyrzexcluding %s)r\rr=r-r>�abspathr#Zscript_name�splitext�basenamerBZdebug_print)	rrrZmodule_files�modulesZsetup_scriptrZabs_fr]rrr�find_package_modules�s
"zbuild_py.find_package_modulesc
Cs%i}g}x|jD]}|jd�}dj|dd��}|d}y||\}}Wn'tk
r�|j|�}d}YnX|s�|j||�}	|df||<|	r�|j|d|	f�q�ntjj||d�}
|j	||
�sqn|j|||
f�qW|S)a�Finds individually-specified Python modules, ie. those listed by
        module name in 'self.py_modules'.  Returns a list of tuples (package,
        module_base, filename): 'package' is a tuple of the path through
        package-space to the module; 'module_base' is the bare (no
        packages, no dots) module name, and 'filename' is the path to the
        ".py" file (relative to the distribution root) that implements the
        module.
        r6rr7�__init__z.pyrTrT)
rr?r>rUr<r\rBr=r-r_)rr$rcr]r-rZmodule_baserZcheckedr[r^rrr�find_modules�s*

zbuild_py.find_modulescCswg}|jr%|j|j��n|jrsxB|jD]4}|j|�}|j||�}|j|�q8Wn|S)a4Compute the list of all modules that will be built, whether
        they are specified one-module-at-a-time ('self.py_modules') or
        by whole packages ('self.packages').  Return a list of tuples
        (package, module, module_file), just like 'find_modules()' and
        'find_package_modules()' do.)rrLrfr$r<rd)rrcrr�mrrr�find_all_moduless		zbuild_py.find_all_modulescCsdd�|j�D�S)NcSsg|]}|d�qS)r7rTr)r8r]rrrr;-s	z-build_py.get_source_files.<locals>.<listcomp>)rh)rrrr�get_source_files,szbuild_py.get_source_filescCs.|gt|�|dg}tjj|�S)Nz.py)�listr=r-r>)rrErr]Zoutfile_pathrrr�get_module_outfile/szbuild_py.get_module_outfiler7cCs�|j�}g}x�|D]�\}}}|jd�}|j|j||�}|j|�|r|jr�|jtjj|dd��n|j	dkr�|jtjj|dd��q�qqW|dd�|j
D�7}|S)Nr6�debug_overrideTrFcSs>g|]4\}}}}|D]}tjj||��qqSr)r=r-r>)r8rrDrErFrRrrrr;Cs	z(build_py.get_outputs.<locals>.<listcomp>)rhr?rkrrBr�	importlib�util�cache_from_sourcerr')rr/rcZoutputsrr]r^rRrrrr43s"
		zbuild_py.get_outputscCs�t|t�r!|jd�}n$t|ttf�sEtd��n|j|j||�}tj	j
|�}|j|�|j||dd�S)Nr6z:'package' must be a string (dot-separated), list, or tuplerNr)
r(�strr?rj�tuple�	TypeErrorrkrr=r-rPrOrQ)rr]r^rZoutfile�dirrrr�build_moduleJs
zbuild_py.build_modulecCs=|j�}x*|D]"\}}}|j|||�qWdS)N)rfrt)rrcrr]r^rrrr0Yszbuild_py.build_modulescCsfx_|jD]T}|j|�}|j||�}x*|D]"\}}}|j|||�q8Wq
WdS)N)r$r<rdrt)rrrrcZpackage_r]r^rrrr1bs

zbuild_py.build_packagesc
Cs�tjr|jd�dSddlm}|j}|d	tjkrV|tj}n|jr�||ddd|j	d|d|j
�n|jdkr�||d|jd|j	d|d|j
�ndS)
Nz%byte-compiling is disabled, skipping.r)r3r7rr�prefix�dry_runrT)�sys�dont_write_bytecoderZ�distutils.utilr3rr=�seprrrvr)rrJr3rurrrr3vs	
		zbuild_py.byte_compile)r	r
r)zcompiler
r)rNr)rrr)zforcerr)�__name__�
__module__�__qualname__ZdescriptionZuser_optionsZboolean_optionsZnegative_optr r.r5r&rAr2r<r\r_rdrfrhrirkr4rtr0r1r3rrrrrs8	



'4	rc@s(eZdZdd�Zdd�ZdS)�
build_py_2to3cCslg|_|jr|j�n|jr?|j�|j�n|j|j�|j|jdd��dS)Nr/r)	�
updated_filesrr0r$r1r2Zrun_2to3r3r4)rrrrr5�s		
	

zbuild_py_2to3.runcCs=tj||||�}|dr9|jj|d�n|S)Nr7r)rrtrrB)rr]r^r�resrrrrt�s
zbuild_py_2to3.build_moduleN)r{r|r}r5rtrrrrr~�sr~)�__doc__r=�importlib.utilrmrwrZdistutils.corerZdistutils.errorsryrrZ	distutilsrrr~rrrr�<module>s
�|

?>