crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.47k stars 763 forks source link

Allow tests to pass without XBR dependencies #1579

Closed yan12125 closed 2 years ago

yan12125 commented 2 years ago

For version 22.5.1, tests fail if XBR dependencies are not installed:

Test failures ``` $ USE_TWISTED=1 PYTHONPATH=.:build/lib.linux-x86_64-3.10 trial autobahn (...omitted...) =============================================================================== [ERROR] Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/twisted/trial/runner.py", line 598, in loadPackage module = modinfo.load() File "/usr/lib/python3.10/site-packages/twisted/python/modules.py", line 390, in load return self.pathEntry.pythonPath.moduleLoader(self.name) File "/usr/lib/python3.10/site-packages/twisted/python/reflect.py", line 298, in namedAny topLevelPackage = _importAndCheckStack(trialname) File "/usr/lib/python3.10/site-packages/twisted/python/reflect.py", line 245, in _importAndCheckStack raise excValue.with_traceback(excTraceback) File "/build/python-autobahn/src/autobahn-22.5.1/autobahn/xbr/test/test_xbr_frealm.py", line 13, in from autobahn.xbr._secmod import SecurityModuleMemory, EthereumKey File "/build/python-autobahn/src/autobahn-22.5.1/autobahn/xbr/_secmod.py", line 35, in from eth_account.account import Account builtins.ModuleNotFoundError: No module named 'eth_account' autobahn.xbr.test.test_xbr_frealm =============================================================================== [ERROR] Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/twisted/trial/runner.py", line 598, in loadPackage module = modinfo.load() File "/usr/lib/python3.10/site-packages/twisted/python/modules.py", line 390, in load return self.pathEntry.pythonPath.moduleLoader(self.name) File "/usr/lib/python3.10/site-packages/twisted/python/reflect.py", line 298, in namedAny topLevelPackage = _importAndCheckStack(trialname) File "/usr/lib/python3.10/site-packages/twisted/python/reflect.py", line 245, in _importAndCheckStack raise excValue.with_traceback(excTraceback) File "/build/python-autobahn/src/autobahn-22.5.1/autobahn/xbr/test/test_xbr_secmod.py", line 37, in from py_eth_sig_utils.eip712 import encode_typed_data builtins.ModuleNotFoundError: No module named 'py_eth_sig_utils' autobahn.xbr.test.test_xbr_secmod ------------------------------------------------------------------------------- ```

Could you consider allowing tests to pass without XBR dependencies? For example, some other tests under autobahn/xbr first do from autobahn.xbr import HAS_XBR, and then import other XBR dependencies only when HAS_XBR is True. Relevant tests are also skipped if HAS_XBR is False.

I'm one of maintainers of official Arch Linux package python-autobahn. Maintaining XBR dependencies is a burden, so no related dependencies are picked into official repositories yet. I didn't use AUTOBAHN_STRIP_XBR introduced in #1371, so that users can still use autobahn.xbr if they installed necessary dependencies from unofficial packages.

oberstet commented 2 years ago

yeah, the XBR dependencies can be painful, this is because Ethereum is a complete new world, everything is moving quite fast, and is hashed out on the fly;) It's just the early phase of ground breaking new tech - unavoidable pain during birth.

rgd the issue: if someone comes up with a PR, sure! otherwise, just package without testing.

oberstet commented 2 years ago

one more hint rgd this XBR stuff: this is very new and experimental, but I'd expect it to become more important to Autobahn/WAMP users looking forward (it is not relevant for users of only the WebSocket stuff in Autobahn). eg it will allow to create WAMP realms shared between and hosted by multiple parties, and also to define and share WAMP API definitions ...

yan12125 commented 2 years ago

if someone comes up with a PR, sure! otherwise, just package without testing.

Sometimes Arch Linux comes with newer dependencies or newer Python versions. Usually we enable tests to ensure compatibility. I will try to make a PR to skip tests.

I'd expect it to become more important to Autobahn/WAMP

Sounds interesting. The program I use (buildbot) does use WAMP. I will check XBR dependencies again at that time. Hopefully packages for XBR dependencies will be easier to maintain then :)

oberstet commented 2 years ago

Hopefully packages for XBR dependencies will be easier to maintain then :)

working on it;)

BB: +1 !! great project and people=)

To give a bit more preview, one thing that BB might indeed be interested in: formalizing their WAMP based BB APIs by writing schemas (in FlatBuffers IDL), and then profit by docs / code generation, payload validation and (future) run-time interface reflection Bildschirmfoto von 2022-05-31 20-30-21 Bildschirmfoto von 2022-05-31 20-30-35 Bildschirmfoto von 2022-05-31 20-31-56

the last screenshot is my ugly demo of auto rendering docs from WAMP APIs ... works via Jinja2 templates and a LMDB schema store, and with Crossbar.io as router (https://github.com/crossbario/crossbar-examples/blob/c67e99777ab7eb12cacab34957a245ce01d28cef/payload-validation/static/.crossbar/config.json#L105)

anyways, it is under development, not yet ready for prime time;)

yan12125 commented 2 years ago

Cool! While I'm more a buildbot user than a dev, I believe buildbot devs will be interested in those nice improvements as well :)