.. _cloud-uploading-conda-packages:

=======================================
Uploading and installing conda packages
=======================================

To work with conda packages, you must use the corresponding subdomain ``https://conda.anaconda.org``. To install conda packages from the user ``travis``, for example, use the repository URL ``https://conda.anaconda.org/travis``.

Uploading conda packages
========================

This example shows how to build and upload a `conda <http://conda.pydata.org/>`_ package to Anaconda.org using ``conda build``.

#. Open Anaconda Prompt (Terminal on macOS/Linux).
#. If necessary, install the ``anaconda-client`` and ``conda-build`` packages by running the following command::

       conda install anaconda-client conda-build

#. Choose the repository for which you would like to build the package. In this example, we use a small public `conda test package <https://github.com/Anaconda-Platform/anaconda-client/tree/master/example-packages/conda>`_::

       # Replace <PACKAGE> with the package name
       git clone https://github.com/Anaconda-Platform/anaconda-client
       cd anaconda-client/<PACKAGE>/conda/

   In this directory, there are two required files, `meta.yaml <https://github.com/Anaconda-Platform/anaconda-client/blob/master/example-packages/conda/meta.yaml>`_ and `build.sh <https://github.com/Anaconda-Platform/anaconda-client/blob/master/example-packages/conda/build.sh>`_.

   macOS and Linux systems are Unix systems. Packages built for Unix systems require a ``build.sh`` file, packages built for Windows require a ``bld.bat`` file, and packages built for both Windows and Unix systems require both a ``build.sh`` file and a ``bld.bat`` file. All packages require a ``meta.yaml`` file.

#. To build the package, turn off automatic Client uploading and then run the ``conda build`` command::

       conda config --set anaconda_upload no
       conda build .

   All packages built in this way are placed in a subdirectory of the :doc:`Anaconda </anaconda/index>` ``conda-bld`` directory.

   .. tip::
       You can check where the resulting file was placed by adding the ``--output`` option::

              conda build . --output

#. Upload the test package to Anaconda.org by running the ``anaconda upload`` command::

       anaconda login

       # Replace </PATH/TO/PACKAGE_NAME> with the correct file path and package name
       # Packages can be uploaded with .tar.bz2 or .conda compression formats
       anaconda upload </PATH/TO/PACKAGE_NAME>.tar.bz2
       anaconda upload </PATH/TO/PACKAGE_NAME>.conda

For more information on the ``.conda`` format, see :ref:`Using the .conda compression format <conda-compression-format>`.

For more information on conda's overall build framework, check out our article on `Building conda packages <https://docs.conda.io/projects/conda-build/en/stable/concepts/recipe.html>`_.

Installing conda packages
=========================

You can install conda packages from Anaconda.org by adding channels to your conda configuration.

Public channels
---------------

#. Open Anaconda Prompt (Terminal on macOS/Linux).
#. Because conda knows how to interact with Anaconda.org, specifying the channel ``sean``, for example, translates to https://anaconda.org/sean::

       conda config --add channels sean

#. You can now install public conda packages from Sean's Anaconda.org account. Try installing the ``testci`` package at https://anaconda.org/sean/testci::

       conda install testci

Private channels
----------------

You can install a package from a private channel with a token and a :ref:`glossary-label`::

     # Replace <TOKEN> with the provided token
     # Replace <CHANNEL> with a user channel
     # Replace <LABEL_NAME> with the label name
     # Replace <PACKAGE> with the name of the package you want to install
     conda install --channel https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>/label/<LABEL_NAME> <PACKAGE>

Tokens are only required if the channel is private.

Finding help for uploading packages
===================================

You can obtain a complete list of upload options, including:

* Package channel.
* Label.
* Availability to other users.
* Metadata.

To list the options, run the following in Anaconda Prompt (Terminal on macOS/Linux)::

    anaconda upload -h