-
Notifications
You must be signed in to change notification settings - Fork 696
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
Make the solver aware of pkg-config constraints #3023
Conversation
Have you tested on Windows? There's a fairly small maximum command line length which, if your command lines are really 10KB large, you are almost definitely going to hit. |
No, unfortunately I don't have access to a Windows machine where I could test this. Nevertheless from reading the docs at I believe the limit you mention is for But using such a long command line is certainly somewhat brittle... I am not sure about the preferred design. I could easily chunk the calls to |
You are right, I misstated the limit. I think this should be fine!. LGTM. (It would be nice if we could get some tests, but pkg-config seems a bit too difficult to actually mock in a useful way.) On January 3, 2016 10:26:35 AM EST, "iñaki García Etxebarria" notifications@github.com wrote:
Sent from my Android device with K-9 Mail. Please excuse my brevity. |
Great, thanks for taking a look!
Indeed it would be nice. I took a look to the testing code in #2873, but I need to spend a bit more time with it to understand how that code works. In any case if you think that the basic approach to modification of the solver in the patch is OK I would be happy to write some tests, trivial as they may end up being (better than nothing at all, I suppose). |
The fact that in some (extremely unlikely, as discussed above, but possible in principle) cases the initial population of the So in the normal case we have the check, but we revert to the previous situation if |
Sweet. Maybe make the error message be a little clearer about what the failure means? (Cabal will continue without solving for pkg-config constraints.) |
Sure, done! I also added some unit tests, and squashed all changes into a single commit, hopefully this makes review a little bit easier. |
8050fe7
to
3b465c5
Compare
There were some merge conflicts against HEAD, so I have rebased the patch. Is there anything else you think I should improve in the patch? I would be happy to do so. |
I think I'll postpone merging this PR until the 1.24 branch is created. The 1.24 release is imminent and I don't want to introduce such large changes. Hope it's okay with you. |
@23Skidoo Sure, that is very reasonable! As long the functionality gets in eventually in some form I am happy :) |
I've not reviewed the code, but in principle this is defiantly a good thing. I'd like to get the solver to take into account more of these things. The big one will be build-tools. |
@23Skidoo Unless the branch really is imminent could you perhaps add a label to the issues which you want to postpone until post-branch? (Just so that I and others don't accidentally merge stuff if we miss one of your comments.) |
@BardurArantsson Sure, will do. |
@23Skidoo Great, thanks! |
I've briefly looked at the part of the PR that actually makes changes to the modular solver, and these look generally ok to me. |
I'm going to just merge this based on the LGTMs, my own (possibly naïve) LGTM and the fact that 1.24 has been branched. |
(Uh, hang on... I can't merge it -- there are conflicts. My bad.) |
34fa6e1
to
3af1c19
Compare
I just rebased, it should merge cleanly now. Thanks for the reviews! |
Mmm, looking to the automatic checks that just ran one of them (appveyor) is failing, apparently due to the fact that it is in running in Windows, so it cannot find Is there a way of having |
-- too long command line). | ||
ioErrorHandler :: IOException -> IO PkgConfigDb | ||
ioErrorHandler e = do | ||
info verbosity ("Failed to query pkg-config, Cabal will continue without solving for pkg-config constraints: " ++ show e) |
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.
Please respect the 80-col line length limit.
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.
Thanks, fixed!
LGTM as well. |
@23Skidoo Thanks! In any case I just updated the patch in the pull request to use This was probably the right thing to do in the first place anyway. It could be a bit annoying to see the message every time if one was interested in using cabal without having pkg-config around, which does make sense. |
When solving, we now discard plans that would involve packages with a pkgconfig-depends constraint which is not satisfiable with the current set of installed packages (as listed by pkg-config --list-all). This fixes haskell#3016. It is possible (in principle, although it should be basically impossible in practice) that "pkg-config --modversion pkg1 pkg2... pkgN" fails to execute for various reasons, in particular because N is too large, so the command line becomes too long for the operating system limits. If this happens, revert to the previous behavior of accepting any install plan, regardless of any pkgconfig-depends constraints.
Yes, I agree that using |
Make the solver aware of pkg-config constraints
Merged, thanks! |
Great, thanks a lot! |
This pull request fixes #3016 (it does not entirely fix #335, but it goes in that direction). As explained in more detail in #3016, having the solver aware of available pkg-config dependencies is important for bindings for recent versions of external APIs.
The implementation is fairly similar to that in #2873, the only noteworthy point is that on startup we scan the list of all installed pkg-config packages in order to obtain their versions. Obtaining the list of installed packages is straightforward (
pkg-config --list-all
), based on this list we then callpkg-config --modversion pkg1 pkg2...
.If there are a lot of packages the commandline can get somewhat long (4-10 KB), but this should not be a problem in modern operating systems. An alternative would be to call
pkg-config --modversion
repeatedly for each package, but from quick testing this makes things much slower (0.02s vs 0.5s in my system).