ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/distutils/command/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/distutils/command/__pycache__/build_ext.cpython-35.pyc



M�Ma{�@s�dZddlZddlZddlZddlZddlmZddlTddlm	Z	m
Z
ddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlmZejd�Zd
d�ZGdd�de�ZdS)z�distutils.command.build_ext

Implements the Distutils 'build_ext' command, for building extension
modules (currently limited to C extensions, should accommodate C++
extensions ASAP).�N)�Command)�*)�customize_compiler�get_python_version)�get_config_h_filename)�newer_group)�	Extension)�get_platform)�log)�	USER_BASEz3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$cCsddlm}|�dS)Nr)�show_compilers)�distutils.ccompilerr)r�r�@/opt/alt/python35/lib64/python3.5/distutils/command/build_ext.pyrsrc@s�eZdZdZdejZd`dad	d
de�fdd
ddfdddefdbdcdddddefdedfdgdhdidjdkdldmdngZdd%d(d1d8gZ	d:d2d;e
fgZd<d=�Zd>d?�Z
d@dA�ZdBdC�ZdDdE�ZdFdG�ZdHdI�ZdJdK�ZdLdM�ZejdNdO��ZdPdQ�ZdRdS�ZdTdU�ZdVdW�ZdXdY�ZdZd[�Zd\d]�Zd^d_�Zd2S)o�	build_extz8build C/C++ extensions (compile/link to build directory)z (separated by '%s')�
build-lib=�b�(directory for compiled extension modules�build-temp=�t�1directory for temporary files (build by-products)z
plat-name=�pz>platform name to cross-compile for, if supported (default: %s)�inplace�iz=ignore build-lib and put compiled extensions into the source z,directory alongside your pure Python modulesz
include-dirs=�Iz.list of directories to search for header files�define=�D�C preprocessor macros to define�undef=�U�!C preprocessor macros to undefine�
libraries=�l�!external C libraries to link withz
library-dirs=�Lz.directories to search for external C libraries�rpath=�R�7directories to search for shared C libraries at runtime�
link-objects=�O�2extra explicit link objects to include in the link�debug�g�'compile/link with debugging information�force�f�2forcibly build everything (ignore file timestamps)�	compiler=�c�specify the compiler type�	parallel=�j�number of parallel build jobs�swig-cppN�)make SWIG create C++ files (default is C)�
swig-opts=�!list of SWIG command line options�swig=�path to the SWIG executable�user�#add user include, library and rpathz
help-compilerzlist available compilerscCs�d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_dS)Nr)�
extensions�	build_lib�	plat_name�
build_tempr�package�include_dirs�define�undef�	libraries�library_dirs�rpath�link_objectsr+r.�compiler�swig�swig_cpp�	swig_optsr=�parallel)�selfrrr�initialize_optionsjs*																				zbuild_ext.initialize_optionsc
Csrddlm}|jdd'd(d)d*d+d,d-�|jdkrP|jj|_|jj|_|j�}|jdd�}|j	dkr�|jj	p�g|_	t
|j	t�r�|j	jt
j�|_	tjtjkr�|j	jt
jjtjd
��|j	j|�||kr+|j	j|�|jd�|jd�|jdkr]g|_|jdkrxg|_n*t
|jt�r�|jjt
j�|_|jdkr�g|_n*t
|jt�r�|jjt
j�|_t
jdkrC|jjt
jjtjd��tjtjkrL|jjt
jjtjd��|jrst
jj|jd�|_nt
jj|jd�|_|j	jt
jjt���ttdd�}|r�|jj|�|j dkr�d}n|j dd�}t
jjtjd�}|r3t
jj||�}|jj|�tj!dd�dksutj!dd�dkr�tj"j#t
jjtjd��r�|jjt
jjtjddt$�d��n|jjd�|j%d �r|j&s|jj|j%d!��n|jjd�|j'rP|j'jd"�}d#d$�|D�|_'|j(rn|j(jd"�|_(|j)dkr�g|_)n|j)jd%�|_)|j*r%t
jjt+d
�}t
jjt+d�}	t
jj,|�r�|j	j|�t
jj,|	�r%|jj|	�|jj|	�t
|j-t�rnyt.|j-�|_-Wnt/k
rmt0d&��YnXdS).Nr)�	sysconfigZbuildr@rBrKr+r.rOrAZ
plat_specific��includerGrJ�ntZlibsZDebugZRelease�_home�win32�ZPCbuild��cygwin�atheos�bin�lib�python�config�.�Py_ENABLE_SHARED�LIBDIR�,cSsg|]}|df�qS)�1r)�.0Zsymbolrrr�
<listcomp>�s	z.build_ext.finalize_options.<locals>.<listcomp>� zparallel should be an integer)r@r@)rBrB)rKrK)r+r+)r.r.)rOrO)rArA)1�	distutilsrRZset_undefined_optionsrC�distributionZext_packageZext_modulesr?Zget_python_incrD�
isinstance�str�split�os�pathsep�sys�exec_prefix�base_exec_prefix�append�path�joinZensure_string_listrGrHrI�name�prefixr+rB�dirnamer�getattrrA�platform�
executable�
startswithr�get_config_varZpython_buildrErFrNr=r�isdirrO�int�
ValueErrorZDistutilsOptionError)
rPrRZ
py_includeZplat_py_include�	_sys_home�suffixZnew_libZdefinesZuser_includeZuser_librrr�finalize_options�s�	"

	""		2$

				
zbuild_ext.finalize_optionsc	Csddlm}|jsdS|jj�rj|jd�}|jj|j�pSg�|j	j
|j�|d|jd|j
d|jd|j�|_t|j�tjdkr�|jt�kr�|jj|j�|jdk	r�|jj|j�|jdk	r9x*|jD]\}}|jj||�qW|jdk	rlx!|jD]}|jj|�qRW|jdk	r�|jj|j�|j	dk	r�|jj|j	�|jdk	r�|jj|j�|j dk	r�|jj!|j �|j"�dS)	Nr)�new_compiler�
build_clibrK�verbose�dry_runr.rU)#r
r�r?riZhas_c_libraries�get_finalized_commandrG�extendZget_library_namesrHrrr�rKr�r�r.rrmrurAr	Z
initializerDZset_include_dirsrEZdefine_macrorFZundefine_macroZ
set_librariesZset_library_dirsrIZset_runtime_library_dirsrJZset_link_objects�build_extensions)rPr�r�ru�value�macrorrr�runs>			
!z
build_ext.runc
Cst|t�std��x�t|�D]�\}}t|t�rFq(t|t�sht|�dkrttd��|\}}tjd|�t|t	�o�t
j|�s�td��t|t�s�td��t||d�}x9dD]1}|j
|�}|dk	r�t|||�q�W|j
d�|_d|krPtjd�|j
d�}|rg|_g|_x�|D]~}	t|	t�o�t|	�dks�td��t|	�dkr�|jj|	d�q~t|	�dkr~|jj|	�q~W|||<q(WdS)a�Ensure that the list of extensions (presumably provided as a
        command option 'extensions') is valid, i.e. it is a list of
        Extension objects.  We also support the old-style list of 2-tuples,
        where the tuples are (ext_name, build_info), which are converted to
        Extension instances here.

        Raise DistutilsSetupError if the structure is invalid anywhere;
        just returns otherwise.
        z:'ext_modules' option must be a list of Extension instances�zMeach element of 'ext_modules' option must be an Extension instance or 2-tuplezuold-style (ext_name, build_info) tuple found in ext_modules for extension '%s'-- please convert to Extension instancezRfirst element of each tuple in 'ext_modules' must be the extension name (a string)zOsecond element of each tuple in 'ext_modules' must be a dictionary (build info)�sourcesrDrHrG�
extra_objects�extra_compile_args�extra_link_argsNrIZdef_filez9'def_file' element of build info dict no longer supported�macrosrSz9'macros' element of build info dict must be 1- or 2-tupler)rDrHrGr�r�r�)rSr�)rj�list�DistutilsSetupError�	enumerater�tuple�lenr
�warnrk�extension_name_re�match�dict�get�setattr�runtime_library_dirs�
define_macros�undef_macrosrr)
rPr?r�ext�ext_nameZ
build_info�key�valr�r�rrr�check_extensions_listUsT
	"				

		
!	zbuild_ext.check_extensions_listcCs>|j|j�g}x!|jD]}|j|j�q W|S)N)r�r?r�r�)rP�	filenamesr�rrr�get_source_files�s
zbuild_ext.get_source_filescCsG|j|j�g}x*|jD]}|j|j|j��q W|S)N)r�r?rr�get_ext_fullpathru)rPZoutputsr�rrr�get_outputs�s
zbuild_ext.get_outputscCs4|j|j�|jr&|j�n
|j�dS)N)r�r?rO�_build_extensions_parallel�_build_extensions_serial)rPrrrr��s	
zbuild_ext.build_extensionscs��j}�jdkr$tj�}yddlm}Wntk
rRd}YnX|dkrm�j�dS|d|��j���fdd��jD�}xAt�j|�D]-\}}�j	|��|j
�WdQRXq�WWdQRXdS)NTr)�ThreadPoolExecutorZmax_workerscs%g|]}�j�j|��qSr)Zsubmit�build_extension)rer�)�executorrPrrrf�s	z8build_ext._build_extensions_parallel.<locals>.<listcomp>)rOrm�	cpu_countZconcurrent.futuresr��ImportErrorr�r?�zip�_filter_build_errors�result)rPZworkersr�Zfuturesr�Zfutr)r�rPrr��s 	


z$build_ext._build_extensions_parallelc
Cs<x5|jD]*}|j|��|j|�WdQRXq
WdS)N)r?r�r�)rPr�rrrr��sz"build_ext._build_extensions_serialccsdy	dVWnTtttfk
r_}z+|js3�|jd|j|f�WYdd}~XnXdS)Nz"building extension "%s" failed: %s)ZCCompilerErrorZDistutilsErrorZCompileErrorZoptionalr�ru)rPr��errrr��s			zbuild_ext._filter_build_errorsc
Cs|j}|dks+t|ttf�r>td|j��t|�}|j|j�}||j}|jp�t	||d�s�t
jd|j�dSt
jd|j�|j
||�}|jp�g}|jdd�}x!|jD]}|j|f�q�W|jj|d|jd|d|jd|jd	|d
|j�}|dd�|_|jrt|j|j�|jp�g}|jp�|jj|�}	|jj||d|j|�d|jd
|jd	|d|j |�d|jd|jd|	�dS)Nzjin 'ext_modules' option (extension '%s'), 'sources' must be present and must be a list of source filenamesZnewerz$skipping '%s' extension (up-to-date)zbuilding '%s' extensionZ
output_dirr�rDr+Zextra_postargs�dependsrGrHr��export_symbolsrBZtarget_lang)!r�rjr�r�r�rur�r�r.rr
r+�info�swig_sourcesr�r�r�rrrK�compilerBrDZ_built_objectsr�r�r��languageZdetect_languageZlink_shared_object�
get_librariesrHr��get_export_symbols)
rPr�r��ext_pathr�Z
extra_argsr�rFZobjectsr�rrrr��sN	"

										zbuild_ext.build_extensioncCs�g}g}i}|jr(tjd�|jsOd|jksOd|jkrXd}nd}xr|D]j}tjj|�\}}	|	dkr�|j|d|�|j|�|d||<qe|j|�qeW|s�|S|jp�|j	�}
|
dg}|j
|j�|jr$|jd�|jsNx|jD]}|j|�q7WxE|D]=}||}
tjd	||
�|j|d
|
|g�qUW|S)z�Walk the list of source files in 'sources', looking for SWIG
        interface (.i) files.  Run SWIG on all that are found, and
        return a modified 'sources' list with SWIG source files replaced
        by the generated C (or C++) files.
        z/--swig-cpp is deprecated - use --swig-opts=-c++z-c++z.cppz.cz.i�_wraprSz-pythonzswigging %s to %sz-o���)
rMr
r�rNrmrs�splitextrrrL�	find_swigr�r�Zspawn)rPr��	extensionZnew_sourcesr�Zswig_targetsZ
target_ext�source�baser�rLZswig_cmd�o�targetrrrr�0s>	
	

	
	

zbuild_ext.swig_sourcescCs�tjdkrdStjdkrixWdD]5}tjjd|d�}tjj|�r)|Sq)WdSntd	tj��d
S)z�Return the name of the SWIG executable.  On Unix, this is
        just "swig" -- it should be in the PATH.  Tries a bit harder on
        Windows.
        �posixrLrU�1.3�1.2�1.1z	c:\swig%szswig.exez>I don't know how to find (much less run) SWIG on platform '%s'N)r�r�r�)rmrursrt�isfileZDistutilsPlatformError)rPZvers�fnrrrr�fs
zbuild_ext.find_swigcCs�|j|�}|jd�}|j|d�}|jsstjj|dd�|g�}tjj|j|�Sdj|dd��}|jd�}tjj	|j
|��}tjj||�S)	z�Returns the path of the filename for a given extension.

        The file is located in `build_lib` or directly in the package
        (inplace option).
        r`rSNr�build_pyr�r�r�)�get_ext_fullnamerl�get_ext_filenamerrmrsrtr@r��abspathZget_package_dir)rPr��fullnameZmodpath�filenamerCr�Zpackage_dirrrrr�~s	#zbuild_ext.get_ext_fullpathcCs&|jdkr|S|jd|SdS)zSReturns the fullname of a given extension name.

        Adds the `package.` prefixNr`)rC)rPr�rrrr��szbuild_ext.get_ext_fullnamecCs?ddlm}|jd�}|d�}tjj|�|S)z�Convert the name of an extension (eg. "foo.bar") into the name
        of the file from which it will be loaded (eg. "foo/bar.so", or
        "foo\bar.pyd").
        r)r|r`�
