Building Anaconda Navigator applications


This tutorial will build an Anaconda Navigator Application (app) of JupyterLab.

Three modifications to the files in the build recipe are required to declare the package as an app. Then, we’ll build JupyterLab with these recipe modifications. After we build the package, we will upload it to an Anaconda Cloud channel. Finally, after adding the channel in Anaconda Navigator, the app will appear on the Home pane.

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 given recipe. Prior knowledge of conda-build or conda recipes is recommended.

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.

Using a recipe

First, make a new directory called jupyterlab and then change to the new directory:

mkdir jupyterlab
cd jupyterlab

Create the recipe by opening a text file and name it meta.yaml. Copy the recipe from the feedstock:

{% set version = "1.2.4" %}
{% set sha256 = "6adb88acd05b51512c37df477a18c36240823a591c2a51bf6556198414026d8f" %}


package:
    name: jupyterlab
    version: {{ version }}

source:
    fn: jupyterlab-{{ version }}.tar.gz
    url: https://pypi.io/packages/source/j/jupyterlab/jupyterlab-{{ version }}.tar.gz
    sha256: {{ sha256 }}
build:
    noarch: python
    number: 0
    script: {{ PYTHON }} -m pip install --install-option="--skip-npm" . -vv
    entry_points:
        - jupyter-lab = jupyterlab.labapp:main
        - jupyter-labextension = jupyterlab.labextensions:main
        - jupyter-labhub = jupyterlab.labhubapp:main
        - jlpm = jupyterlab.jlpmapp:main

app:
    entry: jupyter lab
    icon: icon.png
    summary: JupyterLab PRE-ALPHA
    type: desk

requirements:
    host:
        - python >=3.5
        - pip
        - nodejs >=8
    run:
        - python >=3.5
        - jupyterlab_server >=1.0.0,<2.0.0
        - notebook >=4.3.1
        - tornado !=6.0.0,!=6.0.1,!=6.0.2
        - jinja2 >=2.10
test:
    requires:
        - nodejs
    imports:
        - jupyterlab
    commands:
        - jupyter lab --version
        - jlpm --version
        - jlpm versions
        - jupyter labextension list
        - jupyter lab path
        - jupyter lab build
        - jupyter lab clean

about:
    home: https://github.com/jupyterlab/jupyterlab
    license: BSD-3-Clause
    license_family: BSD
    license_file: LICENSE
    summary: >
        An extensible environment for interactive and reproducible computing, based
        on the Jupyter Notebook and Architecture.
    doc_url: https://jupyterlab.readthedocs.io
    dev_url: https://github.com/jupyterlab/jupyterlab
    description: >
        JupyterLab is the next-generation user interface for Project Jupyter. It
        offers all the familiar building blocks of the classic Jupyter Notebook
        (notebook, terminal, text editor, file browser, rich outputs, etc.) in a
        flexible and powerful user inteface. Eventually, JupyterLab will replace
        the classic Jupyter Notebook.
        JupyterLab can be extended using extensions that are npm packages and use
        our public APIs. You can search for the GitHub topic or npm keyword
        `jupyterlab-extension` to find extensions. To learn more about extensions,
        see our user documentation.
        JupyterLab is suitable for general usage. For JupyterLab extension
        developers, the extension APIs will continue to evolve.
extra:
    recipe-maintainers:
        - jasongrout
        - blink1073
        - jochym
        - ian-r-rose
        - afshin
        - ellisonbg

Build architecture

The recipe, as given, is a noarch recipe. This is not compatible with older versions of Navigator. Under the build section, remove noarch: python.

App entry in meta.yaml

To declare a conda package as an app, the app parameter must be added to to the meta.yaml file. The app section will contain three keys: entry, summary, and type. In the case of the JupyterLab recipe, replace the app section in the meta.yaml with the values below.

In the app section, the entry tag defines how the package is to be launched by Anaconda Navigator. For JupyterLab, 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: jupyterlab .                                 [win]

 entry: jupyterlab .                                 [linux]

Launch script

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

DIR=$(dirname $0)
$DIR/jupyter-lab ${HOME}

Build.sh script

To make sure that the file gets installed, create a new file in the same directory as the meta.yaml. Title it build.sh and add these lines to the build.sh script:

$PYTHON  -m pip install . --no-deps --ignore-installed -vv
if [ `uname` == Darwin ]

then
    cp $RECIPE_DIR/jupyterlab_mac.command $PREFIX/bin

fi

Remove the script key under the build section in the meta.yaml.

Build.bat

Create a new file called build.bat. Include the following:

%PYTHON% -m pip install . --no-deps --ignore-installed -vv

Entry key

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

The completed app section should look like this:

Note

The app icon defaults to the Anaconda logo.

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 JupyterLab package separately on Windows, macOS, and Linux machines in order for the package to be available on all platforms. If you’re already in the JupyterLab directory, you can type conda build . in your terminal. Otherwise type conda-build jupyterlab.

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\username\miniconda\conda-bld\win-64\jupyterlab-1.2.4-py38_0.tar.bz2

macOS example file path: /Users/username/anaconda3/conda-bld/osx-64/jupyterlab-1.2.4-py38_0.tar.bz2

Linux example file path: /home/username/miniconda/conda-bld/linux-64/bjupyterlab-1.2.4-py38_0.tar.bz2

Note

The 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, log in to Anaconda Cloud from your terminal: 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:

Note

This step must be done in the root conda environment.

Now that you are logged into your channel, you can upload the JupyterLab conda package as follows:

Windows users: anaconda upload C:\Users\username\miniconda\conda-bld\win-64\jupyterlab-1.2.4-py38_0.tar.bz2

Linux and macOS users: anaconda upload /Users/username/miniconda/conda-bld/osx-64/jupyterlab-1.2.4-py38_0.tar.bz2

Note

Change your username, path, and filename to the exact username, path, and filename you saved in Step 2. These 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 JupyterLab package has been uploaded to your Anaconda Cloud channel, you need to add the channel to Anaconda Navigator.

  1. 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.

  2. Open the Environments pane on the far left.

  3. 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

    Note

    Replace “channel” with your Anaconda Cloud username.

  4. Press Enter and select Update Channels.

    ../../../../_images/add-channel.png
  5. Close and restart Anaconda Navigator. The JupyterLab app will be displayed on the Home pane.

Troubleshooting

A. Conda-build fails

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

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. 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 jupyterlab

If JupyterLab starts correctly then you may have to remove your .anaconda/navigator directory and restart Navigator. This directory is in your Home directory.

Additional Information

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