pythongitanacondacondaconda-build

How to specify the source (git branch) of a conda build package


I created a conda package that build successfully, and that I can install with conda. I am using versioneer to automatically generate the version number of my builds. My project is in a git repository with multiple branches.

My problem is that when I want to install the package, conda will install the last built version (no matter the branch), whereas I would like that it installs by default the last version of the branch Master. My workaround is to manually specify the version number of the version I want.

Is there a way to generate a version number with versioneer that will make conda install in priority the last built version of the branch master? Alternatively, is there a way to specify conda the branch to get the latest build?

Thanks


Solution

  • Rather than varying the version, I'd suggest looking into encoding the branch info into either the build string or the label/subdirectory. To me, these seem more semantically consistent with the situation.

    Build Variants

    For the former, this could either be done explicitly by defining a build string that includes some jinja-templated variable coordinated with the Git branch, or automatically through variants defined in the conda_build_config.yaml. If you get this working, then installing a build from branch foo would go something like:

    conda install my_package=*=*foo
    

    I don't know a simple example of this, but the Conda Forge blas-feedstock uses a conda_build_config.yaml to define the set of blas_impl options, which is then used to define build strings on the various outputs in meta.yaml.

    Repository Labels

    For the latter, I only know about Anaconda Cloud hosting (which you may not be using). In that case, one adds a label (subdir) with:

    anaconda upload -l foo my_package.tar.gz
    

    If you went this route, then installing a build from a branch foo would go something like:

    conda install channel/foo::my_package
    

    where "channel" is the channel to which you upload.