matrix-org / matrix-org/matrix-python-sdk
Add canonicaljson to runtime dependencies
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 266
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
The module crypto/olm_device.py imports the canonicaljson packages which is not listed in the projects runtime dependencies. When creating a MatrixClient object with encryption=True but missing installation of canonicaljson the resulting ImportError is caught. The further handling of this Error makes it look like python-olm package is not installed.
To Reproduce
Steps to reproduce the behavior, with python-olm installed but missing canonicaljson:
- Create a MatrixClient object with encryption enabled:
from matrix_client.client import MatrixClient
client = MatrixClient("http://localhost:8008", encryption=True)
Expected behavior
These two lines should result in the creation of a MatrixClient object.
Desktop (please complete the following information):
- OS: Debian 11
- Version: Python 3.8.8, matrix-client 0.4.0
Additional context
This can be fixed by adding 'canonicaljson' to the list started in line 47 in setup.py. Even if the additional packages is only used when encryption is enabled, installing it always seems to be the preferable option, especially because the import error is masked.
I'd be willing to create a PR to fix this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the dependency list around line 47 of setup.py and inspect the import in crypto/olm_device.py. Reproduce MatrixClient creation with encryption enabled and canonicaljson absent, then verify that declaring canonicaljson as a runtime dependency allows the documented example to create a client without the misleading ImportError handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100