HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/numpy/distutils/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/numpy/distutils/__pycache__/ccompiler.cpython-36.pyc
3

���h�j�@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZddlmZmZmZmZmZddlmZddlmZddlmZdd	lmZmZdd
lmZm Z m!Z!m"Z"m#Z#yddl$Z$Wne%k
r�ddl&Z$YnXda'e$j(�Z)e*�Z+dd�Z,d
d�Z-dd�Z.e-ede.�dZdd�Z/e-ede/�d[dd�Z0e-ede0�d\dd�Z1e-ede1�ffdd�Z2e-ede2�dd �Z3d!d"�Z4e-ed#e4�d]d$d%�Z5e-ed&e5�d^d(d)�Z6d*dgfd+d,�Z7e-ed-e7�d.d/�Z8e-ed0e8�d_e
d4<d`e
d7<dae
d:<dbe
d=<dce
d@<dde
dD<ej9dk7_9ej:dGk�rfdle
dK<e!��rfej;dL�dnej9e_9e
Z<dodMdN�Z
e
e_
eZ=dOdP�Zee_x8dpD]0Z>ej?j@dXe>dY�ZAeAdk	�r�eBeAdPe��q�WdS)q�N)�copy)�	ccompiler)�compiler_class�gen_lib_options�get_default_compiler�new_compiler�	CCompiler)�DistutilsExecError�DistutilsModuleError�DistutilsPlatformError�CompileError�UnknownFileError)�customize_compiler)�LooseVersion)�log)�filepath_from_subprocess_output�forward_bytes_to_stdout)�	cyg2win32�is_sequence�mingw32�get_num_build_jobs�_commandline_dep_stringcCs�|d}tjj|�sdSt|d��}|j�}WdQRXt|||�}|d}||krVdSdj|dd��}	dd�tj|	dd	�D�}
y2tj	|�j
}x |
D]}tj	|�j
|kr�dSq�WWntk
r�dSXd
S)
z�
    Check if an objects needs to be rebuild based on its dependencies

    Parameters
    ----------
    obj : str
        object file

    Returns
    -------
    bool
    z.dT�rN��cSs$g|]}|dkr|jd�r|�qS)�
�:)�endswith)�.0�x�r �:/tmp/pip-build-5_djhm0z/numpy/numpy/distutils/ccompiler.py�
<listcomp>Fsz _needs_build.<locals>.<listcomp>)�posixF���r$)�os�path�exists�open�	readlinesr�join�shlex�split�stat�st_mtime�OSError)�obj�cc_args�extra_postargs�pp_optsZdep_file�f�linesZcmdlineZlast_cmdline�contents�depsZt_objr r r!�_needs_build&s&
r8cs�fdd�}t|||�dS)Ncs�|f|�|�S)Nr )�self�args�kw)�funcr r!�<lambda>Zsz replace_method.<locals>.<lambda>)�setattr)�klass�method_namer<�mr )r<r!�replace_methodXsrBcCsdS)z�
    Does nothing here, but is called by the get_version method and can be
    overridden by subclasses. In particular it is redefined in the `FCompiler`
    class where more documentation can be found.

    Nr )r9r r r!�CCompiler_find_executablescsrC�find_executablescCs�|dkr"|}t|�r"djt|��}tj|�y&|jr@tj|�ntj|tjd�WnJtj	k
r�}z|j
}|j}WYdd}~Xn tk
r�d}d}YnXdSt|�r�djt|��}|jr�t
|�tjd|�r�d}nd}td	|||f��dS)
a�
    Execute a command in a sub-process.

    Parameters
    ----------
    cmd : str
        The command to execute.
    display : str or sequence of str, optional
        The text to add to the log file kept by `numpy.distutils`.
        If not given, `display` is equal to `cmd`.

    Returns
    -------
    None

    Raises
    ------
    DistutilsExecError
        If the command failed, i.e. the exit status was not 0.

    N� )�stderr��sToo many open filesz2
Try rerunning setup command until build succeeds.rz)Command "%s" failed with exit status %d%s)rr*�listr�info�verbose�
subprocess�check_output�STDOUT�CalledProcessError�output�
returncoder/r�re�searchr	)r9�cmd�display�exc�o�s�msgr r r!�CCompiler_spawnqs2

rZ�spawnrcCs�|dkrd}g}x�|D]�}tjjtjj|��\}}tjj|�d}|tjj|�d�}|jd�r�|jd�d}|d|�}	tjjtjj	|	��}	|	||d�}||j
kr�td||f��|r�tjj|�}tjj|||j
�}
|j|
�qW|S)a�
    Return the name of the object files for the given source files.

    Parameters
    ----------
    source_filenames : list of str
        The list of paths to source files. Paths can be either relative or
        absolute, this is handled transparently.
    strip_dir : bool, optional
        Whether to strip the directory from the returned paths. If True,
        the file name prepended by `output_dir` is returned. Default is False.
    output_dir : str, optional
        If given, this path is prepended to the returned paths to the
        object files.

    Returns
    -------
    obj_names : list of str
        The list of paths to the object files corresponding to the source
        files in `source_filenames`.

    Nrrz..�z"unknown file type '%s' (from '%s'))r%r&�splitext�normpath�
splitdrive�isabs�
startswith�rfind�basename�abspathZsrc_extensionsr
r*Z
obj_extension�append)r9Zsource_filenamesZ	strip_dir�
output_dirZ	obj_names�src_name�base�ext�i�dZobj_namer r r!�CCompiler_object_filenames�s&


rlZobject_filenamesc	sNt�}	t�tdkrtj|	�aWdQRX|s0gSddlm}
m}m}t	�|
�r�g}
x<dD]4}t
�d|�}|dkrtqX|
jd|d	j|�f�qXWd
j|
�}
n�j
}dd	j|�f}
tj|
��j|||||��\}}��}�j�||��dd	j��}
��r|
d
d	j��7}
tj|
�����fdd�}t	�|
��r�t|j��}gg}}x||D]t}||k�rR||\}}�jdk�r�t|�}t|�}||��r�||��r�|j|||ff�n|j|||ff��qRW|}x |D]}||��q�Wn|j�}t|�dk�r2|	dk�r2ddl}|jj|	�}|j||�|j�nx|D]}||��q8W|S)a�
    Compile one or more source files.

    Please refer to the Python distutils API reference for more details.

    Parameters
    ----------
    sources : list of str
        A list of filenames
    output_dir : str, optional
        Path to the output directory.
    macros : list of tuples
        A list of macro definitions.
    include_dirs : list of str, optional
        The directories to add to the default include file search path for
        this compilation only.
    debug : bool, optional
        Whether or not to output debug symbols in or alongside the object
        file(s).
    extra_preargs, extra_postargs : ?
        Extra pre- and post-arguments.
    depends : list of str, optional
        A list of file names that all targets depend on.

    Returns
    -------
    objects : list of str
        A list of object file names, one per source file `sources`.

    Raises
    ------
    CompileError
        If compilation fails.

    Nr)�	FCompiler�	is_f_file�has_f90_header�f77�f90�fixZ	compiler_zFortran %s compiler: %srErzC compiler: %s
zcompile options: '%s'z
extra options: '%s'cs�|\}\}}t|����sdSx2t�|tkr:tj|�PWdQRXtjd�q Wz(t��j|||����WdQRXWdt�tj|�WdQRXXdS)Ng�������?)	r8�_global_lock�_processing_files�add�time�sleep�_job_semaphore�_compile�remove)r:r0�srcri)r1r2r3r9r r!�single_compile-s
"z)CCompiler_compile.<locals>.single_compileZabsoftr)rprqrr)rrsrx�	threading�	SemaphoreZnumpy.distutils.fcompilerrmrnro�
isinstance�getattrrer*�compiler_sorrJZ_setup_compileZ_get_cc_argsrI�keys�
compiler_typer�items�lenZmultiprocessing.pool�poolZ
ThreadPool�map�close)r9�sourcesrf�macros�include_dirs�debug�
extra_preargsr2�depends�jobsrmrnrorUZfcZfcompZccompZobjects�buildr|Zobjects_to_buildZf77_objectsZ
other_objectsr0r{riZbuild_itemsrW�multiprocessingr�r )r1r2r3r9r!�CCompiler_compile�sd+









r��compilecs�tjd|jj�jjf���fdd�}|d�r<|j�j�|d�rdx�jD]\}}|j||�qLW|d�r�x�jD]}|j	|�qtW|d�r�|j
|j�j�|d�r�|j|j
�j
�|d	�r�|j�j�|d
�r�|j�j�dS)a�
    Customize compiler using distutils command.

    Parameters
    ----------
    cmd : class instance
        An instance inheriting from `distutils.cmd.Command`.
    ignore : sequence of str, optional
        List of `CCompiler` commands (without ``'set_'``) that should not be
        altered. Strings that are checked for are:
        ``('include_dirs', 'define', 'undef', 'libraries', 'library_dirs',
        'rpath', 'link_objects')``.

    Returns
    -------
    None

    zcustomize %s using %scst�|d�dk	o|�kS)N)r�)�attr)rT�ignorer r!�allow�sz&CCompiler_customize_cmd.<locals>.allowr��define�undef�	libraries�library_dirs�rpath�link_objectsN)rrJ�	__class__�__name__Zset_include_dirsr�r�Zdefine_macror�Zundefine_macroZ
set_librariesr�Zset_library_dirsr�Zset_runtime_library_dirsr�Zset_link_objectsr�)r9rTr�r��name�value�macror )rTr�r!�CCompiler_customize_cmdps&r�Z
customize_cmdc
s�g}d}t|jj��}xdD]}||kr|j|�qWx@|D]8}t||�r<t||�}t|t|��}|j|t|�f�q<Wdt|d
�d��fdd�|D�}dj	|�S)Nr�versionr�r��
object_switch�compile_switchr�r�r�r�r�z%-rzs = %scsg|]}�|�qSr r )r�prop)�fmtr r!r"�sz'_compiler_to_string.<locals>.<listcomp>r)
r�r�r�r�r�r�r�r�r�r�)
rIZexecutablesr�re�hasattrr��maxr��reprr*)�compiler�propsZmxr��key�vr5r )r�r!�_compiler_to_string�s 


r�cCs`y|j�Wntk
r YnXtjjdkr\tdd�t|j�tt|��tdd�dS)z�
    Print the compiler customizations to stdout.

    Parameters
    ----------
    None

    Returns
    -------
    None

    Notes
    -----
    Printing is only done if the distutils log threshold is < 2.

    r\�*�PN)�get_version�	Exceptionr�_global_log�	threshold�printr�r�)r9r r r!�CCompiler_show_customization�s
r�Zshow_customizationc
"Cs�tjd|jj�t|�|r�y|jjd�Wnttfk
rFYnXt	|d�r�d|j
dkr�|js�|j
djd�r�d\}}nd\}}|j
dj
||�g|j
d	d
�|_n8t	|d�r�tjd|j
f�t	|d�s�tjd
|jj�t	|d��r*d|j
dk�s"d|j
dk�s"d|j
dk�r*d|_n�tjdk�r�dd
l}dd
l}|j�}zvyTtjj|d�}t|d��}	|	jd�Wd
QRX|j|g|dd|dgd�d|_Wntk
�r�d|_YnXWd
|j|�Xd
S)am
    Do any platform-specific customization of a compiler instance.

    This method calls `distutils.sysconfig.customize_compiler` for
    platform-specific customization, as well as optionally remove a flag
    to suppress spurious warnings in case C++ code is being compiled.

    Parameters
    ----------
    dist : object
        This parameter is not used for anything.
    need_cxx : bool, optional
        Whether or not C++ has to be compiled. If so (True), the
        ``"-Wstrict-prototypes"`` option is removed to prevent spurious
        warnings. Default is False.

    Returns
    -------
    None

    Notes
    -----
    All the default options used by distutils can be extracted with::

      from distutils import sysconfig
      sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS',
                                'CCSHARED', 'LDSHARED', 'SO')

    zcustomize %sz-Wstrict-prototypesr��ccr�gcc�g++�c++rNz#### %s #######�compiler_cxxzMissing compiler_cxx fix for ZclangTr#zfile.c�wzint a;
