===================
Using cas-installer
===================


The cas-installer tool makes an environment installer, which is a
bash script or Windows executable file that can be run on any machine
to install an exact copy of a conda environment and its packages on
that machine.


Installing cas-installer
========================

A token from Anaconda is required to install cas-installer, and you
should have received it when your organization purchased Repository,
Workgroup or Enterprise. If you no longer have access to your token,
submit a support ticket or contact us at
`Enterprise Support <https://support.anaconda.com/>`_. You can also
email support at the email address given to you by your sales
representative.

When you have the token, run::

  export TOKEN=<your_anaconda_cloud-token>
  conda config --add channels https://conda.anaconda.org/t/$TOKEN/anaconda-server


Because this tool allows you to create an installer for a conda
environment, it is important that the cas-installer package is
installed into the root conda environment, not root user. The
following command ensures that this happens::

  conda install -n root cas-installer=1.3.2


Using the cas-installer command
===============================

Once installed, the ``cas-installer`` command is available::

  cas-installer -h

The command takes an installer specification file as its
argument, which specifies the name of the installer, the conda
channel to pull packages from, the conda packages included in the
installer, and so on.

EXAMPLE::

  # ----------------- required -----------------
  # name
  name: test

  # channels to pull packages from
  # The &channels creates a back reference so that it can be reused as
  # *channels in the conda_default_channels section below.
  channels: &channels
    - https://repo.continuum.io/pkgs/free/

  # specifications
  specs:
    - python
    - grin

  # ----------------- optional -----------------
  # platform e.g. linux-32, osx-64, win-32 defaults to current platform
  # platform: linux-64

  # The conda default channels which are used when running a conda which
  # was installed be the cas-installer created: requires conda---3.6.2 or
  # greater---in the specifications. The *channels is a YAML reference to
  # &channels above. It inserts all the channels from the channels key, so
  # that they do not have to be typed twice.

  conda_default_channels: *channels

  # installer filename
  # installer_filename: grin.sh

  # default install prefix
  default_prefix: /opt/anaconda


For Windows, the tool creates nsis-based .exe installers, which
can only be created on a Windows platform, although the architecture
may be different. For Unix, the tool creates bash-based .sh
installer, which can only be created on Unix---Linux or
macOS---systems.
