-
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
Support x.x for all dependencies. #728
Conversation
provide misleading information.
…t does not" This reverts commit e325902.
Really interesting addition. Nice @johanneskoester. I'm personally not a huge fan of the current For me, this would need a good deal more unit tests before I had confidence that the changes are, and continue to, function in the expected way. Great stuff! |
Glad you like it! I don't know if I have the time to implement more tests. Is CA interested in adding tests? I think a lot of packages outside of Bioconda would benefit from this as well. We need this functionality quite urgently in Bioconda. |
I think this is a good thing. Pinging @kalefranz and @csoja for comment on whether CA can fill in on writing tests (if so, on what timescale?) |
This is a reasonable proposal to solve a real problem. Just for discussion, I want to point out an alternative. As pointed out above, there are currently four packages that already support the special
If you've done that, then you can use requirements:
build:
- python >=3.4
run:
- python x.x or, even better (IMHO) you can avoid writing requirements:
build:
- python >=3.4,{{PY_VER}}*
run:
- python {{PY_VER}}* But It's worth mentioning that jinja templates can also be used to achieve our goals here. Taking inspiration from conda/conda#1959, we could define a jinja template with our preferred versions in it, and include it in {% import '$CONDA_DEFAULT_ENV/versions.yaml' as versions %}
package:
name: mypackage
version: 0.1
requirements:
build:
- boost >=1.55,{{versions.boost}}*
run:
- boost {{versions.boost}}* And your {% set python = '3.5' %}
{% set numpy = '1.9' %}
{% set boost = '1.57' %} For huge stacks, the number of versions one might want to pin could get large, so keeping them organized in a file might be more manageable than keeping them on the command-line. They're also readily diff-able. Admittedly, abusing the |
@stuarteberg I like your alternative proposal. For us, it is important to be able to pin to multiple versions. Hence, it would be necessary to build for different versions.yaml. I wasn't aware of the jinja support (is this documented somewhere?). Defining a file with versions and make this flexible without hardcoding to some path in CONDA_DEFAULT_ENV:
In addition we can already pin directly:
Am I right? |
We are about to find general a solution for pinning to ABIs [here](conda/conda-build#728 (comment)).
Good question. I thought it was documented explicitly, but now I can't seem to find it. You can see implicit reference to jinja support in the examples for git environment variables.
Unfortunately, it's not quite that simple. By default, jinja doesn't let you import using absolute paths. Every template you wish to use must be locatable on jinja's search path. We can support absolute paths by adding
Yes, your example will work perfectly, as far as I can tell. Environment variables are loaded directly into the jinja context, so you can simplify your example like so: package:
name: mypackage
version: 0.1
build:
number: 0
string: boost{{BOOST_VER}}_{{PKG_BUILDNUM}}
requirements:
build:
- boost >=1.55,{{BOOST_VER}}*
run:
- boost {{BOOST_VER}}*
(OK, the BTW, If you forget to define
|
Thanks, that sounds good and much more flexible than the x.x approach. |
Is this then something that really needs documentation more than code On Tue, Jan 26, 2016, 01:48 Johannes Köster notifications@github.com
|
I would support that, and I am fine with abandoning my PR in favor of @stuarteberg's proposal. |
We just need to bear in mind that the proposed Jinja approach is not entirely equivalent. Jinja variables are expanded at A proposal for how such a tool might do this inspection would be an interesting use case to consider. |
The suggested change was:
I wonder if we should also add VERSIONS_FILE=/absolute/path/to/versions.jinja conda build mypackage
VERSIONS_FILE=./relative/path/to/versions.jinja conda build mypackage Thinking of jinja templates in general, it occurs to me that we might want the ability to use selectors in the imported templates, too. That is, something like this: {% set python = '3.5' %}
{% set numpy = '1.9' %}
{% set boost = '1.57' %} # [not win]
{% set boost = '1.58' %} # [win] It shouldn't be hard. I think we just need to implement our own 'loader' that is aware of selectors. I think this is all that's needed in class FilteredLoader(jinja2.BaseLoader):
"""
A pass-through for the given loader, except that the loaded source is
filtered according to any metadata selectors in the source text.
"""
def __init__(self, unfiltered_loader):
self._unfiltered_loader = unfiltered_loader
self.list_templates = unfiltered_loader.list_templates
def get_source(self, environment, template):
contents, filename, uptodate = self._unfiltered_loader.get_source(environment, template)
return select_lines(contents, ns_cfg()), filename, uptodate
loaders.append(jinja2.FileSystemLoader('/'))
loaders.append(jinja2.FileSystemLoader(os.getcwd()))
loaders = map(FilteredLoader, loaders) |
This is obviously related to the discussion in #650. For better or worse, I'm bringing the same biases to this discussion. :-) If I were rewriting conda from scratch, I would leave out the In my opinion, jinja templates are explicit and more generalizable without relying on updates to the conda code base when we need to support new packages (or languages) with strange version semantics. But I will readily acknowledge that @pelson's opinion on this may be better informed, from his experience with the conda-forge project. If you'd like to merge this PR, I have no complaints. It does seem carefully written and does not preclude jinja-based approaches for those of us who would prefer that instead. **My complaints about
|
if any(i in v for i in ',|>!<'): | ||
break | ||
res.append(ms.name + v.strip('*')) | ||
|
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.
The build_id()
(and thus the default build string) will now mention any packages that have a specified version
. But in this implementation, the order of the package names in the build string will depend on the order in which they happened to be listed in meta.yaml
. Instead -- just for consistent naming conventions -- should they be sorted before they get added to the build_id
?
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.
IMHO, yes.
I am generally in favor of @stuarteberg's proposal, because I find the readability of things like:
vastly superior to x.x. Regarding @pelson's point about a tool for introspection, could such a tool inspect the template itself, rather than its filled-in content? That seems like an easier target. |
I don't want to speak for @pelson, but here are my thoughts: Yes, such a tool could be written to inspect a recipe according to a given standard. But the problem he faces now is that the jinja and/or environment variable method allows anyone to implement their own conventions for how package versions are injected into I don't think that's a show-stopper. It just means that the developers of "matrix build" tools such as |
cc @ukoethe |
See also conda-forge/conda-forge.github.io#157 where I argue that low level libraries like boost should get a package name change to make the coinstallable. |
@JanSchulz, please consolidate discussion to #966 where I'm trying to consolidate implementation of these ideas. Closing this - but thank you everyone for your contributions to this discussion. |
Motivation
Currently, using x.x to allow pinning of dependencies to externally provided versions works for Python, Perl, R and numpy.
However, the functionality is critical in order to be able to pin dependencies in case of ABI incompatibilities. E.g., this mechanism can be used to build for particular boost versions.
This PR modifies conda-build to support this mechanism for all dependencies.
Changes
--versions boost=1.57
.Outlook
The new implementation could be used as well to handle the previous mechanism that was specific for Python, Perl, R and numpy. However, I left the old code for backwards compatibility.
Johannes Köster on behalf of the Bioconda team.