Anaconda Enterprise: Documentation

# Building Anaconda Navigator Applications

## Overview

This tutorial will build an Anaconda Navigator Application (app) of the Rodeo IDE.

## Who is this for?

This tutorial is for Windows, macOS, and Linux users who wish to generate an Anaconda Navigator app conda package from a PyPI package. Prior knowledge of conda-build or conda recipes is recommended.

### Conda build summary

The conda build recipe for Rodeo will be generated by conda skeleton. Three modifications to the files in the build recipe are required to declare the package as an app. The package is built and uploaded to your Anaconda Cloud channel. Finally, after adding the channel in Anaconda Navigator the app will appear on the Home pane.

1. Before you start
2. Create skeleton recipe
3. Modify Requirements
4. App entry in meta.yaml
5. Build
6. Upload to Anaconda Cloud
7. Configure Anaconda Navigator
8. Troubleshooting
9. Additional Information

## Before you start

Note: Applications to be built for Anaconda Navigator should have a graphical user interface. Not all conda packages have graphical interfaces.

You should already have installed Miniconda or Anaconda.

Install conda-build:

    conda install conda-build

It is recommended that you use the latest versions of conda and conda-build. To upgrade both packages run:

    conda upgrade conda
    conda upgrade conda-build

You will also need an account on Anaconda Cloud. Your username will be referred to as your Anaconda Cloud channel.

## Create skeleton recipe

First, in your user home directory, run the `conda skeleton` command:

    conda skeleton pypi rodeo

This creates a directory named rodeo and creates three skeleton files in that directory: meta.yaml, build.sh, and bld.bat. Use the `ls` command on macOS or Linux or the `dir` command on Windows to verify that these files have been created.

## Modify Requirements

In a text editor change entries from `ipython` to `jupyter` in the `requirements` section. The full `requirements` section will look like this.

    requirements:
      build:
        - python
        - setuptools
        - jupyter
        - flask >=0.10.1
        - docopt
        - pyzmq >=13
        - mistune

      run:
        - python
        - jupyter
        - flask >=0.10.1
        - docopt
        - pyzmq >=13
        - mistune

## App entry in meta.yaml

To declare a conda package as an app the `app` parameter must be added to the `meta.yaml` file. The `app` section will contain four keys `entry`, `icon`, `summary` and `type`.

In the `app` section the `entry` tag defines how the package is to be launched by Anaconda Navigator. For the Rodeo IDE separate `entry` tags are required for Windows, macOS, and Linux operating systems.

In your text editor open the `meta.yaml` file and add the following lines.

On Windows and Linux the `entry` tag is

    app:
      entry: rodeo .                              [win]
      entry: rodeo .                              [linux]

For macOS a launch script must also be provided. In a text editor create a new file in the conda build recipe directory called `rodeo_mac.command`. The contents of this file are

    DIR=$(dirname $0)

    $DIR/rodeo ${HOME}

To make sure that the file gets installed add these lines to the `build.sh` script.

    if [ `uname` == Darwin ]
    then
        cp $RECIPE_DIR/rodeo_mac.command $PREFIX/bin
    fi

Then in `meta.yaml` add this line to the `app` section.

    entry: open ${PREFIX}/bin/rodeo_mac.command [osx]

Finally, a logo PNG file is provided in the conda build recipe that will be displayed in Anaconda Navigator. You can download the app.png file directly from the Github repository. This file must be downloaded to the same directory as the `meta.yaml` file.

The completed `app` section should look like this.

    app:
      entry: rodeo .                              [win]
      entry: rodeo .                              [linux]
      entry: open ${PREFIX}/bin/rodeo_mac.command [osx]
      icon: app.png
      summary: Rodeo Data Science IDE
      type: web

You can download full versions of the `meta.yaml` and `build.sh` files.

## Build

Now that you have the conda build recipe ready, you can use the conda-build tool to create the package. You will have to build and upload the rodeo package separately on Windows, macOS, and Linux machines in order for the package to be available on all platforms.

    conda build rodeo

When conda-build is finished, it displays the exact path and filename of the conda package. See the Troubleshooting section if the conda-build command fails.

Windows example file path:

    C:\Users\jsmith\Miniconda\conda-bld\win-64\rodeo-0.4.4-py35_0.tar.bz2

macOS example file path:

    /Users/jsmith/miniconda/conda-bld/osx-64/rodeo-0.4.4-py35_0.tar.bz2

Linux example file path:

    /home/jsmith/miniconda/conda-bld/linux-64/rodeo-0.4.4-py35_0.tar.bz2

NOTE: Your path and filename will vary depending on your installation and operating system. Save the path and filename information for the next step.

## Upload to Anaconda Cloud

Now you can upload the new local packages to Anaconda Cloud.

First login to Anaconda Cloud from your terminal application:

    anaconda login

You will be asked for your Anaconda Cloud account name and password. If the login was successful you will see output like the following.

    Using Anaconda Cloud api site https://api.anaconda.org
    Username: defusco
    defusco's Password:
    login successful

Note: This step must be done in the root conda environment.

Now that you are logged into your channel you can upload the Rodeo conda package as follows.

Windows users:

    anaconda upload C:\Users\jsmith\Miniconda\conda-bld\win-64\rodeo-0.4.4-py35_0.tar.bz2

Linux and macOS users:

    anaconda upload /home/jsmith/miniconda/conda-bld/linux-64/rodeo-0.4.4-py35_0.tar.bz2

Note: Change your path and filename to the exact path and filename you saved in Step 2. Your path and filename will vary depending on your installation and operating system.

For more information about Anaconda Cloud, see the Anaconda Cloud documentation page.

## Configure Anaconda Navigator

Now that the Rodeo package has been uploaded to your Anaconda Cloud channel you need to add the channel to Anaconda Navigator.

Launch the Anaconda Navigator app. In Windows and Linux it will be available from the Start Menu. On macOS you can find it either on the Desktop or through Spotlight.

Open the Environments pane on the far left:

To add your channel first click the Channel button, second click the Add button, third type in the URL to your Anaconda Cloud channel:

    https://conda.anaconda.org/CHANNEL

Replace CHANNEL with your Anaconda Cloud username.

Finally, click the Update Channels button:

The last step is to close and restart Anaconda Navigator. The Rodeo app will be displayed on the Home pane.

## Troubleshooting

### A. Conda build fails

If the conda recipe fails to build consult the Troubleshooting page.

### B. App does not appear on the home pane

Check that the conda package has been uploaded to your Anaconda Cloud channel.

Check that your channel has been added to the Channels list.

You may have to remove your `.anaconda/navigator` directory and restart Navigator.

On Windows, macOS, and Linux this directory is in your Home directory.

### C. App does not launch

If after installing the application it does not launch check that it works correctly on the command line with the following command.

    conda run rodeo

If rodeo starts correctly then you may have to remove your `.anaconda/navigator` directory and restart Navigator.

On Windows, macOS, and Linux this directory is in your Home directory.

## Additional Information

See the conda skeleton pypi reference page for more options.

For more information about adding Start Menu entries in Windows see the menuinst documentation.