explodinglabs / jsonrpcserver

Process incoming JSON-RPC requests in Python
MIT License
187 stars 40 forks source link

Consider merging request-schema.json into a .py file #166

Open voice-of-texnoforge opened 3 years ago

voice-of-texnoforge commented 3 years ago

Hello,

I've hit a little issue when using jsonrpcserver with PyInstaller:

FileNotFoundError: [Errno 2] No such file or directory: `path-to\\jsonrpcserver\\request-schema.json'

I've submitted a simple hook for PyInstaller which fixes this but I've hit similar issues with python packaging and non-py files many times in the past and I suggest you consider moving the .json data into a .py file unless there's a good reason not to - it can be a new request_schema.py or any of existing files.

This would prevent similar problems with python packaging in various tools without requiring additional effort.

Either way, thanks for the nice library ♥

bcb commented 3 years ago

Yes, good idea. Can’t see any reason not to do this.

st31ny commented 2 months ago

This would also avoid the warning that I get with python 3.12:

.../lib/python3.12/site-packages/jsonrpcserver/__init__.py:19: in <module>
    from .async_main import (
.../lib/python3.12/site-packages/jsonrpcserver/async_main.py:7: in <module>
    from .main import default_validator, default_deserializer
.../lib/python3.12/site-packages/jsonrpcserver/main.py:29: in <module>
    schema = json.loads(importlib.resources.read_text(__package__, "request-schema.json"))
/usr/lib/python3.12/importlib/resources/_legacy.py:25: in wrapper
    return func(*args, **kwargs)
/usr/lib/python3.12/importlib/resources/_legacy.py:79: in read_text
    with open_text(package, resource, encoding, errors) as fp:
/usr/lib/python3.12/importlib/resources/_legacy.py:18: in wrapper
    warnings.warn(
E   DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
bcb commented 2 months ago

Fixed in the version 6