Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

A way to build OPAM files without knowing their names #4487

Open
Niols opened this issue Apr 13, 2021 · 4 comments
Open

A way to build OPAM files without knowing their names #4487

Niols opened this issue Apr 13, 2021 · 4 comments

Comments

@Niols
Copy link
Contributor

Niols commented Apr 13, 2021

Hi there,

I hope there is indeed no way to do what I ask for and I hope this makes sense to you! Thank you by advance on the time you'll spend on this.

Wanted Feature

Dune can generate OPAM files which is truly great. It generates one per package defined in the dune-project file. I know two ways to ask Dune to generate these OPAM files: via dune build @install and via dune build whatever.opam. The former also builds a lot of other objects (which is potentially time consuming and might even fail) and the latter requires to know the name of the OPAM file one wants to generate. Could there be a way to generate the OPAM files – and only them – without knowing their names? For instance with a @opam target?

Context & Example Use

My goal is to write a generic CI script able to build a whole project. In particular, this script needs to ensure that the dependencies of the project are installed beforehand. With OPAM files, I would just do opam install . --deps-only. If I want to use only the dune-project, I need a way to generate the OPAM files. Since the dependencies are not installed yet, I cannot simply run dune build@install. And since I want my script to be generic, I cannot expect to know the OPAM file names. I think it would be perfect to have a virtual target that generates all the OPAM files.

Mitigation

I see two ways to do it currently, although I do not find either of them so satisfactory. The first way is to run dune build @install which will take some time and fail but still generate the OPAM files. The second way is to extract the package names from the dune-project with some sed magic.

@rgrinberg
Copy link
Member

Aren't the opam files committed in your project? In which case opam install . --deps-only should work as expected?

@Niols
Copy link
Contributor Author

Niols commented Apr 22, 2022 via email

@rgrinberg
Copy link
Member

dune build @check should already check for that. Of course it also checks other things that you might not want included.

Another option would be to extend dune describe to output the packages in the project and you can then build dune build $package.opam to verify them individually.

@Niols
Copy link
Contributor Author

Niols commented Apr 23, 2022

dune build @check should already check for that. Of course it also checks other things that you might not want included.

dune build @check builds a lot of things and only succeeds if the dependencies are present. I think it pretty much defeats the purpose on CI checking that .opam files and dune-project are in sync because it will fail complaining about missing dependencies instead of lack of sync.

For now, my CI that checks for sync actually calls dune build and ignore its output and potential failure, and then checks if the .opam files changed. As far as I am concerned, it is good enough.

Another option would be to extend dune describe to output the packages in the project and you can then build dune build $package.opam to verify them individually.

It does seem like a nice idea to extend dune describe with more information anyways!

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

No branches or pull requests

3 participants