Distributing Packages via conda

conda is an open-source package manager very popular in the Python ecosystem that can be used as an alternative to pip. It is especially helpful when distributing packages that rely on compiled libraries (e.g. when you need to use some C code to achieve performance improvements) and uses Anaconda as its standard repository (the PyPI equivalent in the conda world).

The process of creating conda packages consists basically in creating some extra files that describe general recipe to build your project in different operating systems. These recipe files can in theory coexist within the same repository as generated by PyScaffold.

While this approach is completely fine and works well, a package uploaded by a regular user to Anaconda will not be available if someone simply try to install it via conda install <pkg name>. This happens because Anaconda and conda are organised in terms of channels and regular users cannot upload packages to the default channel. Instead, separated personal channels need to be used for the upload and explicitly selected with the -c <channel name> option in conda install.

It is important however to consider that mixing many channels together might create clashes in dependencies (although conda tries very hard to avoid clashes by using channel preference ordering and a clever resolution algorithm).

A general practice that emerged in the conda ecosystem is to organise packages in large communities that share a single and open repository in Anaconda, that rely on specific procedures and heavy continuous integration for publishing cohesive packages. These procedures, however, might involve creating a second repository (separated from the main code base) to just host the recipe files. For that reason, PyScaffold does not currently generate conda recipe files when creating new projects.

Instead, if you are an open-source developer and are interested in distributing packages via conda, our recommendation is to try publishing your package on conda-forge (unless you want to target a specific community such as bioconda). conda-forge is one of the largest channels in Anaconda and works as the central hub for the Python developers in the conda ecosystem.

Once you have your package published to PyPI using the project generated by PyScaffold, you can create a conda-forge feedstock 1 using a special tool called grayskull and following the instructions. Please make sure to check PyScaffold community tips in discussion #422.

If you still need to use a personal custom channel in Anaconda, please checkout conda-build tutorials for further information.

Tip

It is not strictly necessary to publish your package to Anaconda for your users to be able to install it if they are using condapip install can still be used from a conda environment. However, if you have dependencies that are also published in Anaconda and are not pure Python projects (e.g. numpy or matplotlib), or that rely on virtual environments, it is generally advisable to do so.

1

feedstock is the term used by conda-forge for the companion repository with recipe files