HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/numpy/distutils/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/numpy/distutils/__pycache__/lib2def.cpython-36.pyc
3

���h<�@sddlZddlZddlZdZdZdeejdd��ZddgZdeZ	ej
d	eej�Zej
d
eej�Z
dd�Zddd
egdfdd�Zdd�Zejfdd�Zedk�re�\ZZedkr�ejZn
eed�Zeee�gZeedd�Zee�\ZZeeee	e�dS)�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\.dllcCsttj�dkr�tjddd�dkrNtjddd�dkrNtjdd�\}}nPtjdd
d�dkr�tjddd�dkr�tjdd�\}}ntd�td	�nnttj�dk�rtjddd�dkr�tjd}d
t}n&tjddd�dk�rd}tjd}nd
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.zpython%s.lib���rrrrr)�len�sys�argv�print�py_ver)�libfile�deffile�r�8/tmp/pip-build-5_djhm0z/numpy/numpy/distutils/lib2def.py�	parse_cmd&s",,


rzpython%s.libTcCsHtj||tjtjdd�}|j�\}}|jdkrDtddj|�|f��|S)zUReturns the output of nm_cmd via a pipe.

nm_output = getnm(nm_cmd = 'nm -Cs py_lib')T)�shell�stdout�stderr�universal_newlinesrzfailed to run "%s": "%s"� )�
subprocess�Popen�PIPE�communicate�
returncode�RuntimeError�join)�nm_cmdr�p�	nm_outputZnm_errrrr�getnm>s
r!cCs�tj|�}tj|�}g}xN|D]F}||kr|dd�dksZ|dd�dksZ|dd�dkr|j|�qWg}x>|D]6}||krr|dd�dks�|dd�dkrr|j|�qrW|j�|j�||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)NrZPyrZ_Pyr�init)�DATA_RE�findall�FUNC_RE�append�sort)r �data�func�flist�sym�dlistrrr�parse_nmJs


8
(r-cCsJx|D]}|d|}qW|d}x|D]}|d|}q(W|j|�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)r,r*�header�fileZdata_symZfunc_symrrr�
output_def`s

r2�__main__�wF)r)�rer	r�__doc__�__version__�tuple�version_inforZ
DEFAULT_NMZ
DEF_HEADER�compile�	MULTILINEr%r#rr!r-rr2�__name__r
r�open�strrr r,r*rrrr�<module>s,