Skip to content

Pinned pysnmp version is broken in Python 3.12 #1041

@BrianJKoopman

Description

@BrianJKoopman

Since the old version of pysnmp we use uses the old asyncore core Python module, which was removed in favor of asyncio, imports of socs.snmp.SNMPTwister break on 3.12:

==================================== ERRORS ====================================
[9](https://github.com/simonsobs/socs/actions/runs/24265674748/job/70859976443?pr=1040#step:5:20)
_____________ ERROR collecting agents/test_meinberg_m1000_agent.py _____________
ImportError while importing test module '/home/runner/work/socs/socs/tests/agents/test_meinberg_m1000_agent.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
agents/test_meinberg_m1000_agent.py:1: in <module>
    from socs.agents.meinberg_m1000.agent import MeinbergM1000Agent  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../socs/agents/meinberg_m1000/agent.py:11: in <module>
    from socs.snmp import SNMPTwister
../socs/snmp.py:4: in <module>
    from pysnmp.hlapi.twisted import (CommunityData, ContextData, ObjectIdentity,
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/hlapi/__init__.py:10: in <module>
    from pysnmp.hlapi import auth
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/hlapi/auth.py:7: in <module>
    from pysnmp.entity import config
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/entity/config.py:8: in <module>
    from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/udp.py:9: in <module>
    from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/base.py:10: in <module>
    from pysnmp.carrier.asyncore.base import AbstractSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/base.py:9: in <module>
    import asyncore
E   ModuleNotFoundError: No module named 'asyncore'
_______ ERROR collecting integration/test_ibootbar_agent_integration.py ________
ImportError while importing test module '/home/runner/work/socs/socs/tests/integration/test_ibootbar_agent_integration.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
integration/test_ibootbar_agent_integration.py:13: in <module>
    from snmpsim.commands import responder
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/snmpsim/commands/responder.py:21: in <module>
    from pysnmp.carrier.asyncore.dgram import udp
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/udp.py:9: in <module>
    from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/base.py:10: in <module>
    from pysnmp.carrier.asyncore.base import AbstractSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/base.py:9: in <module>
    import asyncore
E   ModuleNotFoundError: No module named 'asyncore'
__________ ERROR collecting integration/test_ups_agent_integration.py __________
ImportError while importing test module '/home/runner/work/socs/socs/tests/integration/test_ups_agent_integration.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
integration/test_ups_agent_integration.py:13: in <module>
    from snmpsim.commands import responder
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/snmpsim/commands/responder.py:21: in <module>
    from pysnmp.carrier.asyncore.dgram import udp
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/udp.py:9: in <module>
    from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/base.py:10: in <module>
    from pysnmp.carrier.asyncore.base import AbstractSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/base.py:9: in <module>
    import asyncore
E   ModuleNotFoundError: No module named 'asyncore'
________________________ ERROR collecting test_snmp.py _________________________
ImportError while importing test module '/home/runner/work/socs/socs/tests/test_snmp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test_snmp.py:1: in <module>
    from socs import snmp  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^
../socs/snmp.py:4: in <module>
    from pysnmp.hlapi.twisted import (CommunityData, ContextData, ObjectIdentity,
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/hlapi/__init__.py:10: in <module>
    from pysnmp.hlapi import auth
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/hlapi/auth.py:7: in <module>
    from pysnmp.entity import config
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/entity/config.py:8: in <module>
    from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/udp.py:9: in <module>
    from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/dgram/base.py:10: in <module>
    from pysnmp.carrier.asyncore.base import AbstractSocketTransport
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/carrier/asyncore/base.py:9: in <module>
    import asyncore
E   ModuleNotFoundError: No module named 'asyncore'
=============================== warnings summary ===============================
../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/vcs_versioning/_backends/_git.py:377
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/vcs_versioning/_backends/_git.py:377: UserWarning: "/home/runner/work/socs/socs" is shallow and may cause errors
    pre_parse(wd)

../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/smi/compiler.py:21
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/smi/compiler.py:21: DeprecationWarning: getReadersFromUrls is deprecated. Please use get_readers_from_urls instead.
    from pysmi.reader.url import getReadersFromUrls

../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/smi/compiler.py:27
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/pysnmp/smi/compiler.py:27: DeprecationWarning: smiV1Relaxed is deprecated. Please use smi_v1_relaxed instead.
    from pysmi.parser.dialect import smiV1Relaxed

../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/tod_ops/t2pleakage.py:7
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/tod_ops/t2pleakage.py:7: DeprecationWarning: `scipy.odr` is deprecated as of version 1.17.0 and will be removed in SciPy 1.19.0. Please use `[https://pypi.org/project/odrpack/`](https://pypi.org/project/odrpack/%60) instead.
    from scipy.odr import ODR, Model, RealData

../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/io/g3thk_db.py:19
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/io/g3thk_db.py:19: MovedIn20Warning: The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    Base = declarative_base()

../../../../../../opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/io/g3tsmurf_db.py:9
  /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/sotodlib/io/g3tsmurf_db.py:9: MovedIn20Warning: The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    Base = declarative_base()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR agents/test_meinberg_m1000_agent.py
ERROR integration/test_ibootbar_agent_integration.py
ERROR integration/test_ups_agent_integration.py
ERROR test_snmp.py
!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!
================= 59 deselected, 6 warnings, 4 errors in 9.75s =================

This pyasyncore package might be a usable holdover, but is a bandaid at best. We should rewrite the SNMP code in socs to use a modern version of pysnmp (which dropped Twisted support a while back).

EDIT: Updating to a modern pysnmp version also means we won't have to pin pyasn1, which has the security vulnerability pointed out in #1014.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions