I’ll present this idea with an example…
Context
todoman
optionally depends on py3-repl
. If the latter is installed, then
todoman
gains a new repl
command which starts an interactive console.
One way of indicating that todoman
optionally depends on py3-repl
is to add
it as an optional dependency. This requires support for optional dependencies in
the package manager and all related tools.
A pitfall of this approach is that there is later no clear indicator that
py3-repl
is installed as an optional dependency for todoman
. If it is marked
as explicitly installed, then there’s no “hint” for me to later remember that I
installed it as an optional dependency. I’ll likely delete it thinking that I
don’t use it directly and nothing depends on it. If it is marked as a installed
as a dependency, then it will removed automatically, since nothing explicitly
depends on it.
A package manager might have a different behaviour: when cleaning up, it can keep around any package that is an optional dependency for another. This would result in many stale unwanted packages being kept around.
Solution
Create a new meta-package: todoman-repl
. This depends on todoman
and
py3-repl
. If I want todoman
with the optional functionality, I simply
install todoman-repl
. The package manager won’t remove py3-repl
, but it also
won’t show up as installed explicitly. In fact, the list of desired packages
reflects my exact intent: “I want todoman with the repl functionality”.
Advantages
This does not require any additional complexity or dedicated features in the package manager or packaging toolchain.
When the package todoman-repl
is installed, it clearly reflects the intent of
the user to install todoman
with its repl
functionality. The repl
dependency is a directly dependency of an explicitly installed package.