[packages/python3-pysnmp] Rel 2. Build pysmi parser once (i686 timeout tests); cryptography >= 47.0.0.
arekm
arekm at pld-linux.org
Thu Oct 1 14:45:57 CEST 2026
commit a4afdf58bbda4c8d95696f026f040436315689bc
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 1 14:44:52 2026 +0200
Rel 2. Build pysmi parser once (i686 timeout tests); cryptography >= 47.0.0.
parser-reuse.patch | 37 +++++++++++++++++++++++++++++++++++++
python3-pysnmp.spec | 12 ++++++++----
2 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/python3-pysnmp.spec b/python3-pysnmp.spec
index 63f7b36..4086150 100644
--- a/python3-pysnmp.spec
+++ b/python3-pysnmp.spec
@@ -7,12 +7,13 @@ Summary: SNMP engine for Python
Summary(pl.UTF-8): Obsługa SNMP dla Pythona
Name: python3-%{module}
Version: 7.1.30
-Release: 1
+Release: 2
License: BSD
Group: Libraries/Python
# PyPI sdist lacks tests and examples
Source0: https://github.com/lextudio/pysnmp/archive/v%{version}/%{module}-%{version}.tar.gz
# Source0-md5: 362fa55079441d9160d28a545945192e
+Patch0: parser-reuse.patch
URL: https://www.pysnmp.com/
BuildRequires: python3 >= 1:3.10
BuildRequires: python3-build
@@ -21,7 +22,8 @@ BuildRequires: python3-installer
BuildRequires: python3-modules >= 1:3.10
%if %{with tests}
BuildRequires: mibs-net-snmp
-BuildRequires: python3-cryptography
+# decrepit.ciphers.modes.CFB (AES privacy) appeared in 47.0.0
+BuildRequires: python3-cryptography >= 47.0.0
BuildRequires: python3-pyasn1 >= 0.6.4
BuildRequires: python3-pysmi >= 2.0.0
BuildRequires: python3-pytest >= 7.2.0
@@ -30,8 +32,9 @@ BuildRequires: python3-pytest-asyncio >= 0.21.1
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 2.044
Requires: python3-modules >= 1:3.10
-# DES/3DES/AES privacy for SNMPv3 USM; imported lazily, so not autodetected
-Requires: python3-cryptography
+# DES/3DES/AES privacy for SNMPv3 USM; imported lazily, so not autodetected;
+# decrepit.ciphers.modes.CFB (AES privacy) appeared in 47.0.0
+Requires: python3-cryptography >= 47.0.0
Suggests: python3-pysmi
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -61,6 +64,7 @@ Ten pakiet zawiera przykładowe programy do modułu Pythona pysnmp.
%prep
%setup -q -n %{module}-%{version}
+%patch -P0 -p1
%build
%py3_build_pyproject
diff --git a/parser-reuse.patch b/parser-reuse.patch
new file mode 100644
index 0000000..f296ba4
--- /dev/null
+++ b/parser-reuse.patch
@@ -0,0 +1,37 @@
+pysnmp rebuilds pysmi's LALR tables for every SnmpEngine/SnmpDispatcher
+blowing the 3 s budget of the timeout tests; build the parser once
+
+--- pysnmp-7.1.30.orig/pysnmp/smi/compiler.py 2026-09-28 09:50:20.000000000 +0200
++++ pysnmp-7.1.30/pysnmp/smi/compiler.py 2026-10-01 14:19:20.574415428 +0200
+@@ -4,6 +4,7 @@
+ # Copyright (c) 2005-2020, Ilya Etingof <etingof at gmail.com>
+ # License: https://www.pysnmp.com/pysnmp/license.html
+ #
++import functools
+ import os
+ import sys
+ import warnings
+@@ -46,13 +47,22 @@
+
+ else:
+
++ @functools.cache
++ def _get_parser():
++ """Return the shared SMI parser.
++
++ Building its LALR tables takes a noticeable fraction of a second,
++ and parse() keeps no state, so one instance serves every compiler.
++ """
++ return parserFactory(**smiV1Relaxed)()
++
+ def add_mib_compiler(mibBuilder: MibBuilder, **kwargs):
+ """Add MIB compiler to MIB builder."""
+ if kwargs.get("ifNotAdded") and mibBuilder.get_mib_compiler():
+ return
+
+ compiler = MibCompiler(
+- parserFactory(**smiV1Relaxed)(),
++ _get_parser(),
+ PySnmpCodeGen(),
+ PyFileWriter(kwargs.get("destination") or DEFAULT_DEST),
+ )
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/python3-pysnmp.git/commitdiff/a4afdf58bbda4c8d95696f026f040436315689bc
More information about the pld-cvs-commit
mailing list