Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow package authors to refine constraints for Melange use case #5860

Open
jchavarri opened this issue Feb 28, 2024 · 4 comments
Open

Allow package authors to refine constraints for Melange use case #5860

jchavarri opened this issue Feb 28, 2024 · 4 comments

Comments

@jchavarri
Copy link

It's not possible at the moment for package authors to support Melange optionally, without updating their package opam constraints to match what the melange package requires.

A clear example of this issue can be seen in anuragsoni/routes#151, where the addition of Melange involved raising the lower boundary of ocaml to 4.14, a constraint that the author was not willing to impose on the package users (understandably).

My suggestion is the addition of a new variable with-melange, that users can optionally use running opam install. This would allow package authors more flexibility to define constraints to accommodate both use cases:

  • only OCaml
  • or OCaml and Melange

For example, in the routes example above, one could define a constraint like:

"ocaml" {>= "4.8.0" | >= "4.14.1" & with-melange}

I think a new variable would solve the issue, but maybe there are other alternatives that are less intrusive? Thank you!

@jchavarri
Copy link
Author

I was talking with @anmonteiro about this, and it seems we can achieve a similar result using deopts and melange:installed.

The package author (like routes in the example above) would define melange as optional dependency:

depopts: [
  "melange"
]

Then, update the constraints using melange:installed:

"ocaml" {>= "4.8.0" | = "4.14.1" & melange:installed}

I suspect that for more complex packages, the with-melange option would make things easier, because instead of having to manually install all the packages in depopts, one could just use opam install . --with-melange. But I'm not sure if this would be such a great advantage to justify the costs of the newly added variable.

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Feb 28, 2024

In the medium/long term we are hoping to be able to integrate a more general package variable concept.

In the meantime I think depopts is the way to go. The same thing is done for the compiler (the ocaml-option-* packages) to get some sort of makeshift USE flag but I'm personally hoping to get a proper implementation of that concept once we finally have some time to move forward (as we're currently blocked on the 2.2 release)

@kit-ty-kate
Copy link
Member

Then, update the constraints using melange:installed:

we had a quick chat about it at the dev meeting yesterday and we were wondering why the use of >= "4.14.1" & melange:installed was necessary. Isn't the constraint already brought up by melange?

@jchavarri
Copy link
Author

You are right. You mean that just by adding melange to depopts, all the constraints defined in melange would apply, right? And in the example above, the ocaml constraint could remain as:

"ocaml" {>= "4.8.0"}

I suspect that for more complex packages, the with-melange option would make things easier, because instead of having to manually install all the packages in depopts, one could just use opam install . --with-melange.

I think that point made above would still stand though? Afaiu, using depopts means that the user has to proceed to install all the packages listed in that field manually, which could scale badly when the list goes to close to real-world numbers like 10+ Melange deps. I understand this problem would go away once the package variable concept work is implemented? (very exciting!)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants