diff options
author | David Sommerseth <davids@redhat.com> | 2010-04-26 20:38:57 +0200 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2010-04-26 20:38:57 +0200 |
commit | d3fd6b84f461a4d7ffbf3f3eae37381150b69e82 (patch) | |
tree | 4de791e5b791b50fe42056443b6dbfae2c3a29f1 /setup.py | |
parent | bfdcac6b16806416a6c0295fcfad5d820595d88c (diff) | |
download | python-ethtool-d3fd6b84f461a4d7ffbf3f3eae37381150b69e82.tar.gz python-ethtool-d3fd6b84f461a4d7ffbf3f3eae37381150b69e82.tar.xz python-ethtool-d3fd6b84f461a4d7ffbf3f3eae37381150b69e82.zip |
Rewritten ethtool to make use of libnl instead of accessing NETLINK directly
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 54 |
1 files changed, 53 insertions, 1 deletions
@@ -1,11 +1,51 @@ #!/usr/bin/python2 from distutils.core import setup, Extension +import commands ethtool = Extension('ethtool', sources = ['python-ethtool/ethtool.c', 'python-ethtool/etherinfo.c', 'python-ethtool/etherinfo_obj.c']) +def pkgconfig(pkg): + def _str2list(pkgstr, onlystr): + res = [] + for l in pkgstr.split(" "): + if l.find(onlystr) == 0: + res.append(l.replace(onlystr, "", 1)) + return res + + (res, cflags) = commands.getstatusoutput('pkg-config --cflags-only-other %s' % pkg) + if res != 0: + print 'Failed to query pkg-config --cflags-only-other %s' % pkg + sys.exit(1) + + (res, includes) = commands.getstatusoutput('pkg-config --cflags-only-I %s' % pkg) + if res != 0: + print 'Failed to query pkg-config --cflags-only-I %s' % pkg + sys.exit(1) + + (res, libs) = commands.getstatusoutput('pkg-config --libs-only-l %s' % pkg) + if res != 0: + print 'Failed to query pkg-config --libs-only-l %s' % pkg + sys.exit(1) + + (res, libdirs) = commands.getstatusoutput('pkg-config --libs-only-L %s' % pkg) + if res != 0: + print 'Failed to query pkg-config --libs-only-L %s' % pkg + sys.exit(1) + + + # Clean up the results and return what we've extracted from pkg-config + return {'cflags': cflags, + 'include': _str2list(includes, '-I'), + 'libs': _str2list(libs, '-l'), + 'libdirs': _str2list(libdirs, '-L') + } + + +libnl = pkgconfig('libnl-1') + # don't reformat this line, Makefile parses it setup(name='ethtool', version='0.2', @@ -13,4 +53,16 @@ setup(name='ethtool', author='Harald Hoyer & Arnaldo Carvalho de Melo', author_email='acme@redhat.com', url='http://fedoraproject.org/wiki/python-ethtool', - ext_modules=[ethtool]) + ext_modules=[ + Extension( + 'ethtool', + sources = [ + 'python-ethtool/ethtool.c', + 'python-ethtool/etherinfo.c', + 'python-ethtool/etherinfo_obj.c'], + include_dirs = libnl['include'], + library_dirs = libnl['libdirs'], + libraries = libnl['libs'] + ) + ] +) |