z-MMDz-MFz.d)rfr�F)r�r�)r�r�)rrJr�r�rr�rz�AttributeError�
ValueErrorr�r�r�ra�replace�warnZ
_auto_dependsr%r��tempfile�shutil�mkdtempr&r*r(�writer�r�rmtree)
r9�distZneed_cxx�a�br�r�Ztmpdir�fnr4r r r!�CCompiler_customize�sJ




r�Z	customize�[-.\d]+cs���fdd�}|S)aU
    Simple matching of version numbers, for use in CCompiler and FCompiler.

    Parameters
    ----------
    pat : str, optional
        A regular expression matching version numbers.
        Default is ``r'[-.\d]+'``.
    ignore : str, optional
        A regular expression matching patterns to skip.
        Default is ``''``, in which case nothing is skipped.
    start : str, optional
        A regular expression matching the start of where to start looking
        for version numbers.
        Default is ``''``, in which case searching is started at the
        beginning of the version string given to `matcher`.

    Returns
    -------
    matcher : callable
        A function that is appropriate to use as the ``.version_match``
        attribute of a `CCompiler` class. `matcher` takes a single parameter,
        a version string.

    cs~|jdd�}d}�r0tj�|�}|s(dS|j�}xBtj�||d��}|sNdS�rntj�|jd��rn|j�}q2Pq2W|jd�S)NrrEr)r�rR�match�endrS�group)r9�version_string�posrA)r��pat�startr r!�matcher?s z%simple_version_match.<locals>.matcherr )r�r�r�r�r )r�r�r�r!�simple_version_match%sr�Fc	&s:|rt|d�r|jS|j�y
|j}Wntk
r<dSX|sN|drRdSy
|j}Wn@tk
r�y
|j�Wntk
r�dSX�fdd�}YnXytj|tj	d�}WnLtj
k
r�}z|j}|j}WYdd}~Xn*t
k
�r�d}d}YnXt|�}d}d}||k�r0||�}|�r0t|�}||_|S)	a�
    Return compiler version, or None if compiler is not available.

    Parameters
    ----------
    force : bool, optional
        If True, force a new determination of the version, even if the
        compiler already has a version attribute. Default is False.
    ok_status : list of int, optional
        The list of status values returned by the version look-up process
        for which a version string is returned. If the status value is not
        in `ok_status`, None is returned. Default is ``[0]``.

    Returns
    -------
    version : str or None
        Version string, in the format of `distutils.version.LooseVersion`.

    r�Nrcs"tj�|�}|sdS|jd�}|S)Nr�)rRr�r�)r�rAr�)r�r r!r�xs

z&CCompiler_get_version.<locals>.matcher)rFrHrG)r�r�rD�version_cmdr�Z
version_matchZversion_patternrLrMrNrOrPrQr/rr)	r9�forceZ	ok_statusr�r�rPrV�statusr�r )r�r!�CCompiler_get_versionTsD




r�r�cCs�|jd
kr|St|�}|jdg|jdd�|_tjjd�rrd|jdkrr|jd|jdg|jd	d�|_n|jdg|jdd�|_|S)z�
    Return the C++ compiler.

    Parameters
    ----------
    None

    Returns
    -------
    cxx : class instance
        The C++ compiler, as a `CCompiler` instance.

    �msvc�intelw�intelemwrrN�aixZ	ld_so_aixr\)r�r�r�)r�rr�r��sys�platformra�	linker_so)r9�cxxr r r!�CCompiler_cxx_compiler�s
r�Zcxx_compiler�intelccompiler�IntelCCompiler�(Intel C Compiler for 32-bit applications�intel�IntelItaniumCCompiler�7Intel C Itanium Compiler for Itanium-based applications�intele�IntelEM64TCCompiler�(Intel C Compiler for 64-bit applications�intelem�IntelCCompilerW�3Intel C Compiler for 32-bit applications on Windowsr��IntelEM64TCCompilerW�3Intel C Compiler for 64-bit applications on Windowsr��
pathccompiler�PathScaleCCompiler�2PathScale Compiler for SiCortex-based applications�pathcc�linux.*�nt�win32�mingw32ccompiler�Mingw32CCompiler�>Mingw32 port of GNU C Compiler for Win32(for MSC built Python)rz+Setting mingw32 as default compiler for nt.c.Cs�|dkrtj�tjk}|dkr$tj}y"|dkr6t|�}t|\}}}Wn8tk
r~d|}|dk	rr|d|}t|��YnXd|}yt	|�Wn�t
k
�r"}	zpt|	�}tjdt|��|dd�}yt	|�Wn8t
k
�r}	zt|	�}t
d|��WYdd}	~	XnXWYdd}	~	XnXytj|}
t|
�|}Wn&tk
�rdt
d
||f��YnX|d||�}||_tjd	|�|S)Nz5don't know how to compile C/C++ code on platform '%s'z with '%s' compilerznumpy.distutils.z,%s in numpy.distutils; trying from distutils�z4can't compile C/C++ code: unable to load module '%s'z4can't compile C/C++ code: unable to find class '%s' zin module '%s'znew_compiler returns %szBcan't compile C/C++ code: unable to find class '%s' in module '%s')rZ
get_threshold�INFOr%r�rr�KeyErrorr�
__import__�ImportError�strrJr
r��modules�varsrKr�)�platr�rK�dry_runr��module_name�
class_name�long_descriptionrY�e�moduler?r r r!r�sJ
,
rcCsFt||||�}g}x.|D]&}t|�r4|jt|��q|j|�qW|S)N)�_distutils_gen_lib_optionsr�extendrIre)r�r��runtime_library_dirsr�rZlib_optsrjr r r!rs
r�msvc9r��_msvc�bcpp�cygwinc�emxc�unixcz
distutils.r�)N)rr)NNNrNNN)r)r�rr)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r��r�r��r�r��r�r��r�r��r�r��r�r�)rrrrrr)r�r�r��r�r)r)NNNrr)r
r�rrrrr)Cr%rRr�r+rvrLr�	distutilsr�distutils.ccompilerrrrrrZdistutils.errorsr	r
rrr
�distutils.sysconfigrZdistutils.versionrZnumpy.distutilsrZnumpy.distutils.exec_commandrrZnumpy.distutils.misc_utilrrrrrr}r��dummy_threadingrx�Lockrs�setrtr8rBrCrZrlr�r�r�r�r�r�r�r�Z_default_compilersr�rJZ_distutils_new_compilerr
Z_ccr�get�_mr>r r r r!�<module>s�2

?
-
)#
Q
/C


(