$93 GRAYBYTE WORDPRESS FILE MANAGER $17

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python37/lib64/python3.7/site-packages/numpy/distutils/

HOME
Current File : /opt/alt/python37/lib64/python3.7/site-packages/numpy/distutils//lib2def.py
from __future__ import division, absolute_import, print_function

import re
import sys
import os
import subprocess

__doc__ = """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
"""

__version__ = '0.1a'

py_ver = "%d%d" % tuple(sys.version_info[:2])

DEFAULT_NM = 'nm -Cs'

DEF_HEADER = """LIBRARY         python%s.dll
;CODE           PRELOAD MOVEABLE DISCARDABLE
;DATA           PRELOAD SINGLE

EXPORTS
""" % py_ver
# the header of the DEF file

FUNC_RE = re.compile(r"^(.*) in python%s\.dll" % py_ver, re.MULTILINE)
DATA_RE = re.compile(r"^_imp__(.*) in python%s\.dll" % py_ver, re.MULTILINE)

def parse_cmd():
    """Parses the command-line arguments.

libfile, deffile = parse_cmd()"""
    if len(sys.argv) == 3:
        if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
            libfile, deffile = sys.argv[1:]
        elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
            deffile, libfile = sys.argv[1:]
        else:
            print("I'm assuming that your first argument is the library")
            print("and the second is the DEF file.")
    elif len(sys.argv) == 2:
        if sys.argv[1][-4:] == '.def':
            deffile = sys.argv[1]
            libfile = 'python%s.lib' % py_ver
        elif sys.argv[1][-4:] == '.lib':
            deffile = None
            libfile = sys.argv[1]
    else:
        libfile = 'python%s.lib' % py_ver
        deffile = None
    return libfile, deffile

def getnm(nm_cmd = ['nm', '-Cs', 'python%s.lib' % py_ver]):
    """Returns the output of nm_cmd via a pipe.

nm_output = getnam(nm_cmd = 'nm -Cs py_lib')"""
    f = subprocess.Popen(nm_cmd, shell=True, stdout=subprocess.PIPE, universal_newlines=True)
    nm_output = f.stdout.read()
    f.stdout.close()
    return nm_output

def parse_nm(nm_output):
    """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)"""
    data = DATA_RE.findall(nm_output)
    func = FUNC_RE.findall(nm_output)

    flist = []
    for sym in data:
        if sym in func and (sym[:2] == 'Py' or sym[:3] == '_Py' or sym[:4] == 'init'):
            flist.append(sym)

    dlist = []
    for sym in data:
        if sym not in flist and (sym[:2] == 'Py' or sym[:3] == '_Py'):
            dlist.append(sym)

    dlist.sort()
    flist.sort()
    return dlist, flist

def output_def(dlist, flist, header, file = sys.stdout):
    """Outputs the final DEF file to a file defaulting to stdout.

output_def(dlist, flist, header, file = sys.stdout)"""
    for data_sym in dlist:
        header = header + '\t%s DATA\n' % data_sym
    header = header + '\n' # blank line
    for func_sym in flist:
        header = header + '\t%s\n' % func_sym
    file.write(header)

if __name__ == '__main__':
    libfile, deffile = parse_cmd()
    if deffile is None:
        deffile = sys.stdout
    else:
        deffile = open(deffile, 'w')
    nm_cmd = [str(DEFAULT_NM), str(libfile)]
    nm_output = getnm(nm_cmd)
    dlist, flist = parse_nm(nm_output)
    output_def(dlist, flist, DEF_HEADER, deffile)

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 3.40 AM
root / root
0755
__pycache__
--
31 Aug 2024 3.40 AM
root / root
0755
command
--
31 Aug 2024 3.40 AM
root / root
0755
fcompiler
--
31 Aug 2024 3.40 AM
root / root
0755
mingw
--
31 Aug 2024 3.40 AM
root / root
0755
tests
--
31 Aug 2024 3.40 AM
root / root
0755
__config__.py
1.14 KB
25 Apr 2023 2.38 AM
root / root
0644
__init__.py
0.729 KB
25 Apr 2023 2.30 AM
root / root
0644
__version__.py
0.147 KB
25 Apr 2023 2.30 AM
root / root
0644
ccompiler.py
27.868 KB
25 Apr 2023 2.30 AM
root / root
0644
compat.py
0.213 KB
25 Apr 2023 2.30 AM
root / root
0644
conv_template.py
9.46 KB
25 Apr 2023 2.30 AM
root / root
0644
core.py
7.991 KB
25 Apr 2023 2.30 AM
root / root
0644
cpuinfo.py
22.429 KB
25 Apr 2023 2.30 AM
root / root
0644
environment.py
2.291 KB
25 Apr 2023 2.30 AM
root / root
0644
exec_command.py
8.46 KB
25 Apr 2023 2.30 AM
root / root
0644
extension.py
2.897 KB
25 Apr 2023 2.30 AM
root / root
0644
from_template.py
7.625 KB
25 Apr 2023 2.30 AM
root / root
0644
info.py
0.153 KB
25 Apr 2023 2.30 AM
root / root
0644
intelccompiler.py
4.19 KB
25 Apr 2023 2.30 AM
root / root
0644
lib2def.py
3.43 KB
25 Apr 2023 2.30 AM
root / root
0644
line_endings.py
2.005 KB
25 Apr 2023 2.30 AM
root / root
0644
log.py
2.681 KB
25 Apr 2023 2.30 AM
root / root
0644
mingw32ccompiler.py
24.558 KB
25 Apr 2023 2.30 AM
root / root
0644
misc_util.py
80.051 KB
25 Apr 2023 2.30 AM
root / root
0644
msvc9compiler.py
2.205 KB
25 Apr 2023 2.30 AM
root / root
0644
msvccompiler.py
1.944 KB
25 Apr 2023 2.30 AM
root / root
0644
npy_pkg_config.py
12.933 KB
25 Apr 2023 2.30 AM
root / root
0644
numpy_distribution.py
0.684 KB
25 Apr 2023 2.30 AM
root / root
0644
pathccompiler.py
0.761 KB
25 Apr 2023 2.30 AM
root / root
0644
setup.py
0.575 KB
25 Apr 2023 2.30 AM
root / root
0644
site.cfg
0.17 KB
25 Apr 2023 2.30 AM
root / root
0644
system_info.py
83.284 KB
25 Apr 2023 2.30 AM
root / root
0644
unixccompiler.py
5.035 KB
25 Apr 2023 2.30 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF