Your IP : 18.223.238.150


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_ext.cpython-34.pyc

�
h f�y�@s dZddlZddlZddlZddlmZddlTddlmZm	Z	ddlm
Z
ddlmZddl
mZdd	lmZdd
lmZddlmZejdkr�dd
lmZee��Znejd�Zdd�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_BASE�nt)�get_build_versionz3^[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/python34/lib64/python3.4/distutils/command/build_ext.pyrsrc@steZdZdZdejZdWdXd	d
de�fdd
ddfdddefdYdZd[dddefd\d]d^d_d`dadbdcddgZdd%d(d.d5gZ	d7d/d8e
fgZd9d:�Zd;d<�Z
d=d>�Zd?d@�ZdAdB�ZdCdD�ZdEdF�ZdGdH�ZdIdJ�ZdKdL�ZdMdN�ZdOdP�ZdQdR�ZdSdT�ZdUdV�Zd/S)e�	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�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|_dS)Nr)�
extensions�	build_lib�	plat_name�
build_tempr�package�include_dirs�define�undef�	libraries�library_dirs�rpath�link_objectsr-r0�compiler�swig�swig_cpp�	swig_optsr<)�selfrrr�initialize_optionsis(																			zbuild_ext.initialize_optionsc
	Cs�ddlm}|jdd,d-d.d/d0d1�|jdkrP|jj|_n|jj|_|j�}|jd
d�}|j	dkr�|jj	p�g|_	nt
|j	t�r�|j	jt
j�|_	ntjtjkr|j	jt
jjtjd��n|j	j|�||kr7|j	j|�n|jd
�|jdkr_g|_n|jdkrzg|_n-t
|jt�r�|jjt
j�|_n|jdkr�g|_n-t
|jt�r�|jjt
j�|_nt
jdkr�|jjt
jjtjd��tjtjkrW|jjt
jjtjd��n|jr~t
jj|jd�|_nt
jj|jd�|_|j	jt
jjt���ttdd�}|r�|jj|�nt dkrc|j!dkrd}n|j!dd�}t
jjtjd�}|rPt
jj||�}n|jj|�q�t dkr�|jjt
jjtjdd��q�t dkr�|jjt
jjtjdd��q�|jjt
jjtjdd��ntj"dd�dks%tj"dd�d kr�tj#j$t
jjtjd!��r{|jjt
jjtjd"d#t%�d$��q�|jjd%�n|j&d&�r�|j's�|jj|j&d'��q�|jjd%�n|j(r	|j(jd(�}d)d*�|D�|_(n|j)r*|j)jd(�|_)n|j*dkrEg|_*n|j*jd+�|_*|j+r�t
jjt,d�}t
jjt,d"�}	t
jj-|�r�|j	j|�nt
jj-|	�r�|jj|	�|jj|	�q�ndS)2Nr)�	sysconfigZbuildr?rArJr-r0r@Z
plat_specific��includerFrZlibsZDebugZRelease�_home�	�win32��ZPCbuild��PCzVS8.0�zVS7.1ZVC6��cygwin�atheos�bin�lib�python�config�.�Py_ENABLE_SHARED�LIBDIR�,cSsg|]}|df�qS)�1r)�.0Zsymbolrrr�
<listcomp>�s	z.build_ext.finalize_options.<locals>.<listcomp>� )�	build_librj)�
build_temprk)�compilerrl)�debugrm)�forcern)�	plat_namero).�	distutilsrPZset_undefined_optionsrB�distributionZext_packageZext_modulesr>Zget_python_incrC�
isinstance�str�split�os�pathsep�sys�exec_prefix�base_exec_prefix�append�path�joinZensure_string_listrFrGrH�name�prefixr-rA�dirnamer�getattr�MSVC_VERSIONr@�platform�
executable�
startswithr�get_config_varZpython_buildrDrErMr<r�isdir)
rNrPZ
py_includeZplat_py_include�	_sys_home�suffixZnew_libZdefinesZuser_includeZuser_librrr�finalize_options�s�	%
"%		2$

				zbuild_ext.finalize_optionsc	Csddlm}|jsdS|jj�rm|jd�}|jj|j�pSg�|j	j
|j�n|d|jd|j
d|jd|j�|_t|j�tjdkr�|jt�kr�|jj|j�n|jdk	r|jj|j�n|jdk	rEx-|jD]\}}|jj||�qWn|jdk	r{x$|jD]}|jj|�q^Wn|jdk	r�|jj|j�n|j	dk	r�|jj|j	�n|jdk	r�|jj|j�n|j dk	r|jj!|j �n|j"�dS)	Nr)�new_compiler�
build_clibrJ�verbose�dry_runr0r)#rr�r>rqZhas_c_libraries�get_finalized_commandrF�extendZget_library_namesrGrzr�rJr�r�r0rrur}r@r	Z
initializerCZset_include_dirsrDZdefine_macrorEZundefine_macroZ
set_librariesZset_library_dirsrHZset_runtime_library_dirsrIZset_link_objects�build_extensions)rNr�r�r}�value�macrorrr�runs>			
!z
build_ext.runc
Cs0t|t�std��nxt|�D]�\}}t|t�rLq+nt|t�snt|�dkr}td��n|\}}tjd|�t|t	�o�t
j|�s�td��nt|t�s�td��nt||d�}x<dD]4}|j
|�}|dk	r�t|||�q�q�W|j
d�|_d|kretjd�n|j
d�}|rg|_g|_x�|D]�}	t|	t�o�t|	�dks�td��nt|	�dkr�|jj|	d�q�t|	�dkr�|jj|	�q�q�Wn|||<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)�sourcesrCrGrF�
extra_objects�extra_compile_args�extra_link_argsNrHZdef_filez9'def_file' element of build info dict no longer supported�macrosrQz9'macros' element of build info dict must be 1- or 2-tupler)zinclude_dirszlibrary_dirsz	librariesz
extra_objectszextra_compile_argszextra_link_args)rQr�)rr�list�DistutilsSetupError�	enumerater�tuple�lenr
�warnrs�extension_name_re�match�dict�get�setattr�runtime_library_dirs�
define_macros�undef_macrosrz)
rNr>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�)rN�	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>rz�get_ext_fullpathr})rNZoutputsr�rrr�get_outputs�s
zbuild_ext.get_outputscCs�|j|j�x||jD]q}y|j|�Wqtttfk
r�}z.|js^�n|jd|j|f�WYdd}~XqXqWdS)Nz"building extension "%s" failed: %s)	r�r>�build_extensionZCCompilerErrorZDistutilsErrorZCompileErrorZoptionalr�r})rNr��errrr��s		zbuild_ext.build_extensionsc
Cs	|j}|dks+t|ttf�rAtd|j��nt|�}|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�|_|jrz|j|j�n|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�rCr-Zextra_postargs�dependsrFrGr��export_symbolsrAZtarget_lang)!r�rrr�r�r�r}r�r�r0rr
r-�info�swig_sourcesr�r�r�rzrJ�compilerArCZ_built_objectsr�r�r��languageZdetect_languageZlink_shared_object�
get_librariesrGr��get_export_symbols)
rNr�r��ext_pathr�Z
extra_argsr�rEZobjectsr�rrrr��sN	"
										zbuild_ext.build_extensioncCs�g}g}i}|jr+tjd�n|jsRd|jksRd|jkr[d}nd}xr|D]j}tjj|�\}}	|	dkr�|j|d|�|j|�|d||<qh|j|�qhW|s�|S|jp�|j	�}
|
dg}|j
|j�|jr*|jd�n|jsWx!|jD]}|j|�q=WnxE|D]=}||}
tjd	||
�|j|d
|
|g�q^W|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�_wraprQz-pythonzswigging %s to %sz-o���)
rLr
r�rMrur{�splitextrzrK�	find_swigr�r�Zspawn)rNr��	extensionZnew_sourcesr�Zswig_targetsZ
target_ext�source�baser�rKZswig_cmd�o�targetrrrr�s>		

		

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.
        �posixrKr�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�)rur}r{r|�isfileZDistutilsPlatformError)rNZvers�fnrrrr�Os
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).
        rbrQNr�build_pyr�r�r�)�get_ext_fullnamert�get_ext_filenamerrur{r|r?r��abspathZget_package_dir)rNr��fullnameZmodpath�filenamerBr�Zpackage_dirrrrr�gs	#zbuild_ext.get_ext_fullpathcCs&|jdkr|S|jd|SdS)zSReturns the fullname of a given extension name.

        Adds the `package.` prefixNrb)rB)rNr�rrrr��szbuild_ext.get_ext_fullnamecCsoddlm}|jd�}|d�}tjdkr[|jr[tjj|�d|Stjj|�|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�rb�
EXT_SUFFIXr�_d)�distutils.sysconfigr�rtrur}r-r{r|)rNr�r�r�Z
ext_suffixrrrr��szbuild_ext.get_ext_filenamecCsCd|jjd�d}||jkr<|jj|�n|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_rbrQr�)r}rtr�rz)rNr�Z
initfunc_namerrrr��szbuild_ext.get_export_symbolscCs0tjdkr�ddlm}t|j|�s}d}|jrM|d}n|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�rr|j|dd	��qC|j|�qCW|j|dg|Stjdkr�|jStjd	d�dkr�|jSddl	m
}|jd�r%djtjd?tjd?d@tj�}|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).
        rUr)�MSVCCompilerz
python%d%dr����Nr[r\zpython%d.%dr])rP�SHLIBSz-lr��m�darwin��aixrcz
python{}.{}{})rwr��distutils.msvccompilerr�rrrJr-�
hexversionrFrprPr�rtr�rz�format�abiflags)rNr�r��templateZ	pythonlibrPZextrar_rrrr��sJ
	

zbuild_ext.get_libraries)rrr)rrr)rrr)r r!r")r#r$r%)r'r(r))r*r+r,)zdebugr.r/)zforcer1r2)r3r4r5)r6Nr7)r8Nr9)r:Nr;)zuserNr=)�__name__�
__module__�__qualname__ZdescriptionrurvZsep_byr	Zuser_optionsZboolean_optionsrZhelp_optionsrOr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr"st



	�@N	
R6	
r)�__doc__rwru�reZdistutils.corerZdistutils.errorsr�rrrZdistutils.dep_utilrZdistutils.extensionrZdistutils.utilr	rpr
Zsiterr}r�r
�intr�r�r�rrrrrr�<module>s"$
	

?>