-
Notifications
You must be signed in to change notification settings - Fork 428
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
Lightened up the requirement on recipes to define numpy x.x as runtime #650
Conversation
@pelson -- I think the only remaining problem with this approach is that the numpy version does not end up pinned in the build. For example, if the build requirement is That is, of course, fixable in this approach. It comes up during the build here: https://github.com/pelson/conda-build/blob/xx_build_dep_remove/conda_build/build.py#L377-L380 Somewhere in In #653 I pulled the check out into a new method of Then in It doesn't matter to me what specific implementation of your approach is used...in other words, you can feel free to grab the code from my PR (or I can do a PR on your PR, changing the |
Aha! Thanks @mwcraig that was the info I needed. Thanks for digging on this. So logically, in my opinion, the behaviour we want is:
means pin the built distribution's runtime dependency to the numpy version that we built against. And:
meaning pick a numpy which satisfies the numpy condition and adheres to the definition of the special This leaves the definition of:
with no meaning, IMHO. Is this making sense, and does this have any flaws (apart from the fact that this (isn't what is exactly implemented in this PR, yet)? @ilanschnell - it would be useful to get your input on this also. Thanks, |
+1 from me. You have my thanks for your efforts on this. |
I think this makes sense, @pelson. I'd be inclined to add a few things:
|
Not at all. Please feel free to submit a PR against my branch, and we can work on this together.
Yes please. Are you happy to do that part as well https://github.com/conda/conda-docs? |
Sure, but won't get to it for a few days... |
Got a PR in for tests, didn't get to this. |
@pelson -- any feelings on how one ought to specify a pinned numpy build with Am thinking adding an option like |
Guys, I'm sorry I'm late to this party, but I guess I don't understand why this PR would be a good thing. The simplest thing would be to just treat
That strikes a nice balance between terse and explicit. Above, @pelson writes:
...I love it!
...I don't love it. This adds "magic" behavior behind the scenes -- for numpy only -- that isn't obvious to the uninitiated. If
I think this proposal is compatible with the existing uses of |
More feedback is definitely better, and good point about not breaking existing recipes. I also see the virtue of requiring explicit over implicit. Question about your suggestion, @stuarteberg: should the specification below raise an error in your proposal?
This currently produces a broken build in the released conda-build. A specification like the one above will not pin the dependency during the build despite advertising in the build_id and the runtime requirements that the version has been pinned. I don't have strong feelings about whether |
Under what I just proposed, no. Buggy recipes like the above may lead to a broken binary. But that's true whether we're talking about
I'm certainly not opposed to having conda raise an error if it sees a recipe like that, but it strikes me as a separate issue from the one in this thread. As I said, I'm know late to this topic, and realize I haven't put as much thought into this as the others in this thread. In particular, I guess I don't see what advantage the |
The
In v1.18.[01] you can make two mistakes:
So in the current released version it is easy to make a mistake by leaving out This PR and #653 are attempts to prevent those mistakes (this is the better option of those two, I think). That said, the more I think about your suggestion I do think numpy will always be treated differently because it has been treated differently than any other python package from the beginning on conda. Wheels have the problem (for packages with extensions that compile against numpy) that there is no way to indicate a wheel has been compiled against particular version of numpy, but conda packages allow that. Which is a long-winded way of saying that I think numpy does need to be treated a little differently than other packages in terms of checking the build/run specifications with each other. |
I can see how giving numpy special treatment makes sense. The concerns we should keep in mind are:
Regarding item (Jeez, I'm a real Debbie Downer, aren't I? I'm not trying to be a pain, just thinking out loud here...) BTW:
FWIW, you can always add additional constraints to a package's requirements by simply adding a new requirement [edit: for a package you already listed]. All the requirements are just bagged up and sent to the solver. So, this actually works:
In some sense, I suppose the "and" operator ( |
Great feedback @stuarteberg - thanks for the comments! I'm also of the opinion that numpy shouldn't be treated specially, I'm just trying to find a route which gets us there without breaking a number of workflows.
The point of my statement was that if you want to specify the magic The only point that I think we have contention on is the build requirement on
So we've got to the point where it is worth talking about removing that numpy special case. In my view the recipe above is clear as day (yet obviously not very sensible), and the proposal I put forwards extends very nicely to being able to define "baked" versions for anything (of course, I'm not proposing that in this PR):
This is cool - I hadn't realised that was possible 👍 |
FYI, this is mostly true, but breaks in one case (will open a separate issue for it because it shouldn't break):
|
@stuarteberg @pelson -- what do you think about a different approach to pinning the numpy version to
Right now we are trying to kludge into an otherwise straightforward list of requirements additional information about how some specific dependencies are to be handled. I think this simplifies dependency handling (numpy is no longer an odd special case) and is more explicit, making recipes easier to read/write. This route could easily be extended to any package with a convention that the environmental variable is expected to be If you think this is worth pursuing I could try to write a PR to implement a couple of days from now. |
(The following is more-or-less a restatement of my earlier opinion. I don't mean to be difficult, and I won't be offended if you guys come to a different conclusion. :-) I think the For a compiled package that uses numpy, I now use this syntax, which already works:
For a pure-python package, I use this:
In the former case, it's clear to the reader that the numpy version is pinned, and that the pinned version came from the environment at build time. (Side note: Since the weird On a related note: According to the conda docs, we can also use jinja templates to make a nicely descriptive build string:
Alas, that doesn't quite work due to two different bugs in |
Sorry for the delay, @stuarteberg -- I had not realized jinja templating already worked in recipes! A couple of questions about the method you are using right now:
I'm coming around to the view that the current I'm not sold on your version yet because it seems really verbose, and suffers from the same ambiguity that Ideally I'd like to not have to think about any of that...I would just list numpy and python requirements like any others. PS The fact that multi-line specifications can be used has turned out to be insanely helpful. It is the only way to express both |
I just did a quick test. It appears that the automagic build string is activated if you define the
In the example I gave, yes, the package requires a specific numpy version at runtime. Adding additional specs merely constrain the requirements even further. Suppose I built my example from above via
Duplicating all the
As I tried to show in my earlier post (compiled package vs. pure-python package), how the numpy spec should be constrained in The following examples are all legitimate requirements for different use-cases involving a numpy dependency: For a package that compiles against numpy, but doesn't use any recently-added functions:
For a package that compiles against numpy, and happens to use functions that were only added in version 1.9:
For a package that uses numpy through the python API (no compilation needed), and furthermore calls numpy functions that were only added recently:
In some cases, you might have the exact same scenario, but for some reason the build script also needs numpy. This might not be common, but is certainly possible.
In fact, it's even theoretically possible (though very unlikely) that some wacky package might require numpy as part of some special build script, but then not actually use numpy at run time:
As far as I can tell, there just isn't any way for conda to guess what your package needs. It is incumbent on the recipe author to understand the package requirements and encode them into |
See poliastro#73 for discussion and conda/conda-build#650 (comment) for inspiration.
This PR has been rail-roaded a little by a pretty lengthy discussion on how a better pinning mechanism might look. I completely agree with aiming for a better solution, but I don't think it needs to hold up this obvious improvement to conda-build. At the end of the day, I suspect In the meantime, @ilanschnell / @kalefranz / other conda-build developers, are you prepared to accept this incremental (non breaking) improvement in how recipe definitions are done, or shall I close the PR? |
+1 as an incremental fix. What's up with the GIT_DESCRIBE_TAG making Travis fail? |
I've assumed that wasn't me, but happy to look into it if you think it is introduced by this PR. |
Fair enough. Sorry for my part in that. BTW, in the intervening time since this PR was written, there have been some changes to |
Thanks @stuarteberg - I hadn't spotted that when I rebased. Diffs are looking much better now 👍 |
@pelson I think this is fine. I'm very sorry it has taken so long to get here. Would you like me to merge it, or hold off until after the build customization discussions tomorrow? I think whatever comes out of that meeting will probably supersede this PR, but this PR has still been conceptually valuable. |
Personally, I think we should hold off until the discussion tomorrow. |
I dusted this PR down. Hopefully CI will go green. |
Closing this to consolidate discussion to #966 where I'm trying to consolidate implementation of these ideas. Thank you everyone for your contributions to this discussion. |
Sorry @pelson just saw your note... Reopening. |
I think the CI is crying wolf - I can't see that the failures are related to this PR, but may be wrong. |
Yes, we have failures elsewhere. I'm well-acquianted. =( This looks good. Thanks @pelson |
Rolls back a little of #573 so that recipes are a little more friendly to write.
Currently one must effectively specify
numpy x.x
as both run and build dependencies in order to build a recipe which has a numpy ABI dependency against anything other than the latest numpy. With this change that is reduced to just specifying that as a runtime dependency.