openlang

Can extension requirements be constrained...?

I'm wondering whether extension dependencies can be controlled…

Here's a situation I ran into.

There is a package Q with some dependencies. It belongs to that category of packages which define an interface and also supply several different implementations of that same interface. To operate, those implementations need dependencies such as HTTP 1.

I'm now developing package R. It's largely finished, and I want an extension to Q that implements R's interface, we'll name it QRExt. Q has no need for HTTP, so I don't want those dependencies added to Q's dependency list. The extension QRExt itself, however, does have a dependency on HTTP in order to work. Presently that works because Q already depends on HTTP, so loading Q means HTTP is available, letting QRExt import it successfully.

The trouble is that this arrangement is accidental and might change. Q could eventually move its HTTP dependency to 2. QRExt would subsequently import HTTP expecting (1), receive HTTP 2 instead, and break. With the assumption “loading Q makes HTTP available”, the underlying issue is that nothing expressly requires that assumption to keep holding.

Id be interested in ideas for handling this.

The conversation continues 2

Follow the reasoning
  1. Permalink

    I think the weakdep mechanism could provide most of the behavior you're looking for here, although there would still be a few caveats to consider when Q moves to HTTP 2. You'd then have to update R's compat entries so QRExt can resolve the newer Q version using HTTP 2. That seems reasonable to me, and likely the intended outcome?

  2. Permalink

    If Q has no HTTP dependency, instead of writing your

    RQExt (I like naming the extended package first)

    You can write RQHTTPExt

    R can then constrain HTTP's compat in its main project file

Other sides of the same question

  1. Reducing docker-compose console noise

    Several of my containers produce hundreds upon hundreds of output lines when docker-compose up starts all the services in my…

    Replies 3Latest activity bash
  2. Could D produce Python extension modules rather than using C?

    Apparently D can link against C. I want to write a Python extension module using D. Is there a reason this approach could nev…

    Replies 2Latest activity d
  3. Micro plugins declared through Nix?🤔

    With python we can write this: Python.withPackages (q: with q; [ fastapi ]) Is an equivalent mechanism available for the Micr…

    Replies 3Latest activity nix