B <�Fd �@s�dZddlmZmZmZddlZddlmZm Z m Z m Z ddl Z ddl mZmZddlZddlmZddlmZddlmZdd lmZe ee ej�d d ��Zdd d�Zee�dd��ZdS)z\ Test scripts Test that we can run executable scripts that have been installed with numpy. �)�division�print_function�absolute_importN)�join�isfile�dirname�basename)�Popen�PIPE)� basestring)� assert_equal)�skipif)�assert_z..zsetup.pyTc Cs�t|t�r|gnt|�}tjdkr0dd�|D�}t|ttd�}|��\}}|��dkr^|� �|r�|j dkr�t d� dd d d d d d dg�� |||���|j ||fS)ap Run command sequence `cmd` returning exit code, stdout, stderr Parameters ---------- cmd : str or sequence string with command name or sequence of strings defining command check_code : {True, False}, optional If True, raise error for non-zero return code Returns ------- returncode : int return code from execution of `cmd` stdout : bytes (python 3) or str (python 2) stdout from `cmd` stderr : bytes (python 3) or str (python 2) stderr from `cmd` Raises ------ RuntimeError If `check_code` is True, and return code !=0 �ntcSs"g|]}d|krd�|�n|�qS)� z"{0}")�format)�.0�c�r�K/opt/alt/python37/lib64/python3.7/site-packages/numpy/tests/test_scripts.py� <listcomp>1szrun_command.<locals>.<listcomp>)�stdout�stderrNr� zCommand "{0}" failed withrz------z{1}�rz{2})� isinstancer �list�os�namer r Z communicateZpollZ terminate� returncode� RuntimeErrorrr)�cmdZ check_code�procrrrrr� run_commands   r#c Cs�tjdkr^ttj�}|�d�r(d|}nd|}ttj|dg�\}}}|��dk}t|d�n�tj}t |j �}t |j �}dd|d|d |f} d }xD| D]<}y*t|dg�\}}}t |��d�d }PWq�Yq�Xq�Wd | } t|| �dS) NZwin32ZScriptsz %s\f2py.pyz%s\Scripts\f2py.pyz-v�2zWarning: f2py not found in pathZf2py�.FTz/Warning: neither %s nor %s nor %s found in path) �sys�platformr� executable�endswithr#�stripr� version_info�str�major�minorr ) �exe_dirZf2py_cmd�coderr�success�versionr-r.Z f2py_cmds�msgrrr� test_f2py>s.          r4)T)�__doc__Z __future__rrrrZos.pathrZpathjoinrrrr&� subprocessr r ZnumpyZnpZnumpy.compat.py3kr Z nose.toolsr Znumpy.testing.decoratorsr Z numpy.testingr�__file__Z is_inplacer#r4rrrr�<module>s     *