This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·56 lines (51 loc) · 2.06 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from distutils.core import setup, Extension
from distutils.version import LooseVersion, StrictVersion
from setuptools import setup, Extension, find_packages
import os
import re
import string
import sys
intree=0
args = sys.argv[:]
for arg in args:
if string.find(arg,'--basedir=') == 0:
basedir = string.split(arg,'=')[1]
sys.argv.remove(arg)
intree=1
if intree:
netsnmp_libs = os.popen(basedir+'/net-snmp-config --libs').read()
libdir = os.popen(basedir+'/net-snmp-config --build-lib-dirs '+basedir).read()
incdir = os.popen(basedir+'/net-snmp-config --build-includes '+basedir).read()
netsnmp_version = os.popen(basedir+'/net-snmp-config --version '+basedir).read()
libs = re.findall(r" -l(\S+)", netsnmp_libs)
libdirs = re.findall(r" -L(\S+)", libdir)
incdirs = re.findall(r" -I(\S+)", incdir)
else:
netsnmp_libs = os.popen('net-snmp-config --libs').read()
netsnmp_version = os.popen('net-snmp-config --version').read()
libdirs = re.findall(r" -L(\S+)", netsnmp_libs)
incdirs = []
libs = re.findall(r" -l(\S+)", netsnmp_libs)
if LooseVersion(netsnmp_version) >= LooseVersion("5.5.0"):
cdefs = [("NETSNMP_SINGLE_API", None)]
#netsnmp from 5.5 uses single API session pointers, like ss = snmp_sess_open(&session);
else:
cdefs = None
#netsnmp up to 5.4.4 uses traditional API session pointers, like ss = snmp_open(&session);
setup(
name="netsnmptable", version="0.1.3",
description = 'A Python package to query SNMP tables and table subsets, on top of the original Net-SNMP Python Bindings.',
author = 'Tobias Deiminger',
author_email = 'tobias.deiminger@gmail.com',
url = 'http://github.com/haxtibal/netsnmptable',
license="LGPL",
packages=['netsnmptable'],
test_suite = "tests.test",
ext_modules = [
Extension("netsnmptable.interface", ["netsnmptable/interface.c", "netsnmptable/table.c", "netsnmptable/util.c"],
library_dirs=libdirs,
include_dirs=incdirs,
libraries=libs,
define_macros=cdefs)
]
)