Ñò
\ÐKc
@ se d d k Z d d k Z d d k Z d d k Z d Z d Z d e e i d ƒ Z d Z d e Z
e i d e e i ƒ Z
e i d e e i ƒ Z d
„ Z d d d
e g d „ Z d „ Z e i d „ Z e d j o… e ƒ \ Z Z e d j o
e i Z n e e d ƒ Z e e ƒ e e ƒ g Z e e ƒ Z e e ƒ \ Z Z e e e e
e ƒ n d S( iÿÿÿÿNsÔ 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.lib and output.def defaults to stdout
Author: Robert Kern
Last Update: April 30, 1999
s 0.1as %d%di s nm -Cssr LIBRARY python%s.dll
;CODE PRELOAD MOVEABLE DISCARDABLE
;DATA PRELOAD SINGLE
EXPORTS
s ^(.*) in python%s\.dlls ^_imp__(.*) in python%s\.dllc C sH t t i ƒ d j oœ t i d d d j o/ t i d d d j o t i d \ } } q>t i d d d j o/ t i d d d j o t i d \ } } q>d GHd GHn t t i ƒ d j of t i d d d j o t i d } d t } q>t i d d d j o d
} t i d } q>n d t } d
} | | f S( sB Parses the command-line arguments.
libfile, deffile = parse_cmd()i i iüÿÿÿs .libi s .defs4 I'm assuming that your first argument is the librarys and the second is the DEF file.s python%s.libN( t lent syst argvt py_vert None( t libfilet deffile( ( s= /usr/lib64/python2.6/site-packages/numpy/distutils/lib2def.pyt parse_cmd' s" 00
t nms -Css python%s.libc C s> t i | d t d t i ƒ} | i i ƒ } | i i ƒ | S( sV Returns the output of nm_cmd via a pipe.
nm_output = getnam(nm_cmd = 'nm -Cs py_lib')t shellt stdout( t
subprocesst Popent Truet PIPER
t readt close( t nm_cmdt ft nm_output( ( s= /usr/lib64/python2.6/site-packages/numpy/distutils/lib2def.pyt getnm? s
c C sû t i | ƒ } t i | ƒ } g } x_ | D]W } | | j oD | d d j p" | d d j p | d d j o | i | ƒ q+ q+ Wg } xN | D]F } | | j o3 | d d j p | d d j o | i | ƒ q“ q“ W| i ƒ | i ƒ | | f S( sŒ 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)i t Pyi t _Pyi t init( t DATA_REt findallt FUNC_REt appendt sort( R t datat funct flistt symt dlist( ( s= /usr/lib64/python2.6/site-packages/numpy/distutils/lib2def.pyt parse_nmH s @ /
c C sY x | D] } | d | } q W| d } x | D] } | d | } q0 W| i | ƒ d S( so Outputs the final DEF file to a file defaulting to stdout.
output_def(dlist, flist, header, file = sys.stdout)s %s DATA
s
s %s
N( t write( R! R t headert filet data_symt func_sym( ( s= /usr/lib64/python2.6/site-packages/numpy/distutils/lib2def.pyt
output_def^ s
t __main__t w( t reR t osR t __doc__t __version__t tuplet version_infoR t
DEFAULT_NMt
DEF_HEADERt compilet MULTILINER R R R R" R
R( t __name__R R R t opent strR R R! R ( ( ( s= /usr/lib64/python2.6/site-packages/numpy/distutils/lib2def.pyt s.