opam support for third-party tools tracking per-package data? #7112
Replies: 5 comments 13 replies
|
The problem is that you have now made ocaml package documentation a property of the |
Thanks for pointing it out. I would've seen it but sadly the experience for remote viewers was rather frustrating so i skipped the last talk.
yes, this is
In theory you could do that by adding files to the However taking a step back, i concur with @dbuenzli. It might be too much of special-case idea because you'd need a fallback non-opam-garbage-collected local database anyway, so at this point why not do that without the opam special case and improve the side database approach in the first place (e.g. by garbage collecting packages that are not available anymore whenever |
|
I get the point that assuming (For example: maybe |
|
Thanks for starting this discussion, @gasche! I want to preface this by saying that I think it's really important to figure out the best way to do this, and there's a good chance that we can come up with a better solution than I've proposed in the talk. Having said that, I'm not sure that what's being discussed here will help. Firstly, it's not so much the package manager logic that we have to reimplement, but the build system. Finding the package dependencies is a fair bit simpler than the 'within package' dependencies. The compiler itself is quite a good example - figuring out which module is in which 'compiler-libs' library and then getting the dependencies right is really tricky - For example, The important thing I want is to have a reliable shared source of odoc files for the installed libraries. Today, every tool maintains its own cache of these - odig, dune, odoc_driver, odd_driver - and each one has to rediscover the rules to build them. I think extending the build system that's already building the libraries to also do to the docs is the most reliable way to do this. I quite like @kit-ty-kate 's nod to Debian's I'd prefer to have search indices installed too, as the alternative would have to be to do the indexing on the first attempt to search after each opam install/upgrade. This can be done either by the package itself or by a post-install hook in opam (a bit like how [odd](https://tangled.org/jon.recoil.org/odd) already works). @dbuenzli suggested installing the odoc files next to the cmis, which I think is an excellent idea that I've happily adopted, as this makes the include flags for odoc identical to standard compilation. The downside is that it leads to the bootstrap problem if opam restricts installing to 'package owned' directories. Possible solutions I can think of would be getting odoc installed in the same package as the ocaml compiler - which could be done either by putting odoc into ocaml/ocaml (https://github.com/jonludlam/ocaml/tree/add-odoc for proof of concept), or making the ocaml-compiler package do more than just build ocaml/ocaml. Does anyone else have any suggestions? |
On this front, I was hopeful that we might be able to get rid of the But yes, in principle, I'm very much in favour of considering this question together, and trying to avoid duplicating quite so much information across all these files. |
Uh oh!
There was an error while loading. Please reload this page.
In his talk at the OCaml Workshop 2026, @jonludlam argued that packages should install their odoc-generated intermediate files by default, to simplify building the odoc documentation (which cross-references the documentation of other libraries the package depends on). Systematically installing the
.odocfiles on each package takes space (and a bit of install time), but it avoids forcingodocto duplicate package-manager logic to (1) locate the dependencies of the package and (2) figuring out how/where to store the documentation files. (In particular, only the package's install script is allowed to write in the install directory of the package, so we cannot easily populate the.odocfiles on-demand after installation.)I had a discussion with @Octachron to understand whether other tools could be improved to make this systematic installation un-necessary (according to my (limited) understanding of the needs here). Our non-expert conclusion is that it would suffice for
opamto provide the two following support features:The ability to ask
opam, for a package installed in the current switch, how it satisfied its dependency requirements: which dependencies it installed, at which version. (Maybe this is already available?):"opam, please show me the actual dependencies you installed for
<name>in this switch"The ability to use
opamas a key-value store to store metadata for packages installed in the current switch. A package<name>.<version>has metadata keys that can be set and read by arbitrary tools (and anyone can set them, unlike the install files that can only be populated by the package).odocfor the package<name>.<version>?"odocfor<name>.<version>the string'~/.opam/5.5.0/share/odoc/<name>/<name>.odoc'"Say you ask
odocfor the documentation ofcontainers, it would look at whether thecontainers.<version>package in the current switch already has metadata attached to theodockey:.odocfiles, stored somewhere in a directory odoc controls);opamto find the exact dependencies installed in the switch, recursively finds their.odocfiles, builds the documentation forcontainers.<version>, and stores build an.odocfile for containers, stores it somewhere, and sets theodockey for thecontainers.<version>package.Our hope is that this would allow
odocto build (and store) documentation for arbitraryopampackages of the current switch on-demand. When a package is removed, the corresponding metadata is also removed. In particular, after package updates, theodocmetadata will be rebuilt (on-demand on the next request for documentation). (In contrast, without those metadata for each<name>.<version>package -- if odoc simply stored the doc inshare/odoc/<name>and looked it up there -- there would be no easy way to tell that there is a version mismatch after an opam update.)I have the impression that this approach would let
odoctrack per-installed-package data without coupling with the build-system or package-management layers -- and this approach extends to other tools (Merlin indices, etc.). It supports on-demand construction of per-package information (reducing worries about disk usage impact), and avoids the "bootstrapping" problem mentioned in Jon's talk: if each package builds and installs its documentation, how can the dependencies ofodocdo it if the tool is not yet installed?All reactions