ocaml / ocaml/dune

Automatically add opam dependencies to dune-project file

Open
#7,449 4 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement package management
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

In a dune project, automatically infer opam dependencies and add them to the dune-project file. This will save users from the drudge work of having to write these dependency lists in two different files since dune can just infer one of them.

Opam dependencies may be inferred by looking at the contents of the (libraries ...) field in dune files. Dune can then add these libraries into the (depends ...) field of the (package ...) stanza of the dune-project file. Ideally, with properly set version bounds, but to start with, it should be acceptable to add only the library names.

How to know which dependencies are opam libraries? Process of elimination. There's a limited set of libraries shipped with the OCaml distribution: str, unix, etc. We can eliminate those as coming from opam. Another set of libraries are defined in the project itself. We can eliminate those. The ones that are left over must then be from opam.

How to decide which (package ...) of the dune-project file to add the library dependencies into? The same way dune knows which library is in which package right now–using the (public_name ...) and (package ...) fields.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how dune currently reads (libraries ...) fields and associates libraries with packages through (public_name ...) and (package ...). Then inspect how dune-project package stanzas represent (depends ...). Done means dependencies are inferred while excluding OCaml-distributed and project-defined libraries, and the appropriate package stanza receives the remaining library names.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.