News for 2024

6 views
Skip to first unread message

Thomas Calmant

unread,
Jan 6, 2024, 12:00:18 PMJan 6
to ipopo...@googlegroups.com, ipop...@googlegroups.com
Dear iPOPO users & devs,

First, let me wish you a happy new year 2024 :)
It's been a while since the last message on this list!
In summary, I moved to a new company that brought me back closer to the OSGi community.

As some of you might have noticed, I'm currently working on a v3 branch on iPOPO.
The goal is to upgrade the project to work with Python 3.10+ and to (finally) benefit from the type hinting feature while coding.
I chose Python 3.10 as the lower bound as it is the version at which iPOPO v1 can no longer be installed with all its dependencies.

The branch currently seems to work for local frameworks, but the Pelix Remote Services and Remote Service Admin packages still need some work due to the upgrade of their dependencies.
My main objectives before the release of 3.0.0 are:
  • to allow code that worked in iPOPO v1 to not require being rewritten to work with iPOPO v3 (except when it comes to changes related to Python itself, obviously),
  • to ensure that a v1 framework can interact seamlessly with a v3 framework via Remote Services.
The features of v1 should be the same as in v3, even though some might take some time to be reimplemented. For example, I had some trouble reimplementing an XMPP shell working in Python 3.10, and I fear it will be the same for some Remote Services/RSA discovery protocols.

Regarding new features, it is now recommended to use a typing.Protocol and an @Specification decorator to describe a service.
ServiceReference is now generic, so that the type of the service returned by BundleContext.get_service(svc_ref) matches the type of ServiceReference.
String specifications are still accepted, in which case you'll obtain a ServiceReference[Any] to work with.

Here is a snippet of what v3 components can look like (v1 syntax is still accepted):

import typing

from pelix.constants import Specification
from pelix.framework import BundleContext
from pelix.ipopo.decorators import (
    ComponentFactory,
    Instantiate,
    Provides,
    Requires,
    Validate,
)


@Specification("hello")
class HelloService(typing.Protocol):
    def hello(self, name: str = "World") -> str:
        ...


@ComponentFactory()
@Provides(HelloService)
@Instantiate("hello")
class HelloProvider(HelloService):
    def hello(self, name: str = "World") -> str:
        return f"Hello {name}!"


@ComponentFactory()
@Requires("_hello", HelloService)
class HelloConsumer:
    _hello: HelloService

    @Validate
    def validate(self, context: BundleContext) -> None:
        print(self._hello.hello())

Note that this allows code completion in type-aware IDEs like VSCode or PyCharm, and it allows you to test your typing with mypy.

What about v2? you might ask.
The project already has a (stalled) v2 branch, which was an intent to make iPOPO asynchronous. I didn't have enough time to work on that feature and it stopped quite early.

Again let me wish you a happy new year

All the best,
Thomas
Reply all
Reply to author
Forward
0 new messages