esy-issues icon indicating copy to clipboard operation
esy-issues copied to clipboard

Handle conditionalDependencies

Open andreypopp opened this issue 8 years ago • 5 comments

I propose to add conditionalDependencies (optionalDependencies name is already taken by npm and doesn't have the needed mechanics behind it).

The suggestion is to use the same semantics as for peerDependencies but not fail if those packages mentioned in conditionalDependencies are absent from installation.

If package optdep is listed in conditionalDependencies for the package pkg:

  • optdep is not being installed automatically (same as with peerDependencies) for the pkg
  • Unlike with peerDependencies it is not an error to have no optdep installed at all.
  • If optdep is present in the installation (required by some of packages above) then it's being pulled into pkg's env.

Fixes #46

andreypopp avatar Jan 27 '17 14:01 andreypopp

I propose pulling this in but not documenting, at least for now. It allows much more lightweight builds for common packages which have different backends — like cohttp for example. While we can have it now (if we merge this) we can decide on how we might want to see this as a public API.

andreypopp avatar Jan 27 '17 14:01 andreypopp

Yes, I like your plan @andreypopp - please merge when ready.

jordwalke avatar Jan 31 '17 01:01 jordwalke

Hm... actually found a downside of this approach — in Esy's current form it requires an app which depend on lwt to depend on base-unix and base-thread. This is what lwt gets converted to:

      ...
      "esy": {
        "build": [
          "make setup", 
          "ocaml setup.ml -configure ... --${base_unix_enable:-disable}-unix --${base_threads_enable:-disable}-preemptive", 
          "make build", 
          "make install", 
          "(opam-installer --prefix=$cur__install || true)"
        ], 
      }
      ...

Not sure how to model that in Esy...

andreypopp avatar Jan 31 '17 21:01 andreypopp

We could probably use ocamlfind to query if unix/threads are installed a set env accordingly. That way we don't need base-* packages at all in dep graph.

andreypopp avatar Jan 31 '17 21:01 andreypopp

ready for review, @jordwalke

In this PR we model unix/threads deps dynamically by querying ocamlfind for those libs.

andreypopp avatar Feb 01 '17 16:02 andreypopp