EXT_SUFFIX)�distutils.sysconfigr|rlrmrsrt)rPr�r|r�Z
ext_suffixrrrr��szbuild_ext.get_ext_filenamecCs@d|jjd�d}||jkr9|jj|�|jS)aReturn the list of symbols that a shared extension has to
        export.  This either uses 'ext.export_symbols' or, if it's not
        provided, "PyInit_" + module_name.  Only relevant on Windows, where
        the .pyd file (DLL) must export the module "PyInit_" function.
        ZPyInit_r`rSr�)rurlr�rr)rPr�Z
initfunc_namerrrr��szbuild_ext.get_export_symbolscCs3tjdkr�ddlm}t|j|�szd}|jrJ|d}|tjd?tjd?d@f}|j|gS|jSn�tjd	d
�dkr�d}|tjd?tjd?d@f}|j|gStjd	d
�d
kr�ddl	m
}d}|tjd?tjd?d@f}g}xS|jd�j�D]<}|j
d�ro|j|dd	��q@|j|�q@W|j|dg|Stjdkr�|jStjd	d�dkr�|jSddl	m
}|jd�r(djtjd?tjd?d@|jd��}|j|gS|jSd	S)z�Return the list of libraries to link against when building a
        shared extension.  On most platforms, this is just 'ext.libraries';
        on Windows, we add the Python library (eg. python20.dll).
        rWr)�MSVCCompilerz
python%d%dZ_d���NrYrZzpython%d.%dr[)rR�SHLIBSz-lr��m�darwin��aixraz
python{}.{}{}�ABIFLAGS)roryZdistutils._msvccompilerr�rjrKr+�
hexversionrGrhrRr|rlr{rr�format)rPr�r��templateZ	pythonlibrRZextrar]rrrr��sJ
	

zbuild_ext.get_libraries)rrr)rrr)rrr)rrr )r!r"r#)r%r&r')r(r)r*)r+r,r-)r.r/r0)r1r2r3)r4r5r6)r7Nr8)r9Nr:)r;Nr<)r=Nr>) �__name__�
__module__�__qualname__ZdescriptionrmrnZsep_byr	Zuser_optionsZboolean_optionsrZhelp_optionsrQr�r�r�r�r�r�r�r��
contextlib�contextmanagerr�r�r�r�r�r�r�r�r�rrrrr!s~



	�@N	
K6	
r)�__doc__r�rm�reroZdistutils.corerZdistutils.errorsr�rrrZdistutils.dep_utilrZdistutils.extensionrZdistutils.utilr	rhr
Zsiterr�r�rrrrrr�<module>s"
	

Zerion Mini Shell 1.0