Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/numpy/f2py/tests/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/numpy/f2py/tests/__pycache__/util.cpython-37.pyc

B

��Fd$�@sPdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZddlZddlmZmZyddlmZWn ek
r�ddlmZYnXdadd	�Zd
d�Zdd
�Zdd�Zegggdfdd��Zegggddfdd��Z da!dd�Z"dd�Z#dd�Z$dd�Z%edd��Z&Gdd�de'�Z(dS) z�
Utility functions for

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

�)�division�absolute_import�print_functionN)�asbytes�asstr)�SkipTest�temppath)�md5)�newc	Cs^tdk	rZytj�t�Wntk
r,YnXyt�t�Wnttfk
rTYnXdadS)N)	�_module_dir�sys�path�remove�
ValueError�shutil�rmtree�IOError�OSError�rr��/builddir/build/BUILDROOT/alt-python37-numpy-1.13.3-8.el8.x86_64/opt/alt/python37/lib64/python3.7/site-packages/numpy/f2py/tests/util.py�_cleanup$srcCs6tdkr2t��at�t�ttjkr2tj�dt�tS)Nr)	r�tempfile�mkdtemp�atexit�registerrrr
�insertrrrr�get_module_dir2s

rcCsZt�}xFtdd�D]8}d|}tj�||�}|tjkrtj�|d�s|SqWtd��dS)Nii��z_test_ext_module_%dz.pyz(Failed to create a temporary module name)	r�range�osr
�joinr�modules�isfile�RuntimeError)�d�j�name�fnrrr�get_temp_module_name<sr'csi���fdd�}�j|_|S)Nc
snt||f�}|�krTy�||��|<Wn,tk
rR}z|�|<�Wdd}~XYnX�|}t|t�rj|�|S)N)�repr�	Exception�
isinstance)�a�kw�key�e�ret)�func�memorr�wrapperJs
z_memoize.<locals>.wrapper)�__name__)r0r2r)r0r1r�_memoizeGsr4c
Cs�dttj�}t�}g}x�|D]�}tj�|�s:td|��tj�|tj�|��}	t	�
||	�|�|	�tj�tj�|�d�}tj�|�rtj�|tj�|��}	tj�|	�st	�
||	�qW|dkr�t
�}dd|g||}
|r�|
dg|7}
|r�|
dg|7}
t��}zft�|�tjd|g|
}tj|tjtjd	�}
|
��\}}|
jd
k�rjtd|dd�t|�f��Wdt�|�x|D]}t�|��q~WXt|�tj|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 filez.f2py_f2cmapNz-cz-mzskip:zonly:)�stdout�stderrrzRunning f2py failed: %s
%s�)r(rr
rrr!r"r�basenamer�copyfile�append�dirnamer'�getcwd�chdir�
executable�
subprocess�Popen�PIPE�STDOUT�communicate�
returncoder�unlink�
__import__r )�source_files�options�skip�only�module_name�coder#�dst_sourcesr&�dst�	f2py_opts�cwd�cmd�p�out�errrrr�build_module^sJ






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

    Nz.f)�suffix�w)rHrIrJrK)r�open�writerU)Zsource_coderHrIrJrVrKr
�frrr�
build_code�sr[c
Cs�tdk	rtSdad}|tttj�d�}tdd��R}t|d��}|�|�WdQRXtj|dg}t	j
|t	jt	jd�}|�
�\}}WdQRXt�d	|�}|r�tt|�d
���tt|�d���tt|�d���fatS)
N)FFFa7
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)
)�syspathz.py)rVrW�config)r5r6sCOMPILERS:(\d+),(\d+),(\d+)���)�_compiler_status�dictr(rr
rrXrYr>r?r@rArBrC�re�search�bool�int�group)rL�scriptrZrQrRrSrT�mrrr�_get_compiler_status�s"

 rjcCs
t�dS)Nr)rjrrrr�has_c_compiler�srkcCs
t�dS)Nr^)rjrrrr�has_f77_compiler�srlcCs
t�dS)Nr_)rjrrrr�has_f90_compiler�srmc
Ks�ddlm}ddlm}t�}g}xP|D]H}tj�|�sDtd|��tj�	|tj�
|��}	t�||	�|�
|	�q(Wt�|��dd�}dt|ttj�d�}
tj�	|t�d	�}|�
|�t|d
�}|�t|
��|��t��}
zdt�|�tj|ddg}tj|tjtjd
�}|� �\}}|j!dk�rDtd|dd�t"|�f��Wdt�|
�x|D]}t�#|��qXWXt$|�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�wb�	build_extz-i)r5r6z%Running distutils build failed: %s
%sr7N)&�numpy.distutils.misc_utilrn�numpy.distutils.corerorrr
r!r"rr8rr9r:�textwrap�dedent�replacerbr(rr'rXrYr�closer<r=r>r?r@rArBrCrDrrErFr )rGrqrKr,rnror#rMr&rNrLrhrZrPrQrRrSrTrrr�build_module_distutils�s@







rzc@s4eZdZdZdZgZgZgZdZdZ	dZ
dd�ZdS)�F2PyTestNz.fcCs�|jdk	rdSt�std��g}|jr2|�|j�|jdk	rH|�|j�d}d}x*|D]"}|�d�rjd}qV|�d�rVd}qVW|r�t	�s�td��|r�t
�s�td��|jdk	r�t|j|j|j
|j|j|jd�|_|jdk	r�t|j|j|j
|j|jd	�|_dS)
NzNo C compiler availableFz.fTz.f90z No Fortran 77 compiler availablez No Fortran 90 compiler available)rHrIrJrVrK)rHrIrJrK)�modulerkr�sources�extendrLr:rV�endswithrlrmr[rHrIrJrKrU)�self�codesZ	needs_f77Z	needs_f90r&rrr�setUpBs:










zF2PyTest.setUp)r3�
__module__�__qualname__rLr}rHrIrJrVr|rKr�rrrrr{8sr{))�__doc__�
__future__rrrrrr?rrrrvrc�random�numpy.compatrr�
numpy.f2py�numpy�
numpy.testingrr�hashlibr	�ImportErrorr
rrrr'r4rUr[rarjrkrlrmrz�objectr{rrrr�<module>sD
:1H