Developer Blog
Summary: Explaining how Continuum's interactive 2015 holiday card was made also demonstrates the conda build system with a simple recipe.
Recently Continuum Analytics graphic designer Victoria O'Dell made a great company holiday card that said "conda install Joy / conda install Peace / conda install Happiness".
One of our developers suggested that it might be fun to build some packages so that the commands would really work, as a hidden feature. We wanted something quick and easy, so we decided the commands should display a holiday message and then open the card. Writing a Python script to do this on Windows, Linux and OS X and on Python 2.7 and 3.5 was remarkably quick and easy:
import time import webbrowser print('The Anaconda Team and Continuum Analytics wish you Joy this holiday season!') print('Loading holiday card...') time.sleep(3) webbrowser.open('http://www.continuum.io/sites/default/files/holidays2015.gif', new=2)
This prints the message, waits three seconds, and then opens the card in a new tab in the system's default web browser.
Next we created a conda recipe so the script can be installed into any system with a single conda command and run by typing "Joy" instead of "python Joy.py". Normally, a conda recipe refers to a .tar archive of source files, or a source repository on GitHub, but since in this case the source is just one small python file we can make it part of the recipe. We created an executable Python script called "Joy":
#!/usr/bin/env python import time import webbrowser def main(): print('The Anaconda Team and Continuum Analytics wish you Joy this holiday season!') print('Loading holiday card...') time.sleep(3) webbrowser.open('http://www.continuum.io/sites/default/files/holidays2015.gif', new=2) if __name__=='__main__': main()
Then we created "bld.bat" for Windows systems:
copy %RECIPE_DIR%\Joy %SP_DIR%\Joy.py if errorlevel 1 exit 1
And "build.sh" for Linux and OS X systems:
#!/bin/bash cp $RECIPE_DIR/Joy $PREFIX/bin
Finally we created "meta.yaml" for the conda build system, which uses the entry_points option to specify an entry point on Windows systems:
package: name: joy version: "1.0" build: entry_points: - Joy = Joy:main [win] requirements: build: - python run: - python about: license: BSD
These four files were placed together in a package directory called "joy". Then the process was repeated for "peace" and "happiness".
The next steps require conda, which is available in Anaconda and in Miniconda. Miniconda was already installed on my machine, and conda can be added easily to any machine with the conda quick install instructions.
I created a new conda environment called "holidayenv" which contained the anaconda-client program so I could upload the built packages to Anaconda Cloud, and activated that environment:
conda create -n holidayenv anaconda-client source activate holidayenv
At this point everything was ready to build the packages. I chose to build versions for all available versions of Python:
conda build --python all joy peace happiness
The next step is to convert these packages from the OS X machine where I first built them to all available platforms, including Windows, Linux, and 32-bit as well as 64-bit systems. This produces many files, so in the "holiday" directory I created a new directory called "allplatforms" and moved into it, and then did the conversion:
mkdir allplatforms cd allplatforms conda convert -p all ~/miniconda3/conda-bld/osx-64/joy* ~/miniconda3/conda-bld/osx-64/peace* ~/miniconda3/conda-bld/osx-64/happiness*
Once all the packages were converted successfully, there were three packages (joy peace and happiness) on five versions of Python (2.6 2.7 3.3 3.4 and 3.5) and five operating system platforms (linux-32 linux-64 osx-64 win-32 and win-64), for a total of 3*5*5=75 package files. To make them available to anyone, I uploaded them to my account on Anaconda Cloud:
anaconda login anaconda upload */*
After this, I tested the packages on 64-bit OS X Yosemite, 64-bit Ubuntu 14.04, and 64-bit Windows 8 by installing them from my account on Anaconda Cloud:
conda install -c wwarner Joy Peace Happiness Joy Peace Happiness
I also used different conda environments to test the packages on Python 2.7 and Python 3.5 on each platform. Once the packages were confirmed to work, Continuum developer Dr. Ilan Schnell copied the packages into the default Anaconda Cloud channels, which are maintained by Continuum, so that anyone can install them using exactly the instructions on the card:
conda install Joy conda install Peace conda install Happiness
Happy holidays to everyone, and may you all have a happy 2016!