Skip to content

Migrating numpy x.x to Conda build 3's pin_run_as_build

Mike Sarahan edited this page Jul 18, 2017 · 1 revision

The x.x syntax began in https://github.com/conda/conda-build/pull/573. The core idea with this syntax was that package builders often need a way to say "pin the runtime dependency to whatever version was present at build time." Compared with the x.x syntax (which conda-build 3 supports fully), conda-build 3 has syntax that generalizes the behavior to all packages, and adds additional configurability.

Given a recipe like this:

package:
  name: abc
  version: 123

requirements:
  build:
    - numpy x.x
  run:
    - numpy x.x

The equivalent recipe using conda-build 3's new syntax will look like this:

package:
  name: abc
  version: 123

requirements:
  build:
    - numpy
  run:
    - {{ pin_compatible('numpy') }}

You may also see recipes that have x.x only in the build requirements. This is functionally equivalent to having it in both build and run. The conda-build 3 syntax to support it is exactly the same as above.

package:
  name: abc
  version: 123

requirements:
  build:
    - numpy x.x
  run:
    - numpy

The customizability that conda-build 3 adds consists of a syntax to specify the exactness of the constraint. For example, the default behavior is to constrain >= the exact version used at build time, and < the next major version. Our code above would thus result in a pin like numpy >=1.11.2,<2. We could tweak that, though:

package:
  name: abc
  version: 123

requirements:
  build:
    - numpy
  run:
    - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x.x') }}

This would now give us a constraint like numpy >=1.11,<1.12. More docs on this are available at https://conda.io/docs/building/variants.html#customizing-compatibility

x.x pins generally should never exist in a "cross capable" recipe (one with a requirements/host section). For those recipes, the pin_compatible jinja2 function is aware of the host section, and should do the right thing.

package:
  name: abc
  version: 123

requirements:
  host:
    - numpy
  run:
    - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x.x') }}
Clone this wiki locally