Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NAV 5.8.0 will not run under Python 3.7 under some systems, due to incompatible ciscoconfparse version #2770

Closed
lunkwill42 opened this issue Nov 29, 2023 · 1 comment · Fixed by #2771
Assignees
Labels

Comments

@lunkwill42
Copy link
Member

Describe the bug

Currently, when installing NAV 5.8.0 under Python 3.7, the napalm==3.4.1 dependency will pull in the ciscoconfparse dependency, with a version number of 1.8.2.

While ciscoconfparse 1.8.2 claims to be compatible with Python 3.7, it is in fact not. Any part of NAV that uses Django will end up pulling in the NAV web urlconfig, which ends up importing napalm, which ends up importing parts of ciscoconfparse that will crash with a SyntaxError.

Most significantly, this means the entire web interface is currently broken under Python 3.7.

The last known good version of ciscoconfparse is the latest 1.7 release, which is was what was available when NAV 5.7 was released.

To Reproduce

Install NAV 5.8 on Debian Buster and try to open the web page. It fails.

A quicker path to demo, withouth involving NAV is:

$ docker run -ti python:3.7 /bin/bash
root@984bc5f248c6:/# pip install ciscoconfparse==1.8.2
Collecting ciscoconfparse==1.8.2
  Downloading ciscoconfparse-1.8.2-py3-none-any.whl (190 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 190.5/190.5 kB 3.3 MB/s eta 0:00:00
Collecting deprecated==1.2.14
  Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)
Collecting passlib<2.0.0,>=1.7.4
  Downloading passlib-1.7.4-py2.py3-none-any.whl (525 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 525.6/525.6 kB 16.3 MB/s eta 0:00:00
Collecting loguru==0.7.2
  Downloading loguru-0.7.2-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.5/62.5 kB 6.1 MB/s eta 0:00:00
Collecting toml>=0.10.2
  Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting dnspython<3.0.0,>=2.3.0
  Downloading dnspython-2.3.0-py3-none-any.whl (283 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 283.7/283.7 kB 25.9 MB/s eta 0:00:00
Collecting wrapt<2,>=1.10
  Downloading wrapt-1.16.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.5/77.5 kB 7.2 MB/s eta 0:00:00
Installing collected packages: passlib, wrapt, toml, loguru, dnspython, deprecated, ciscoconfparse
Successfully installed ciscoconfparse-1.8.2 deprecated-1.2.14 dnspython-2.3.0 loguru-0.7.2 passlib-1.7.4 toml-0.10.2 wrapt-1.16.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
root@984bc5f248c6:/# python -c 'from ciscoconfparse import CiscoConfParse'
raceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/ciscoconfparse/__init__.py", line 29, in <module>
    from ciscoconfparse.ccp_util import PythonOptimizeCheck
  File "<fstring>", line 1
    (arg=)
        ^
SyntaxError: invalid syntax
root@984bc5f248c6:/# 

Expected behavior

While we are planning to drop Python 3.7 compatibility from NAV within the next 6 months, NAV 5.8 needs to remain compatible. Since NAV doesn't explicitly list ciscoconfparse in its own dependencies, it may need to add a list of version constraints for third party packages for pip to comply with.

Tracebacks

Traceback (most recent call last):
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
    response = self.get_response(request)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/base.py", line 130, in get_response
    response = self._middleware_chain(request)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/exception.py", line 49, in inner
    response = response_for_exception(request, exc)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/exception.py", line 152, in handle_uncaught_exception
    callback = resolver.resolve_error_handler(500)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/urls/resolvers.py", line 615, in resolve_error_handler
    callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
    return import_module(self.urlconf_name)
  File "/opt/venvs/nav/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/django/urls.py", line 38, in <module>
    re_path(r'^api/', include(('nav.web.api.urls', 'api'))),
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/opt/venvs/nav/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/api/urls.py", line 20, in <module>
    from nav.web.api.v1 import urls as v1_urls
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/api/v1/urls.py", line 23, in <module>
    from nav.auditlog import api as auditlogapi
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/auditlog/api.py", line 23, in <module>
    from nav.web.api.v1.views import NAVAPIMixin
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/api/v1/views.py", line 53, in <module>
    from nav.web.api.v1 import serializers, alert_serializers
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/api/v1/serializers.py", line 25, in <module>
    from nav.web.seeddb.page.netbox.edit import get_sysname
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/seeddb/page/netbox/edit.py", line 38, in <module>
    from nav import napalm
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/napalm.py", line 21, in <module>
    import napalm
  File "/opt/venvs/nav/lib/python3.7/site-packages/napalm/__init__.py", line 5, in <module>
    from napalm.base import get_network_driver
  File "/opt/venvs/nav/lib/python3.7/site-packages/napalm/base/__init__.py", line 22, in <module>
    from napalm.base.base import NetworkDriver
  File "/opt/venvs/nav/lib/python3.7/site-packages/napalm/base/base.py", line 21, in <module>
    import napalm.base.helpers
  File "/opt/venvs/nav/lib/python3.7/site-packages/napalm/base/helpers.py", line 16, in <module>
    from ciscoconfparse import CiscoConfParse
  File "/opt/venvs/nav/lib/python3.7/site-packages/ciscoconfparse/__init__.py", line 29, in <module>
    from ciscoconfparse.ccp_util import PythonOptimizeCheck
  File "<fstring>", line 1
    (arg=)
        ^
SyntaxError: invalid syntax

Environment (please complete the following information):

  • OS on the NAV server: Debian 10
  • NAV version installed: 5.8.0
  • Python version installed: 3.7.17
@lunkwill42
Copy link
Member Author

Closed by #2771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant