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

optional dependencies #4982

Merged
merged 5 commits into from
Apr 14, 2017
Merged

Conversation

kalefranz
Copy link
Contributor

@kalefranz kalefranz commented Mar 31, 2017

For the 4.4.0 release, this PR supersedes #4120. It leaves out the package superseding part of #4120.

This feature will allow a package to restrict versions of other packages installed within its environment, while also not forcing those packages to be installed. That is, these are not hard dependency specifications, but the constraints of "optional" dependencies.

We need a keyword here to add to a package's metadata for this feature. The value will be a list of matchspec strings, just as depends is a list of matchspec strings.

Possibilities for this keyword include

  • optional
  • conditional
  • constrained
  • restricted
  • optionally_depends

This PR needs the new MatchSpec object in #4158. The envs PR #4676 will follow this one.

@megies
Copy link
Contributor

megies commented Mar 31, 2017

I like Debian's wording of Recommends. From the list you put up I definitely like optional best, the other options you put up are far less intuitive for me.

👍 for this new feature, this is really much needed. Will there also be a possibility to specify "optional" for $ conda install ...?

@kalefranz
Copy link
Contributor Author

Will there also be a possibility to specify "optional" for $ conda install ...?

There could be I guess, but I don't really understand the use case, or what it would actually do. Could you elaborate on how you'd use it?

Something maybe related that is coming is the ability to specify pinned dependencies within condarc configuration files. The ability is actually in the 4.3.16 release that's in canary right now, but marked as a beta feature. The difference is that, in 4.4, these will be the optional type dependencies that constrain versions only if the package is installed, whereas in 4.3 these pinned specs act as hard dependencies and force the package into the environment.

@megies
Copy link
Contributor

megies commented Mar 31, 2017

Will there also be a possibility to specify "optional" for $ conda install ...?

There could be I guess, but I don't really understand the use case, or what it would actually do. Could you elaborate on how you'd use it?

When setting up a testing environment In CI (appveyor/Travis), we first install our hard dependencies, some of which with fixed versions differing across the build matrix. After that we'd like to try to install some optional dependencies to also cover some tests that can only run with certain packages installed. But we don't want those install commands to alter previously installed package versions, just try to install them if they can fit in the current set of installed packages.

I know, this could and maybe should be done using pinned files but we just didn't get round to set this up properly.. for this you would need to introspect where to put those files in the CI environment (which might change paths over time without notice).

result = {ms.name: ms for ms in (MatchSpec(spec) for spec in self.depends or ())}
result.update({ms.name: ms for ms in (MatchSpec(spec, option=True)
for spec in self.constrains or ())})
return tuple(itervalues(result))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcg1969 This is the only logic I've added to this PR beyond yours, as we discussed today. Is using a dict to dedupe by name the best way to do this here? Do you have other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, rule number one is that you shouldn't de-dupe if you don't have to, because multiple MatchSpecs with the same name has semantic meaning. So let's make sure you're not doing it in other places. Here, we want the constraints to overwrite the depends. In the absence of duplicates in either list, this is the right way to do it. Do we want to allow dupes in conda recipes? I'd say not. So this should be good. Certainly for now...

@sodre
Copy link

sodre commented May 11, 2017

Hi @kalefranz how will this feature be mapped to meta.yaml? I have a PR in conda-forge/staged-recipes#2882 for Airflow 1.8 that could make use of that syntax.

@kalefranz
Copy link
Contributor Author

The conda-build PR for enhancement to meta.yaml is conda/conda-build#2001. Under the requirements section there's now a new run_constrained key available. Value is just a list similar to build and run.

It's merged for conda-build 3, which I think @msarahan has plans to release the rc0 is the coming days. It'll also only be supported for users running conda >=4.4, which is close to being ready to release into canary.

@asmeurer
Copy link
Contributor

asmeurer commented Jul 7, 2017

Will it be possible to make these dependencies install by default with the package and simply prevent conda from disallowing them from being uninstalled?

mrocklin pushed a commit to dask/dask that referenced this pull request Nov 18, 2017
* Document instructions for minmal dask-core install

This pull request's core purpose is to add in instructions for installing dask-core which has less dependency bloat than the default `conda install dask`. A use-case for example is  for developers building docker images that don't want a overly huge image size (see e.g. [here](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#avoid-installing-unnecessary-packages)), or for those who would like to manage the optional dependencies themselves.

Aware of #2336 which removes confusion of two channels (default and conda-forge), but seeing as dask-core downloads overwhelming come from the conda-forge channel (>30k vs < 100 see https://anaconda.org/search?q=dask-core), I thought I'd add back in the instructions for conda-forge, but add in 'recommended' in brackets next to default channel so that new users won't be too confused. Open to recommendations on what's better.

External references:
https://pypi.python.org/pypi/dask
conda/conda#4982 (note new optional dependency functionality from conda 4.4.0 onwards)
conda-forge/dask-feedstock#22

* Retain only link to conda-forge

Remove `conda install -c conda-forge` so as to not add extra confusion, as per #2336. Using KISS philosophy.

* Fix up some more small style and english issues.
@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants