Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../site-pac.../cffi
File: ffiplatform.py
import sys, os
[0] Fix | Delete
from .error import VerificationError
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs',
[4] Fix | Delete
'extra_objects', 'depends']
[5] Fix | Delete
[6] Fix | Delete
def get_extension(srcfilename, modname, sources=(), **kwds):
[7] Fix | Delete
_hack_at_distutils()
[8] Fix | Delete
from distutils.core import Extension
[9] Fix | Delete
allsources = [srcfilename]
[10] Fix | Delete
for src in sources:
[11] Fix | Delete
allsources.append(os.path.normpath(src))
[12] Fix | Delete
return Extension(name=modname, sources=allsources, **kwds)
[13] Fix | Delete
[14] Fix | Delete
def compile(tmpdir, ext, compiler_verbose=0, debug=None):
[15] Fix | Delete
"""Compile a C extension module using distutils."""
[16] Fix | Delete
[17] Fix | Delete
_hack_at_distutils()
[18] Fix | Delete
saved_environ = os.environ.copy()
[19] Fix | Delete
try:
[20] Fix | Delete
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
[21] Fix | Delete
outputfilename = os.path.abspath(outputfilename)
[22] Fix | Delete
finally:
[23] Fix | Delete
# workaround for a distutils bugs where some env vars can
[24] Fix | Delete
# become longer and longer every time it is used
[25] Fix | Delete
for key, value in saved_environ.items():
[26] Fix | Delete
if os.environ.get(key) != value:
[27] Fix | Delete
os.environ[key] = value
[28] Fix | Delete
return outputfilename
[29] Fix | Delete
[30] Fix | Delete
def _build(tmpdir, ext, compiler_verbose=0, debug=None):
[31] Fix | Delete
# XXX compact but horrible :-(
[32] Fix | Delete
from distutils.core import Distribution
[33] Fix | Delete
import distutils.errors, distutils.log
[34] Fix | Delete
#
[35] Fix | Delete
dist = Distribution({'ext_modules': [ext]})
[36] Fix | Delete
dist.parse_config_files()
[37] Fix | Delete
options = dist.get_option_dict('build_ext')
[38] Fix | Delete
if debug is None:
[39] Fix | Delete
debug = sys.flags.debug
[40] Fix | Delete
options['debug'] = ('ffiplatform', debug)
[41] Fix | Delete
options['force'] = ('ffiplatform', True)
[42] Fix | Delete
options['build_lib'] = ('ffiplatform', tmpdir)
[43] Fix | Delete
options['build_temp'] = ('ffiplatform', tmpdir)
[44] Fix | Delete
#
[45] Fix | Delete
try:
[46] Fix | Delete
old_level = distutils.log.set_threshold(0) or 0
[47] Fix | Delete
try:
[48] Fix | Delete
distutils.log.set_verbosity(compiler_verbose)
[49] Fix | Delete
dist.run_command('build_ext')
[50] Fix | Delete
cmd_obj = dist.get_command_obj('build_ext')
[51] Fix | Delete
[soname] = cmd_obj.get_outputs()
[52] Fix | Delete
finally:
[53] Fix | Delete
distutils.log.set_threshold(old_level)
[54] Fix | Delete
except (distutils.errors.CompileError,
[55] Fix | Delete
distutils.errors.LinkError) as e:
[56] Fix | Delete
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
[57] Fix | Delete
#
[58] Fix | Delete
return soname
[59] Fix | Delete
[60] Fix | Delete
try:
[61] Fix | Delete
from os.path import samefile
[62] Fix | Delete
except ImportError:
[63] Fix | Delete
def samefile(f1, f2):
[64] Fix | Delete
return os.path.abspath(f1) == os.path.abspath(f2)
[65] Fix | Delete
[66] Fix | Delete
def maybe_relative_path(path):
[67] Fix | Delete
if not os.path.isabs(path):
[68] Fix | Delete
return path # already relative
[69] Fix | Delete
dir = path
[70] Fix | Delete
names = []
[71] Fix | Delete
while True:
[72] Fix | Delete
prevdir = dir
[73] Fix | Delete
dir, name = os.path.split(prevdir)
[74] Fix | Delete
if dir == prevdir or not dir:
[75] Fix | Delete
return path # failed to make it relative
[76] Fix | Delete
names.append(name)
[77] Fix | Delete
try:
[78] Fix | Delete
if samefile(dir, os.curdir):
[79] Fix | Delete
names.reverse()
[80] Fix | Delete
return os.path.join(*names)
[81] Fix | Delete
except OSError:
[82] Fix | Delete
pass
[83] Fix | Delete
[84] Fix | Delete
# ____________________________________________________________
[85] Fix | Delete
[86] Fix | Delete
try:
[87] Fix | Delete
int_or_long = (int, long)
[88] Fix | Delete
import cStringIO
[89] Fix | Delete
except NameError:
[90] Fix | Delete
int_or_long = int # Python 3
[91] Fix | Delete
import io as cStringIO
[92] Fix | Delete
[93] Fix | Delete
def _flatten(x, f):
[94] Fix | Delete
if isinstance(x, str):
[95] Fix | Delete
f.write('%ds%s' % (len(x), x))
[96] Fix | Delete
elif isinstance(x, dict):
[97] Fix | Delete
keys = sorted(x.keys())
[98] Fix | Delete
f.write('%dd' % len(keys))
[99] Fix | Delete
for key in keys:
[100] Fix | Delete
_flatten(key, f)
[101] Fix | Delete
_flatten(x[key], f)
[102] Fix | Delete
elif isinstance(x, (list, tuple)):
[103] Fix | Delete
f.write('%dl' % len(x))
[104] Fix | Delete
for value in x:
[105] Fix | Delete
_flatten(value, f)
[106] Fix | Delete
elif isinstance(x, int_or_long):
[107] Fix | Delete
f.write('%di' % (x,))
[108] Fix | Delete
else:
[109] Fix | Delete
raise TypeError(
[110] Fix | Delete
"the keywords to verify() contains unsupported object %r" % (x,))
[111] Fix | Delete
[112] Fix | Delete
def flatten(x):
[113] Fix | Delete
f = cStringIO.StringIO()
[114] Fix | Delete
_flatten(x, f)
[115] Fix | Delete
return f.getvalue()
[116] Fix | Delete
[117] Fix | Delete
def _hack_at_distutils():
[118] Fix | Delete
# Windows-only workaround for some configurations: see
[119] Fix | Delete
# https://bugs.python.org/issue23246 (Python 2.7 with
[120] Fix | Delete
# a specific MS compiler suite download)
[121] Fix | Delete
if sys.platform == "win32":
[122] Fix | Delete
try:
[123] Fix | Delete
import setuptools # for side-effects, patches distutils
[124] Fix | Delete
except ImportError:
[125] Fix | Delete
pass
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function