-
Notifications
You must be signed in to change notification settings - Fork 773
Closed
Description
📝 Note for maintainers: Please triage this issue (review,
classify, and assign appropriate labels).
What is your issue about?
When AUTOBAHN_USE_NVX=0 is set during build time, leaving it unset at runtime does not allow the pure Python fallback for Utf8Validator and create_xor_masker to load:
$ AUTOBAHN_USE_NVX=false pip install -q --no-cache --no-binary=autobahn autobahn
$ python -c 'import autobahn.websocket as w; print(w.HAS_NVX, w.USES_NVX)'
True True
$ python -c 'import autobahn.websocket.utf8validator as u; u.Utf8Validator()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
import autobahn.websocket.utf8validator as u; u.Utf8Validator()
~~~~~~~~~~~~~~~^^
File "/tmp/tmp.NtrSLmGHQz/venv/lib/python3.13/site-packages/autobahn/nvx/_utf8validator.py", line 100, in __init__
from _nvx_utf8validator import lib
ModuleNotFoundError: No module named '_nvx_utf8validator'
$ python -c 'import autobahn.websocket.xormasker as x; x.create_xor_masker(b"\0" * 4)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
import autobahn.websocket.xormasker as x; x.create_xor_masker(b"\0" * 4)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/tmp/tmp.NtrSLmGHQz/venv/lib/python3.13/site-packages/autobahn/nvx/_xormasker.py", line 165, in create_xor_masker
return XorMaskerSimple(mask)
File "/tmp/tmp.NtrSLmGHQz/venv/lib/python3.13/site-packages/autobahn/nvx/_xormasker.py", line 144, in __init__
super().__init__(mask, use_simd=False)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmp.NtrSLmGHQz/venv/lib/python3.13/site-packages/autobahn/nvx/_xormasker.py", line 101, in __init__
from _nvx_xormasker import ffi as _ffi, lib as _lib
ModuleNotFoundError: No module named '_nvx_xormasker'
This seems to be because HAS_NVX is set based on whether the wrapper modules are importable:
autobahn-python/autobahn/websocket/__init__.py
Lines 43 to 53 in b063660
| # Step 1: Probe for NVX availability (was it built and can we import it?) | |
| _has_nvx = False | |
| try: | |
| # Try importing both NVX modules to verify they're available | |
| from autobahn.nvx._xormasker import create_xor_masker as _nvx_xor_test # noqa: F401 | |
| from autobahn.nvx._utf8validator import Utf8Validator as _nvx_utf8_test # noqa: F401 | |
| _has_nvx = True | |
| except ImportError: | |
| # NVX not available (not built or CFFI compilation failed) | |
| pass |
which is not an indicator of whether NVX was built because the actual _nvx_* imports are lazy:
| from _nvx_utf8validator import lib |
autobahn-python/autobahn/nvx/_xormasker.py
Line 101 in b063660
| from _nvx_xormasker import ffi as _ffi, lib as _lib |
Additional context
Triage Notes (for maintainers only)
AI Assistance Disclosure
- I did not use any AI-assistance tools to help create
this issue. - I did use AI-assistance tools to help create this
issue. - I have read, understood and followed the projects'
AI Policy
when creating code, documentation etc. for this pull
request.