Specify a chosen default version of conda package through conda-forge / conda-install

524 views Asked by At

I'd like to distribute multiple versions of a package through conda. Specifically, I'd like to do something like this:

...
package-v1.2-dev
package-v1.2
package-v1.1-dev
package-v1.1
package-v1.0

The trick is that I'd like to have the "latest" or default package be the release versions that do not have -dev. As I understand it, conda install <package> without a version number will install the newest build. In my case, that will always be -dev. Is it possible to make the default a specific version number?

1

There are 1 answers

4
Stuart Berg On BEST ANSWER

You can achieve this by specifying a custom "label" for your dev packages. Keep using the default main label for your release packages, but use a non-main label (e.g. dev) for the other packages.

First, a quick note about version numbers: conda package versions must not contain the - character, so v1.2-dev is not a valid version. For the following examples, I'll use v1.2.dev.


Here's how to upload your packages:

anaconda upload mypackage-v1.2.tar.bz2
anaconda upload --label dev mypackage-v1.2.dev.tar.bz2

(You can also manipulate the labels for existing packages via your account on the http://anaconda.org website.)

By default, your users will only download your main packages. Users who want the dev packages will have two choices:

  1. They can specify the dev label on the command-line:

    conda install -c mychannel/label/dev mypackage
    

OR

  1. They can add your dev label to their .condarc config

    # .condarc
    channels:
      - mychannel/label/dev # dev label
      - mychannel           # main label only
      - conda-forge
      - defaults
    

    And then there's no need to specify the channel on the command-line:

    conda install mypackage
    

PS -- Here's a side note about something you wrote above:

As I understand it, conda install <package> without a version number will install the newest build

Just to clarify, it doesn't install the "newest" in chronological sense, but rather the highest compatible version according to conda's VersionOrder logic. That logic is designed to be largely compatible with relevant Python conventions (e.g. PEP440 and others), but with some affordances for compatibility with other languages' conventions, too.

Please note: As far as conda (and PEP440) is concerned, 1.2.dev comes BEFORE 1.2. (Maybe you already knew that, but I don't consider it obvious.)

$ python
>>> from conda.models.version import VersionOrder
>>> VersionOrder('1.2.dev') < VersionOrder('1.2')
True