Build against Python3

This commit is contained in:
Josef Ridky 2018-02-27 13:48:26 +01:00
parent 08064860dd
commit 7486c6880d
2 changed files with 428 additions and 10 deletions

View File

@ -0,0 +1,413 @@
diff -urNp old/configure new/configure
--- old/configure 2018-02-27 09:13:39.865414853 +0100
+++ new/configure 2018-02-27 09:25:30.341067359 +0100
@@ -6412,8 +6412,8 @@ $as_echo "no" >&6; }
fi
-# Extract the first word of "python", so it can be a program name with args.
-set dummy python; ac_word=$2
+# Extract the first word of "python3", so it can be a program name with args.
+set dummy python3; ac_word="python3"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PYTHONPROG+:} false; then :
diff -urNp old/Makefile.in new/Makefile.in
--- old/Makefile.in 2018-02-27 09:13:39.863414712 +0100
+++ new/Makefile.in 2018-02-27 12:14:02.428730316 +0100
@@ -222,7 +222,7 @@ perlcleanfeatures:
# python specific build rules
#
-PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
+PYMAKE=/usr/bin/python3 setup.py $(PYTHONARGS)
pythonmodules: subdirs
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
if test $$? != 0 ; then \
diff -urNp old/python/netsnmp/tests/test.py new/python/netsnmp/tests/test.py
--- old/python/netsnmp/tests/test.py 2018-02-27 09:13:39.904417605 +0100
+++ new/python/netsnmp/tests/test.py 2018-02-27 10:37:43.488435738 +0100
@@ -8,7 +8,7 @@ import time
class BasicTests(unittest.TestCase):
def testFuncs(self):
- print ""
+ print ("")
var = netsnmp.Varbind('sysDescr.0')
var = netsnmp.Varbind('sysDescr','0')
var = netsnmp.Varbind(
@@ -19,67 +19,67 @@ class BasicTests(unittest.TestCase):
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1','0')
- print "---v1 GET tests -------------------------------------\n"
+ print ("---v1 GET tests -------------------------------------\n")
res = netsnmp.snmpget(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpget result: ", res, "\n"
+ print ("v1 snmpget result: ", res, "\n")
- print "v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print ("v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 GETNEXT tests-------------------------------------\n"
+ print ("---v1 GETNEXT tests-------------------------------------\n")
res = netsnmp.snmpgetnext(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpgetnext result: ", res, "\n"
+ print ("v1 snmpgetnext result: ", res, "\n")
- print "v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print ("v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 SET tests-------------------------------------\n"
+ print ("---v1 SET tests-------------------------------------\n")
var = netsnmp.Varbind('sysLocation','0', 'my new location')
res = netsnmp.snmpset(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpset result: ", res, "\n"
+ print ("v1 snmpset result: ", res, "\n")
- print "v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print ("v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 walk tests-------------------------------------\n"
+ print ("---v1 walk tests-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
- print "v1 varlist walk in: "
+ print ("v1 varlist walk in: ")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
res = netsnmp.snmpwalk(vars,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result: ", res, "\n"
+ print ("v1 snmpwalk result: ", res, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 walk 2-------------------------------------\n"
+ print ("---v1 walk 2-------------------------------------\n")
- print "v1 varbind walk in: "
+ print ("v1 varbind walk in: ")
var = netsnmp.Varbind('system')
res = netsnmp.snmpwalk(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result (should be = orig): ", res, "\n"
+ print ("v1 snmpwalk result (should be = orig): ", res, "\n")
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 multi-varbind test-------------------------------------\n"
+ print ("---v1 multi-varbind test-------------------------------------\n")
sess = netsnmp.Session(Version=1,
DestHost='localhost',
Community='public')
@@ -88,16 +88,16 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v1 sess.get result: ", vals, "\n"
+ print ("v1 sess.get result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
vals = sess.getnext(vars)
- print "v1 sess.getnext result: ", vals, "\n"
+ print ("v1 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -106,28 +106,28 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v1 sess.getbulk result: ", vals, "\n"
+ print ("v1 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 set2-------------------------------------\n"
+ print ("---v1 set2-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my newer location'))
res = sess.set(vars)
- print "v1 sess.set result: ", res, "\n"
+ print ("v1 sess.set result: ", res, "\n")
- print "---v1 walk3-------------------------------------\n"
+ print ("---v1 walk3-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v1 sess.walk result: ", vals, "\n"
+ print ("v1 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v2c get-------------------------------------\n"
+ print ("---v2c get-------------------------------------\n")
sess = netsnmp.Session(Version=2,
DestHost='localhost',
@@ -140,22 +140,22 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v2 sess.get result: ", vals, "\n"
+ print ("v2 sess.get result: ", vals, "\n")
- print "---v2c getnext-------------------------------------\n"
+ print ("---v2c getnext-------------------------------------\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
vals = sess.getnext(vars)
- print "v2 sess.getnext result: ", vals, "\n"
+ print ("v2 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
- print "---v2c getbulk-------------------------------------\n"
+ print ("---v2c getbulk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -164,30 +164,30 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v2 sess.getbulk result: ", vals, "\n"
+ print ("v2 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
- print "---v2c set-------------------------------------\n"
+ print ("---v2c set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0','my even newer location'))
res = sess.set(vars)
- print "v2 sess.set result: ", res, "\n"
+ print ("v2 sess.set result: ", res, "\n")
- print "---v2c walk-------------------------------------\n"
+ print ("---v2c walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v2 sess.walk result: ", vals, "\n"
+ print ("v2 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v3 setup-------------------------------------\n"
+ print ("---v3 setup-------------------------------------\n")
sess = netsnmp.Session(Version=3,
DestHost='localhost',
SecLevel='authPriv',
@@ -200,22 +200,22 @@ class BasicTests(unittest.TestCase):
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
- print "---v3 get-------------------------------------\n"
+ print ("---v3 get-------------------------------------\n")
vals = sess.get(vars)
- print "v3 sess.get result: ", vals, "\n"
+ print ("v3 sess.get result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
- print "---v3 getnext-------------------------------------\n"
+ print ("---v3 getnext-------------------------------------\n")
vals = sess.getnext(vars)
- print "v3 sess.getnext result: ", vals, "\n"
+ print ("v3 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -224,37 +224,37 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v3 sess.getbulk result: ", vals, "\n"
+ print ("v3 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
- print "---v3 set-------------------------------------\n"
+ print ("---v3 set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0', 'my final destination'))
res = sess.set(vars)
- print "v3 sess.set result: ", res, "\n"
+ print ("v3 sess.set result: ", res, "\n")
- print "---v3 walk-------------------------------------\n"
+ print ("---v3 walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v3 sess.walk result: ", vals, "\n"
+ print ("v3 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print (" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
class SetTests(unittest.TestCase):
def testFuncs(self):
- print "\n-------------- SET Test Start ----------------------------\n"
+ print ("\n-------------- SET Test Start ----------------------------\n")
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
+ print ("uptime = ", res[0])
var = netsnmp.Varbind('versionRestartAgent','0', 1)
@@ -264,19 +264,19 @@ class SetTests(unittest.TestCase):
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
+ print ("uptime = ", res[0])
var = netsnmp.Varbind('nsCacheEntry')
res = netsnmp.snmpgetnext(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print ("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')')
var.val = 65
res = netsnmp.snmpset(var, Version = 1, DestHost='localhost',
Community='public')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print ("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')')
sess = netsnmp.Session(Version = 1, DestHost='localhost',
Community='public')
@@ -286,7 +286,7 @@ class SetTests(unittest.TestCase):
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116','', 4))
res = sess.set(vars)
- print "res = ", res
+ print ("res = ", res)
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -295,14 +295,14 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
vars = netsnmp.VarList(netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116','', 6))
res = sess.set(vars)
- print "res = ", res
+ print ("res = ", res)
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -311,10 +311,10 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print (var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print ("\n")
- print "\n-------------- SET Test End ----------------------------\n"
+ print ("\n-------------- SET Test End ----------------------------\n")
if __name__=='__main__':
diff -urNp old/python/setup.py new/python/setup.py
--- old/python/setup.py 2018-02-27 09:13:39.904417605 +0100
+++ new/python/setup.py 2018-02-27 10:03:24.816969453 +0100
@@ -9,9 +9,9 @@ intree=0
args = sys.argv[:]
for arg in args:
- if string.find(arg,'--basedir=') == 0:
- basedir = string.split(arg,'=')[1]
- sys.argv.remove(arg)
+ if arg.find('--basedir=') == 0:
+ basedir = arg.split('=')[1]
+ sys.argv.remove(arg)
intree=1
if intree:

View File

@ -2,14 +2,14 @@
%{!?netsnmp_check: %global netsnmp_check 1}
# allow compilation on Fedora 11 and older
%{!?python2_sitearch: %global python2_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%{!?python3_sitearch: %global python3_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
# Arches on which we need to prevent arch conflicts on net-snmp-config.h
%global multilib_arches %{ix86} ia64 ppc ppc64 s390 s390x x86_64 sparc sparcv9 sparc64 aarch64
Summary: A collection of SNMP protocol tools and libraries
Name: net-snmp
Version: 5.7.3
Release: 34%{?dist}
Release: 35%{?dist}
Epoch: 1
License: BSD
@ -69,6 +69,7 @@ Patch100: net-snmp-5.7.3-openssl.patch
# Modern RPM API means at least EL6
Patch101: net-snmp-5.7.3-modern-rpm-api.patch
Patch102: net-snmp-5.7.3-python3.patch
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: %{name}-agent-libs%{?_isa} = %{epoch}:%{version}-%{release}
@ -81,7 +82,7 @@ BuildRequires: systemd
BuildRequires: openssl-devel, bzip2-devel, elfutils-devel
BuildRequires: libselinux-devel, elfutils-libelf-devel, rpm-devel
BuildRequires: perl-devel, perl(ExtUtils::Embed), procps
BuildRequires: python2-devel, python2-setuptools
BuildRequires: python3-devel, python3-setuptools
BuildRequires: chrpath
BuildRequires: mariadb-connector-c-devel
# for netstat, needed by 'make test'
@ -181,8 +182,8 @@ Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
The net-snmp-agent-libs package contains the runtime agent libraries for shared
binaries and applications.
%package -n python2-net-snmp
%{?python_provide:%python_provide python2-net-snmp}
%package -n python3-net-snmp
%{?python_provide:%python_provide python3-net-snmp}
# Remove before F30
Provides: %{name}-python = %{version}-%{release}
Provides: %{name}-python%{?_isa} = %{version}-%{release}
@ -190,7 +191,7 @@ Obsoletes: %{name}-python < %{version}-%{release}
Summary: The Python 'netsnmp' module for the Net-SNMP
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
%description -n python2-net-snmp
%description -n python3-net-snmp
The 'netsnmp' module provides a full featured, tri-lingual SNMP (SNMPv3,
SNMPv2c, SNMPv1) client API. The 'netsnmp' module internals rely on the
Net-SNMP toolkit library.
@ -226,6 +227,7 @@ cp %{SOURCE10} .
%patch22 -p1 -b .autofs-skip
%patch100 -p1 -b .openssl
%patch101 -p1 -b .modern-rpm-api
%patch102 -p1
%ifarch sparc64 s390 s390x
# disable failing test - see https://bugzilla.redhat.com/show_bug.cgi?id=680697
@ -290,7 +292,7 @@ find perl/blib -type f -name "*.so" -print -exec chrpath --delete {} \;
# compile python module
pushd python
%{__python2} setup.py --basedir="../" build
%{__python3} setup.py --basedir="../" build
popd
@ -352,7 +354,7 @@ install -m 644 local/mib2c.*.conf %{buildroot}%{_datadir}/snmp
# install python module
pushd python
%{__python2} setup.py --basedir=.. install -O1 --skip-build --root %{buildroot}
%{__python3} setup.py --basedir=.. install -O1 --skip-build --root %{buildroot}
popd
find %{buildroot} -name '*.so' | xargs chmod 0755
@ -465,9 +467,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
%{perl_vendorarch}/auto/*SNMP*
%{perl_vendorarch}/auto/Bundle/*SNMP*
%files -n python2-net-snmp
%files -n python3-net-snmp
%doc README
%{python2_sitearch}/*
%{python3_sitearch}/*
%files gui
%{_bindir}/tkmib
@ -491,6 +493,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
%{_libdir}/libnetsnmptrapd*.so.*
%changelog
* Tue Feb 27 2018 Josef Ridky <jridky@redhat.com> - 1:5.7.3-35
- compile against Python3
* Fri Feb 16 2018 Josef Ridky <jridky@redhat.com> - 1:5.7.3-34
- fix wrong systemd patch (#1545946)