diff --git a/.gitignore b/.gitignore index 0d6b022..428343e 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ docs/_build capnp/lib/capnp.cpp capnp/lib/capnp.h +capnp/lib/capnp_api.h bundled/ example *.iml diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e8d58..e0367e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## v2.0.0b1 (2023-10-03) - Update to bundled capnproto-1.0.1 -- Remove explicit support for Python 3.7 (though wheels are still built for now) +- Remove support for Python 3.7 - Use custom build backend to support build args (#328) - Update Cython version and Python to 3.12 (#320) - Wrap all capnp code in a context-manager to avoid segfaults (#317) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index ff775a2..dbb92b7 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -42,6 +42,7 @@ from types import ModuleType as _ModuleType from operator import attrgetter as _attrgetter from functools import partial as _partial from contextlib import asynccontextmanager as _asynccontextmanager +from importlib.machinery import ModuleSpec _CAPNP_VERSION_MAJOR = capnp.CAPNP_VERSION_MAJOR _CAPNP_VERSION_MINOR = capnp.CAPNP_VERSION_MINOR @@ -2423,7 +2424,7 @@ cdef class _PyAsyncIoStreamProtocol(DummyBaseClass, asyncio.BufferedProtocol): # State for reading data from the transport cdef char* read_buffer - cdef size_t read_min_bytes + cdef int32_t read_min_bytes cdef size_t read_max_bytes cdef size_t read_already_read cdef PromiseFulfiller[size_t]* read_fulfiller @@ -4322,7 +4323,7 @@ class _Importer: self.extension = '.capnp' self.additional_paths = additional_paths - def find_module(self, fullname, package_path=None): + def find_spec(self, fullname, package_path, target=None): if fullname in _sys.modules: # Don't allow re-imports return None @@ -4363,12 +4364,12 @@ class _Importer: path = abspath(path) if is_file(path+sep+capnp_module_name): - return _Loader(fullname, join_path(path, capnp_module_name), self.additional_paths) + return ModuleSpec(fullname, _Loader(fullname, join_path(path, capnp_module_name), self.additional_paths)) if has_underscores: if is_file(path+sep+capnp_module_name_dashes): - return _Loader(fullname, join_path(path, capnp_module_name_dashes), self.additional_paths) + return ModuleSpec(fullname, _Loader(fullname, join_path(path, capnp_module_name_dashes), self.additional_paths)) if is_file(path+sep+capnp_module_name_spaces): - return _Loader(fullname, join_path(path, capnp_module_name_spaces), self.additional_paths) + return ModuleSpec(fullname, _Loader(fullname, join_path(path, capnp_module_name_spaces), self.additional_paths)) _importer = None diff --git a/setup.py b/setup.py index b263a96..31e7781 100644 --- a/setup.py +++ b/setup.py @@ -210,7 +210,7 @@ def run(self): # noqa: C901 ] setup( - python_requires=">=3.7", + python_requires=">=3.8", name="pycapnp", packages=["capnp"], version=VERSION, diff --git a/test/test_load.py b/test/test_load.py index 0fde0c9..34b2830 100644 --- a/test/test_load.py +++ b/test/test_load.py @@ -144,6 +144,7 @@ async def wrapped(self, object, **kwargs): baz_.text = "test" baz_.qux.id = 2 - wrapper = foo.Wrapper._new_client(Wrapper()) - remote = wrapper.wrapped(baz_) - await remote + async with capnp.kj_loop(): + wrapper = foo.Wrapper._new_client(Wrapper()) + remote = wrapper.wrapped(baz_) + await remote