Skip to content

Creating Anaconda Binary Packages

Connie Gao edited this page Jan 26, 2016 · 12 revisions

You must begin with (Anaconda)[http://www.continuum.io/downloads] with Python 2.7 installed. Then install conda-build and anaconda-client if needed:

conda install conda-build
conda install anaconda-client

Configure a .condarc file, which has the purpose of providing Anaconda settings and pointing to the rmg channel when looking for packages. The .condarc file should be stored either in the '~' folder (unix-based systems) or alternatively inside the base Anaconda installation folder (all systems).

The .condarc file should look like this:

channels:
  - defaults
  - rmg

Recently it has come to my attention that conda does not always prioritize the rmg channel's package. It instead finds the most optimal one. So you may have to force a version on your package if you want one specifically.

If you are using windows, you must install the conda package mingwpy:

conda install mingwpy

In Windows you may need to point distutils to MinGW. Go to C:\Anaconda or wherever you installed Anaconda, then type the following into the command prompt:

cd C:\Anaconda
echo -e "[build]\ncompiler=mingw32" > Lib/distutils/distutils.cfg

Creating RMG-related Binaries

For RMG-related source code to be compiled into a binary, first clone the repo (here we use the example PyDAS). Then in the directory outside of that repo and the same directory you did the cloning, type the command

cd ~/Code/
git clone https://github.com/ReactionMechanismGenerator/PyDAS/
conda build PyDAS

If successful, Anaconda will write that the build is successful in your terminal or command prompt and then tell you to upload it to a relevant channel.

Building Binaries for RMG Dependencies

In order for the Anaconda environment or the RMG-related binaries to work successfully, we compile and store all relevant dependencies on the RMG channel on Anaconda.org. Some of these recipes can be found in the conda-recipes repo: http://github.com/ReactionMechanismGenerator/conda-recipes

A larger repo of conda-recipes for a variety of packages can be found at http://github.com/conda/conda-recipes

For more information on how to create a build recipe or use one, visit the Conda documentation page here: http://conda.pydata.org/docs/building/recipe.html

Note: It is helpful to first search Anaconda.org or PyPI for anaconda or pip packages before trying to compile dependencies by yourself. Often there is a prebuilt package that you can copy to RMG's channel instead of having to build your own. Be sure to test them to see if they are working.

It is possible to copy a dependency from another channel to the RMG channel using the command

anaconda copy channelname/packagename/version --to-owner RMG

Currently this may be not working, and you can upload a package manually by first downloading it to disk and uploading the normal way.

Stylistically I recommend if you did not create the package yourself, to remove the OS prefix in front of the file and change it to just the pkgname_versionetc.tar.bz2 naming format so that it uploads and displays nicely.

Note that anaconda will automatically detect that the package is a conda package and also auto-detect the OS for while the package was built, so there is no need to specify it if the package is build properly.

Uploading, Testing, and Removing Packages from the Anaconda Channel

anaconda upload location_of_package/packagename_version_.tar.bz2

Alternatively if you are uploading to the RMG channel on Anaconda.org instead of your default user channel, use the flag -u:

anaconda upload location_of_package/packagename_version_.tar.bz2 -u RMG --force

The --force flag is optional for when you want to overwrite a package

To fully test the package after you upload it, run the command

conda create --name package_name_env package_name
source activate package_name

where package_name is replaced by whatever package you just built. This will create a fresh environment with only the single package on it. Then you can open a python prompt or type additional commands to test your package.

To delete a malformed or deprecated package, use the command:

anaconda remove channelname/pkg/version