o
    iJ                     @   s   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 dZ
ede
ZG dd	 d	Zd
d ZdddZedkr@e  dS dS )z:Module for displaying information about Numba's gdb set up    )
namedtupleN)dedent)configz4binary_loc, extension_loc, py_ver, np_ver, supported	_gdb_infoc                   @   sZ   e Zd ZdZdd ZdddZedd Zed	d
 Z	dd Z
dd Zdd Zdd ZdS )_GDBTestWrapperzmWraps the gdb binary and has methods for checking what the gdb binary
    has support for (Python and NumPy).c                 C   s,   t j}|d u rdt j }t||| _d S )Nz.No valid binary could be found for gdb named: )r   Z
GDB_BINARY
ValueError_gdb_binary)self
gdb_binarymsg r   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/misc/numba_gdbinfo.py__init__   s   
z_GDBTestWrapper.__init__r   c                 C   sH   | j dg}|D ]}|d || q|ddg tj|ddddS )Nz-qz-exqT
   )capture_outputtimeouttext)r
   appendextend
subprocessrun)r	   cmdZgdb_callxr   r   r   _run_cmd   s   


z_GDBTestWrapper._run_cmdc                 C   s   | j S )N)r   r	   r   r   r   r
   #   s   z_GDBTestWrapper.gdb_binaryc                 C   s
   |j dkS )Nr   )
returncode)clsstatusr   r   r   success'   s   
z_GDBTestWrapper.successc                 C   s   |   S )zChecks that gdb will launch okr   r   r   r   r   check_launch+   s   z_GDBTestWrapper.check_launchc                 C      d}|  |fS )NzUpython from __future__ import print_function; import sys; print(sys.version_info[:2])r    r	   r   r   r   r   check_python/   s   z_GDBTestWrapper.check_pythonc                 C   r"   )Nztpython from __future__ import print_function; import types; import numpy; print(isinstance(numpy, types.ModuleType))r    r#   r   r   r   check_numpy4      z_GDBTestWrapper.check_numpyc                 C   r"   )Nzapython from __future__ import print_function; import types; import numpy;print(numpy.__version__)r    r#   r   r   r   check_numpy_version:   r&   z#_GDBTestWrapper.check_numpy_versionN)r   )__name__
__module____qualname____doc__r   r   propertyr
   classmethodr   r!   r$   r%   r'   r   r   r   r   r      s    
	

r   c               
   C   sv  d} d}d}d}d}z#t  }| }||s)d|j d|j d|j }t||j} W n tyD } zd| } W Y d}~nZd}~ww | }||rt	
d	|j }	|	dur|	 \}
}|
 d
| }d}| }||rd|j vr|j dkrd}d}| }||rd|j vr|j }|r|rd}nd}nd}d}tjtjt|}t| ||||S )zEPrints information to stdout about the gdb setup that Numba has foundNFzNo Python supportzNo NumPy supportzgdb at 'z#' does not appear to work.
stdout: z	
stderr: z+Testing gdb binary failed. Reported Error: z\((\d+),\s+(\d+)\).T	TracebackTrueUnknownz!Full (Python and NumPy supported)z'Partial (Python only, no NumPy support)Nonezgdb_print_extension.py)r   r!   r   r
   stdoutstderrr   	Exceptionr$   rematchstripgroupsr%   r'   ospathjoindirname__file__r   )Z	gdb_stateZgdb_has_pythonZgdb_has_numpyZgdb_python_versionZgdb_python_numpy_versionZgdb_wrapperr   r   eZversion_matchZpymajorZpyminorZprint_ext_supportedZprint_ext_fileZprint_ext_pathr   r   r   collect_gdbinfoA   sd   





r@   -   c                 C   s   t  }td d|  d}t|d|jf  t|d|jf  t|d|jf  t|d|jf  t|d|jf  td	 td
 td|j d td d}tt| dS )z;Displays the information collected by collect_gdbinfo.
    zP--------------------------------------------------------------------------------z%-zs : %-szBinary locationzPrint extension locationzPython versionzNumPy versionz Numba printing extension support zTTo load the Numba gdb printing extension, execute the following from the gdb prompt:z
source 
a  
    =============================================================
    IMPORTANT: Before sharing you should remove any information
    in the above that you wish to keep private e.g. paths.
    =============================================================
    N)r@   printZ
binary_locZextension_locZpy_verZnp_ver	supportedr   )Zsep_posZgdb_infofmtwarnr   r   r   display_gdbinfo   s   rH   __main__)rA   )r+   collectionsr   r:   r6   r   textwrapr   Znumbar   _fieldsr   r   r@   rH   r(   r   r   r   r   <module>   s    
3
D
