lmstudio-ai / venvstacks

Virtual environment stacks for Python
https://lmstudio-ai.github.io/venvstacks/
MIT License
1 stars 0 forks source link

Allow framework layers to form a directed acyclic graph #18

Open ncoghlan opened 3 weeks ago

ncoghlan commented 3 weeks ago

The current venvstacks model has exactly three layers:

It would be feasible to make the "depending on framework layers" feature a shared characteristic of both the framework and application layers, rather than restricting it to the application layer.

We would need to define a linearisation algorithm for translating the graph of framework nodes in the declared layer dependencies into a predictable sys.path order in the application layers.

My initial instinct is that it should be sufficient to make that a breadth-first traversal for frameworks (i.e. all first-order framework deps in declared left-to-right order, than second order deps, etc), with the runtime folders always forced to the end regardless of how shallow or deep the framework chains are. However, rather than trying to assure ourselves that the simplistic approach is sufficient, it may be better to instead use a well-defined and studied linearisation algorithm like the C3 algorithm that Python uses to resolve class method resolution orders: https://en.wikipedia.org/wiki/C3_linearization