Commit 00b8a403 authored by Brenden Blanco's avatar Brenden Blanco

Fix python2.7 compatibility breakage

* Add requirement on 'future' package to ensure backwards compatibility
 - If working in dev environment, do 'sudo pip install future'

Note: end-users installing a compiled package with pip should have
future installed as a dependency automatically.
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent aa5e456b
......@@ -15,6 +15,7 @@
import atexit
import ctypes as ct
import json
from past.builtins import basestring
import os
lib = ct.CDLL("libbpfprog.so")
......@@ -190,7 +191,7 @@ class BPF(object):
}
@staticmethod
def _decode_table_type(desc):
if isinstance(desc, str):
if isinstance(desc, basestring):
return BPF.str2ctype[desc]
fields = []
for t in desc[1]:
......@@ -198,7 +199,7 @@ class BPF(object):
fields.append((t[0], BPF._decode_table_type(t[1])))
elif len(t) == 3:
fields.append((t[0], BPF._decode_table_type(t[1]), t[2]))
cls = type(desc[0], (ct.Structure,), dict(_fields_=fields))
cls = type(str(desc[0]), (ct.Structure,), dict(_fields_=fields))
return cls
def get_table(self, name, keytype=None, leaftype=None):
......
......@@ -10,4 +10,4 @@ setup(name='bpf',
url='http://plumgrid.com',
packages=['bpf'],
platforms=['Linux'],
requires=[])
install_requires=['future'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment