HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/numpy/distutils/__pycache__/lib2def.cpython-310.pyc
o

���g.�@sddlZddlZddlZdZdZdeejdd��ZddgZdeZ	e�
d	eej�Ze�
d
eej�Z
dd�Zddd
egdfdd�Zdd�Zejfdd�Zedkr�e�\ZZeduraejZneed�Zeee�gZeedd�Zee�\ZZeeee	e�dSdS)�Na�This module generates a DEF file from the symbols in
an MSVC-compiled DLL import library.  It correctly discriminates between
data and functions.  The data is collected from the output of the program
nm(1).

Usage:
    python lib2def.py [libname.lib] [output.def]
or
    python lib2def.py [libname.lib] > output.def

libname.lib defaults to python<py_ver>.lib and output.def defaults to stdout

Author: Robert Kern <kernr@mail.ncifcrf.gov>
Last Update: April 30, 1999
z0.1az%d%d��nmz-CszrLIBRARY         python%s.dll
;CODE           PRELOAD MOVEABLE DISCARDABLE
;DATA           PRELOAD SINGLE

EXPORTS
z^(.*) in python%s\.dllz^_imp__(.*) in python%s\.dllcCs0ttj�dkrYtjddd�dkr*tjddd�dkr*tjdd�\}}||fStjddd�dkrMtjddd�dkrMtjdd�\}}||fStd�td	�||fSttj�dkr�tjddd�dkrxtjd}d
t}||fStjddd�dkr�d}tjd}||fSd
t}d}||fS)zBParses the command-line arguments.

libfile, deffile = parse_cmd()�����Nz.librz.defz4I'm assuming that your first argument is the libraryzand the second is the DEF file.�python%s.lib)�len�sys�argv�print�py_ver)�libfile�deffile�r�B/usr/local/lib/python3.10/dist-packages/numpy/distutils/lib2def.py�	parse_cmd&s,,,���
�
�rrTcCsHtj||tjtjdd�}|��\}}|jdkr"tdd�|�|f��|S)zUReturns the output of nm_cmd via a pipe.

nm_output = getnm(nm_cmd = 'nm -Cs py_lib')T)�shell�stdout�stderr�textrzfailed to run "%s": "%s"� )�
subprocess�Popen�PIPE�communicate�
returncode�RuntimeError�join)�nm_cmdr�p�	nm_output�nm_errrrr�getnm>s�

�r"cCs�t�|�}t�|�}g}|D]#}||vr1|dd�dks,|dd�dks,|dd�dkr1|�|�qg}|D]}||vrQ|dd�dksL|dd�dkrQ|�|�q6|��|��||fS)z�Returns a tuple of lists: dlist for the list of data
symbols and flist for the list of function symbols.

dlist, flist = parse_nm(nm_output)Nr�Pyr�_Py��init)�DATA_RE�findall�FUNC_RE�append�sort)r �data�func�flist�sym�dlistrrr�parse_nmJs

8
�(
�r1cCsB|D]}|d|}q|d}|D]}|d|}q|�|�dS)zoOutputs the final DEF file to a file defaulting to stdout.

output_def(dlist, flist, header, file = sys.stdout)z		%s DATA
�
z	%s
N)�write)r0r.�header�file�data_sym�func_symrrr�
output_def`sr8�__main__�wF)r)�rer	r�__doc__�__version__�tuple�version_infor�
DEFAULT_NM�
DEF_HEADER�compile�	MULTILINEr)r'rr"r1rr8�__name__r
r�open�strrr r0r.rrrr�<module>s4�

