-
Notifications
You must be signed in to change notification settings - Fork 28
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
Allow marking certain packages as "installed via OPAM" #234
Allow marking certain packages as "installed via OPAM" #234
Conversation
So, I haven't looked at the code yet but there are a few things to clarify here. The first is that to work well with opam, the variable should be used to mark the packages to pull, not the ones to opam install. The second is that we need to think carefuly about the solving step. Including the opam deps there will give a consistent result as you'll know everything can be co-installed but it then requires us to properly filter out any transitive deps that have leaked in the solution. I think a good goal here is to go for the minimum viable. The minimum is that the opam deps and duniverse can be built in the same switch, i.e. they are compatible ocaml and dune-wise. I think we should proceed as follow:
At this point we can run the solver again with the fixed ocaml and dune from the above solution to get a solution for the opam install packages and merge it with the other solution so that everything that matters is locked there and one can just use the lockfile for all their dependency needs. The result of this merge might not always work for several reasons. We should probably stick to adding the opam install packages (not their deps) with the I don't think there's an easy answer here so let's think in terms of workflow. What I'd like to advocate is the following:
Another option is to completely skip the second solver run and just re-inject the deps from the source opam files. It might make for a better first iteration by the way. One last thing to note is that the lockfile should always contain the variables to mark the ones that opam should install or not. It's probably worth doing this fist in a separate PR by the way as this will enable the above workflow! |
fa0279a
to
b7c5b05
Compare
@NathanReb I'm currently resolving everything marked as opam-provided with the solver and removing it from the set of dependencies. There might be cases where it would resolve differently than with a larger set but this seems to me to be also true if I were to manually go down the formulas as well, creating another kind of solver. This seemed to be a convenient setup but if there's any concerns I am happy to change the code. |
0e3444b
to
16fa874
Compare
This is starting to look great! I've done a bit of testing on the latest version and I identified a couple things:
|
One thing I just thought about: the opam-provided packages shouldn't be required to build with dune, we need to patch the solver so it knows to do that! |
This is strictly a refactoring and a small one but it was necessary for the work I am currently doing on reproducible `lock` and thought it might also be of use for #234! This should make rebasing either of these features easier along with reducing the size of the PRs so it seemed worthwile to extract it to its own PR. Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
|
8c7e7f7
to
3eeea74
Compare
3eeea74
to
a0eecef
Compare
I've added a number of tests:
|
ff79829
to
4fbf613
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to finally have tests for this!
I think another good thing to test is the dependency collision thing, e.g. both the target package and an opam provided package depend on a same third one, whatever behaviour we choose there.
I have a few comments on the code but it's looking good!
4fbf613
to
087b697
Compare
@TheLortex Can you take another look? There was indeed an error and I ended up just adding debug/info prints in relevant places to be able to see why a package is classified as either (so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! This is long overdue!
I'm still having issues using the feature. See this opam file:
Opam-monorepo crashes with the following error:
|
Ah yeah I think I see where it's coming from, should be easy to fix! @Leonidas-from-XIV probably the constraints that aren't dedup in the second run! |
The compiler constraint should be applied after the other constraints but, it is possible that the set of constraints already contains the compiler (because a previous run already determined the compiler). In such case, the compiler constraint should be added successfully but only if it exactly matches what the previous constraint already determined. This fixes an issue where specifying the compiler on the command line would lead to the constraint being applied twice and failing on the second time because it was already in place. It is being cautious to make sure not to overwrite the previously picked ocaml compiler with a different constraint, so if there is something unexpected going on it will still throw an error instead of silencing it and continuing.
3aadbbd
to
18f7434
Compare
@TheLortex Thanks for the testing, I appreciate it. I tried with your example first and it didn't work because the solver picked 4.14 which is not compatible with We did indeed have an issue there, because in certain cases we inject the compiler constraint from the command line twice, but the code was written in a way where this would crash. I made sure for it to work as long as the constraint is unchanged. @NathanReb I added a small regression test into the cram test (that fails with the exact error @TheLortex describes) so this should not happen in the future. It is a bit more code than absolutely necessary because I wanted to make sure the constraint is equal to the constraint that already exists - otherwise there would be some tricky solver problem that we should not just ignore. |
...impatiently waiting for this to be merged and released... thanks for all your hard work on it :) |
@hannesm it should get in today. We will also focus on the |
Thanks again, for the work on this, and for merging it. I'm wondering @NathanReb 8 days ago wrote "release in the next few days", is there still a release planned, or have there been show stoppers encountered? Thanks for you time. |
@hannesm Yes, we are planning a 0.3.0 release soon. There is a milestone with the missing things for 0.3.0, the only potential show stopper is about the opam |
CHANGES: ### Added - Add opam extensions `x-opam-monorepo-opam-repositories` and `x-opam-monorepo-global-opam-vars` to make `lock` fully reproducible. (tarides/opam-monorepo#250, tarides/opam-monorepo#253, @NathanReb) - Show an error message when the solver can't find any version that satisfies the requested version constraint in the user's OPAM file (tarides/opam-monorepo#215, tarides/opam-monorepo#248, @Leonidas-from-XIV) - Allow packages to be marked as being provided by Opam and not to be pulled by `opam-monorepo`. To control this a new optional Opam file field, `x-opam-monorepo-opam-provided` is introduced. Its value is a list of package names that are to be excluded from being pulled (tarides/opam-monorepo#234, @Leonidas-from-XIV) - Show an error message when the OCaml version of the lock file does not match the OCaml version of the switch (tarides/opam-monorepo#267, tarides/opam-monorepo#268, @Leonidas-from-XIV) - Generate a `duniverse/README.md` file to explain the basics of `opam-monorepo` in the vendored directory (tarides/opam-monorepo#272, tarides/opam-monorepo#274, @Leonidas-from-XIV) - Add a `--prefer-cross-compile` flag for the solver to select cross-compiling versions of packages when available. This is determined through the presence of the `"cross-compile"` tag in the opam metadata. ### Changed - Bump lockfile version to 0.3 (tarides/opam-monorepo#285, @NathanReb) - Mark packages to be pulled by opam-monorepo with the `vendor` variable so using OPAM with `opam install --deps-only --locked .` will not install packages that will be installed with `opam-monorepo pull` (tarides/opam-monorepo#237, @Leonidas-from-XIV) ### Deprecated ### Fixed - Fix a bug where a package which had a single version that built with dune and got selected by the solver would be reported has having no version building with dune. (tarides/opam-monorepo#245, @Leonidas-from-XIV) - Fix the solver so it does not select beta versions of the compiler unless forced to by version constraints or `--ocaml-version`. (tarides/opam-monorepo#269, @NathanReb) ### Removed - Drop support for lockfile versions 0.2 and lower (tarides/opam-monorepo#285, @NathanReb) ### Security
CHANGES: ### Added - Add opam extensions `x-opam-monorepo-opam-repositories` and `x-opam-monorepo-global-opam-vars` to make `lock` fully reproducible. (tarides/opam-monorepo#250, tarides/opam-monorepo#253, @NathanReb) - Show an error message when the solver can't find any version that satisfies the requested version constraint in the user's OPAM file (tarides/opam-monorepo#215, tarides/opam-monorepo#248, tarides/opam-monorepo#290 @Leonidas-from-XIV) - Allow packages to be marked as being provided by Opam and not to be pulled by `opam-monorepo`. To control this a new optional Opam file field, `x-opam-monorepo-opam-provided` is introduced. Its value is a list of package names that are to be excluded from being pulled (tarides/opam-monorepo#234, @Leonidas-from-XIV) - Show an error message when the OCaml version of the lock file does not match the OCaml version of the switch (tarides/opam-monorepo#267, tarides/opam-monorepo#268, @Leonidas-from-XIV) - Generate a `duniverse/README.md` file to explain the basics of `opam-monorepo` in the vendored directory (tarides/opam-monorepo#272, tarides/opam-monorepo#274, @Leonidas-from-XIV) - Add a `--prefer-cross-compile` flag for the solver to select cross-compiling versions of packages when available. This is determined through the presence of the `"cross-compile"` tag in the opam metadata. ### Changed - Bump lockfile version to 0.3 (tarides/opam-monorepo#285, @NathanReb) - Mark packages to be pulled by opam-monorepo with the `vendor` variable so using OPAM with `opam install --deps-only --locked .` will not install packages that will be installed with `opam-monorepo pull` (tarides/opam-monorepo#237, @Leonidas-from-XIV) ### Fixed - Fix a bug where a package which had a single version that built with dune and got selected by the solver would be reported has having no version building with dune. (tarides/opam-monorepo#245, @Leonidas-from-XIV) - Fix the solver so it does not select beta versions of the compiler unless forced to by version constraints or `--ocaml-version`. (tarides/opam-monorepo#269, @NathanReb) ### Removed - Drop support for lockfile versions 0.2 and lower (tarides/opam-monorepo#285, @NathanReb)
This is a draft PR on the hybrid mode feature, which makes it possible to actually test things and go somewhere from there.
opam
can't be marked as not-installable in the solver because in such case there is no solution. I explored this avenue and it doesn't lead anywhere. At least one part of the solution space eliminated ✔️opam-provided
, our custom variable. Not great.opam-provided
packages. That's the easiest part so I'm leaving it for last, once we have figured out the other problems just collecting packages to install should be simple.(No changelog entry because it shouldn't be merged and also for a decent changelog entry I'd want to have the functionality in place so I know what to describe)
But what works is:
opam-provided
in theopam
/dune-project
file, e.g.bos
like in this PRopam-monorepo lock
bos
and its dependencies likefpath
,rresult
and friends aren't part of the lockfile anymore, so they wouldn't be pulled anymore.