HOME


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

���h�%�@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZddl
mZddlmZddlmZdadadd	�Zd
d�Zdd
�Zdd�Zegggdfdd��Zegggddfdd��Zdadd�Zdd�Zdd�Zdd�Zedd��Z Gdd�d�Z!dS) z�
Utility functions for

- building and importing modules on test time, using a temporary location
- detecting if compilers are present

�N)�asbytes�asstr)�temppath)�
import_module)�md5icCs^tdk	rZytjjt�Wntk
r,YnXytjt�Wnttfk
rTYnXdadS)N)	�_module_dir�sys�path�remove�
ValueError�shutil�rmtree�IOError�OSError�rr�6/tmp/pip-build-5_djhm0z/numpy/numpy/f2py/tests/util.py�_cleanup srcCs6tdkr2tj�atjt�ttjkr2tjjdt�tS)Nr)	r�tempfile�mkdtemp�atexit�registerrrr	�insertrrrr�get_module_dir.s

rcCs,t�}dt}td7a|tjkr(td��|S)Nz_test_ext_module_%d�z%Temporary module name already in use.)r�_module_numr�modules�RuntimeError)�d�namerrr�get_temp_module_name8s
rcsi���fdd�}�j|_|S)Ncsnt||f�}|�krTy�||��|<Wn,tk
rR}z|�|<�WYdd}~XnX�|}t|t�rj|�|S)N)�repr�	Exception�
isinstance)�a�kw�key�e�ret)�func�memorr�wrapperGs
z_memoize.<locals>.wrapper)�__name__)r(r*r)r(r)r�_memoizeDsr,cCsrdttj�}t�}g}g}xr|D]j}	tjj|	�s>td|	��tjj|tjj|	��}
t	j
|	|
�|j|
�tjj|
�\}}|dkr"|j|
�q"W|dkr�t
�}dd	|g||}
|r�|
d
g|7}
|r�|
dg|7}
tj�}zftj|�tjd|g|
}tj|tjtjd�}|j�\}}|jd
k�r@td|dd�t|�f��Wdtj|�x|D]}	tj|	��qTWXt|�S)zH
    Compile and import a f2py module, built from the given files.

    zEimport sys; sys.path = %s; import numpy.f2py as f2py2e; f2py2e.main()z%s is not a file�.f90�.f�.c�.pyfNz-cz-mzskip:zonly:)�stdout�stderrrzRunning f2py failed: %s
%s�)r-r.r/r0)r rr	r�os�isfiler�join�basenamer�copyfile�append�splitextr�getcwd�chdir�
executable�
subprocess�Popen�PIPE�STDOUT�communicate�
returncoder�unlinkr)�source_files�options�skip�only�module_name�coder�dst_sourcesZf2py_sources�fn�dst�base�extZ	f2py_opts�cwd�cmd�p�out�errrrr�build_module[sF






rUcCsV|dkrd}t|d��6}t|d��}|j|�WdQRXt|g||||d�SQRXdS)z6
    Compile and import Fortran code using f2py.

    Nz.f)�suffix�w)rFrGrHrI)r�open�writerU)Zsource_coderFrGrHrVrIr	�frrr�
build_code�sr[c	Cs�tdk	rtSdatjd�}|tttj�d�}tj�}z`t	jj
|d�}t|d��}|j|�WdQRXtj
ddg}tj|tjtj|d�}|j�\}}Wdtj|�Xtjd|�}|r�tt|jd	���tt|jd
���tt|jd���fatS)
NFa�        import os
        import sys
        sys.path = %(syspath)s

        def configuration(parent_name='',top_path=None):
            global config
            from numpy.distutils.misc_util import Configuration
            config = Configuration('', parent_name, top_path)
            return config

        from numpy.distutils.core import setup
        setup(configuration=configuration)

        config_cmd = config.get_config_cmd()
        have_c = config_cmd.try_compile('void foo() {}')
        print('COMPILERS:%%d,%%d,%%d' %% (have_c,
                                          config.have_f77c(),
                                          config.have_f90c()))
        sys.exit(99)
        )�syspathzsetup.pyrW�config)r1r2rPsCOMPILERS:(\d+),(\d+),(\d+)r��)FFF)�_compiler_status�textwrap�dedent�dictr rr	rrr4r6rXrYr=r>r?r@rArBrr
�re�search�bool�int�group)	rJZtmpdir�scriptrZrQrRrSrT�mrrr�_get_compiler_status�s,
 rkcCs
t�dS)Nr)rkrrrr�has_c_compiler�srlcCs
t�dS)Nr)rkrrrr�has_f77_compiler�srmcCs
t�dS)Nr^)rkrrrr�has_f90_compiler�srncKs�ddlm}ddlm}t�}g}xP|D]H}tjj|�sDtd|��tjj	|tjj
|��}	tj||	�|j
|	�q(Wtj|�jdd�}tjd�t|ttj�d�}
tjj	|t�d	�}|j
|�t|d
��}|jt|
��WdQRXtj�}
zdtj|�tj|dd
g}tj|tjtjd�}|j�\}}|j dk�rNtd|dd�t!|�f��Wdtj|
�x|D]}tj"|��qbWXt#|�tj$|S)z6
    Build a module via distutils and import it.

    r)�
Configuration)�setupz%s is not a file�
z
    a�        import os
        import sys
        sys.path = %(syspath)s

        def configuration(parent_name='',top_path=None):
            from numpy.distutils.misc_util import Configuration
            config = Configuration('', parent_name, top_path)
            %(config_code)s
            return config

        if __name__ == "__main__":
            from numpy.distutils.core import setup
            setup(configuration=configuration)
        )�config_coder\z.py�wbN�	build_extz-i)r1r2z%Running distutils build failed: %s
%sr3)%Znumpy.distutils.misc_utilroZnumpy.distutils.corerprr4r	r5rr6r7rr8r9rarb�replacercr rrrXrYrr;r<r=r>r?r@rArBrCrrD�
__import__r)rErrrIr$rorprrKrLrMrJrirZrPrQrRrSrTrrr�build_module_distutils�s@






rwc@s4eZdZdZdZgZgZgZdZdZ	dZ
dd�ZdS)�F2PyTestNz.fcCstjdkrtjd�|jdk	r"dSt�s2tjd�g}|jrH|j|j�|jdk	r^|j	|j
�d}d}x*|D]"}|jd�r�d}ql|jd�rld}qlW|r�t�r�tjd�|r�t
�r�tjd	�|jdk	r�t|j|j|j|j|j
|jd
�|_|jdk	�rt|j|j|j|j|jd�|_dS)N�win32z)Fails with MinGW64 Gfortran (Issue #9673)zNo C compiler availableFz.fTz.f90z No Fortran 77 compiler availablez No Fortran 90 compiler available)rFrGrHrVrI)rFrGrHrI)r�platform�pytestrG�modulerl�sources�extendrJr9rV�endswithrmrnr[rFrHrIrU)�self�codesZ	needs_f77Z	needs_f90rLrrrrpBs>












zF2PyTest.setup)r+�
__module__�__qualname__rJr}rFrGrHrVr|rIrprrrrrx8srx)"�__doc__r4rr>rrrrardr{Znumpy.compatrrZ
numpy.testingr�	importlibr�hashlibrrrrrrr,rUr[r`rkrlrmrnrwrxrrrr�<module>s>
87G