-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsetup.py
More file actions
42 lines (35 loc) · 1.2 KB
/
Copy pathsetup.py
File metadata and controls
42 lines (35 loc) · 1.2 KB
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
"""Build the netsnmp C extension.
Static project metadata lives in pyproject.toml. This file only remains for
the parts that can't be expressed declaratively: the net-snmp client library
is discovered at build time via net-snmp-config.
"""
import os
import re
import sys
from setuptools import Extension, setup
def netsnmp_config(flag):
cmd = 'net-snmp-config ' + flag
if sys.platform == 'win32':
# net-snmp-config is a POSIX shell script; on Windows os.popen goes
# through cmd.exe which can't execute it, so run it via sh (available
# in the MSYS2/mingw environment used to build the extension).
cmd = 'sh -c "net-snmp-config %s"' % flag
return os.popen(cmd).read()
netsnmp_libs = netsnmp_config('--libs')
libdirs = re.findall(r" -L(\S+)", netsnmp_libs)
incdirs = []
libs = re.findall(r" -l(\S+)", netsnmp_libs)
if sys.platform == 'win32':
# inet_addr() and the winsock symbols net-snmp relies on come from ws2_32.
libs.append('ws2_32')
setup(
ext_modules=[
Extension(
"netsnmp.client_intf",
["netsnmp/client_intf.c"],
library_dirs=libdirs,
include_dirs=incdirs,
libraries=libs,
)
],
)