Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/numpy/f2py/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/numpy/f2py/tests/__pycache__/util.cpython-35.pyc



(��^$�@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZmZddlZddlmZmZyddlmZWn"ek
r�ddlmZYnXdadd	�Zd
d�Zdd
�Zdd�Zegggddd��Zegggdddd��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)�newcCsktdk	rgytjjt�Wntk
r4YnXytjt�Wnttfk
r`YnXdadS)N)	�_module_dir�sys�path�remove�
ValueError�shutil�rmtree�IOError�OSError�rr��/builddir/build/BUILDROOT/alt-python35-numpy-1.13.3-2.el8.x86_64/opt/alt/python35/lib64/python3.5/site-packages/numpy/f2py/tests/util.py�_cleanup$s
rcCsKtdkrGtj�atjt�ttjkrGtjjdt�tS)Nr)	r�tempfile�mkdtemp�atexit�registerrrr
�insertrrrr�get_module_dir2s
rcCs|t�}x`tdd�D]O}d|}tjj||�}|tjkrtjj|d�r|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<s	
&r'cs+i���fdd�}�j|_|S)Ncs�t||f�}|�krjy�||��|<Wn2tk
ri}z|�|<�WYdd}~XnX�|}t|t�r�|�|S)N)�repr�	Exception�
isinstance)�a�kw�key�e�ret)�func�memorr�wrapperJs

z_memoize.<locals>.wrapper)�__name__)r0r2r)r0r1r�_memoizeGsr4cCsBdttj�}t�}g}x�|D]�}tjj|�sQtd|��tjj|tjj|��}	t	j
||	�|j|	�tjjtjj|�d�}tjj|�r)tjj|tjj|��}	tjj|	�s)t	j
||	�q)W|dkrt
�}dd|g||}
|rL|
dg|7}
|rc|
dg|7}
tj�}z�tj|�tjd|g|
}tj|d	tjd
tj�}
|
j�\}}|
jdkr�td|d
d�t|�f��Wdtj|�x|D]}tj|�qWXt|�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	
!
!!	
$


rUcCsz|dkrd}td|��R}t|d��}|j|�WdQRXt|gd|d|d|d|�SWdQRXdS)	z6
    Compile and import Fortran code using f2py.

    Nz.f�suffix�wrHrIrJrK)r�open�writerU)Zsource_coderHrIrJrVrKr
�frrr�
build_code�sr[cCs&tdk	rtSdad}|tdttj��}tdd��r}t|d��}|j|�WdQRXtj|dg}t	j
|dt	jd	t	j�}|j
�\}}WdQRXtjd
|�}|r"tt|jd���tt|jd���tt|jd
���fatS)NFa7
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)
�syspathrVz.pyrW�configr5r6sCOMPILERS:(\d+),(\d+),(\d+)���)FFF)�_compiler_status�dictr(rr
rrXrYr>r?r@rArBrC�re�search�bool�int�group)rL�scriptrZrQrRrSrT�mrrr�_get_compiler_status�s"0rjcCst�dS)Nr)rjrrrr�has_c_compiler�srkcCst�dS)Nr^)rjrrrr�has_f77_compiler�srlcCst�dS)Nr_)rjrrrr�has_f90_compiler�srmcKsddlm}ddlm}t�}g}xn|D]f}tjj|�s^td|��tjj	|tjj
|��}	tj||	�|j
|	�q6Wtj|�jdd�}dtd|d	ttj��}
tjj	|t�d
�}|j
|�t|d�}|jt|
��|j�tj�}
z�tj|�tj|dd
g}tj|dtjdtj�}|j �\}}|j!dkr�td|dd�t"|�f��Wdtj|
�x|D]}tj#|�q�WXt$|�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-ir5r6z%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@sLeZdZdZdZgZgZgZdZdZ	dZ
dd�ZdS)�F2PyTestNz.fcCs|jdk	rdSt�s(td��g}|jrG|j|j�|jdk	rf|j|j�d}d}x;|D]3}|jd�r�d}qy|jd�ryd}qyW|r�t	�r�td��|r�t
�r�td��|jdk	r6t|jd|jd	|j
d
|jd|jd|j�|_|jdk	r{t|jd|jd	|j
d
|jd|j�|_dS)
NzNo C compiler availableFz.fTz.f90z No Fortran 77 compiler availablez No Fortran 90 compiler availablerHrIrJrVrK)�modulerkr�sources�extendrLr:rV�endswithrlrmr[rHrIrJrKrU)�self�codesZ	needs_f77Z	needs_f90r&rrr�setUpBs:		
	
	zF2PyTest.setUp)r3�
__module__�__qualname__rLr}rHrIrJrVr|rKr�rrrrr{8sr{))�__doc__�
__future__rrrrrr?rrrrvrc�random�numpy.compatrr�
numpy.f2py�numpy�
numpy.testingrr�hashlibr	�ImportErrorr
rrrr'r4rUr[rarjrkrlrmrz�objectr{rrrr�<module>sD

:1H