bitkeks / python-netflow-v9-softflowd

PyPI "netflow" package. NetFlow v9 parser, collector and analyzer implemented in Python 3. Developed and tested with softflowd
https://bitkeks.eu/blog/2016/08/collecting-netflow-v9-on-openwrt.html
MIT License
116 stars 59 forks source link

Fails to run on python 3.7 due to lru_cache syntax #27

Closed dahristo closed 4 years ago

dahristo commented 4 years ago

Both pip install 0.10.2 and from git clone fails to run python3 -m netflow.collector on python 3.7 with exception

$ python -m netflow.collector -h Traceback (most recent call last): File "C:\Users\dhristov\AppData\Local\Continuum\anaconda3\envs\py37\lib\runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "C:\Users\dhristov\AppData\Local\Continuum\anaconda3\envs\py37\lib\runpy.py", line 109, in _get_module_details import(pkg_name) File "C:\techno\git\python-netflow-v9-softflowd\netflow__init__.py", line 10, in from .utils import parse_packet File "C:\techno\git\python-netflow-v9-softflowd\netflow\utils.py", line 16, in from .ipfix import IPFIXExportPacket File "C:\techno\git\python-netflow-v9-softflowd\netflow\ipfix.py", line 526, in class IPFIXDataTypes: File "C:\techno\git\python-netflow-v9-softflowd\netflow\ipfix.py", line 559, in IPFIXDataTypes def by_name(cls, key: str) -> Optional[DataType]: File "C:\Users\dhristov\AppData\Local\Continuum\anaconda3\envs\py37\lib\functools.py", line 477, in lru_cache raise TypeError('Expected maxsize to be an integer or None') TypeError: Expected maxsize to be an integer or None

The root cause is lru_cache before 3.8 has to have at least to be "lru_cache()".

Maybe should bump up the dependency to 3.8 from 3.5 in the setup.py

bitkeks commented 4 years ago

Hello @dahristo, thank you for this issue! You are absolutely right that this is a problem with Python before 3.8. The docs on functools in 3.8 make it clear if you know how to differentiate the two variants (user_func or int/None).

Maybe should bump up the dependency to 3.8 from 3.5 in the setup.py

I'm aiming for 3.5+ support, so a parameter fix will be the best (and easiest) option. You should not receive this error in the next release.

bitkeks commented 4 years ago

Thank you very much for the incompatibility hint. Version v0.10.3 is now available on PyPI. It includes multiple fixes for compatibility to Python 3.5.3 and should work for you as well!