Using package managers#

Repository supports two package managers, conda and PyPI. To work with conda or PyPI packages, you must use their corresponding subdomains.

EXAMPLE: To install conda packages from the user “travis,” use the Repository URL:

https://conda.<your-anaconda-repo>/travis

EXAMPLE: To install PyPI packages from the user “travis,” use the Repository URL:

https://pypi.<your-anaconda-repo>/travis

Working with conda packages#

Building a conda package#

To build a package using conda build:

  1. Install Anaconda Client and conda build:

    conda install anaconda-client conda-build
    
  2. Choose the repository for which you would like to build the package. In this example, we use a simple, public conda test package:

    git clone https://github.com/anaconda-platform/anaconda-client
    cd anaconda-client/example-packages/conda/
    

    In this directory, there are two required files, build.sh, and meta.yaml.

    NOTE: Linux and macOS 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 Unix and Windows systems require both a build.sh file and a bld.bat file. All packages require a meta.yaml file.

  3. 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 Anaconda’s conda-bld directory.

  4. You can check where the resulting file was placed with the --output option:

    conda build . --output
    

For more information on conda’s overall build framework, you may also want to read the articles Building conda packages and Tutorials on conda build.

Uploading a conda package#

Upload the test package to Repository with the anaconda upload command:

anaconda login
anaconda upload /path/to/conda-package.tar.bz2

NOTE: Replace /path/to/ with the path to where you stored the package.

Installing conda packages#

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

  1. Because conda knows how to interact with Repository, specifying the channel “sean” translates to https://<your-anaconda-repo>/sean:

    conda config --add channels sean
    
  2. You can now install public conda packages from Sean’s Repository account. Try installing the testci package at https://<your-anaconda-repo>/sean/testci:

    conda install testci
    

You can also install a package from a channel with a token and a label:

conda install -c https://conda.anaconda.org/t/<token>/<channel>/label/<labelname> <package>

NOTE: Replace <token> with the provided token,``<channel>`` with the user channel, <labelname> with the label name and <package> with the package name you want to install.

Working with PyPI packages#

Uploading PyPI packages#

You can test PyPI package uploading with a small, public example package saved in the anaconda-client repository:

  1. Begin by cloning the repository from the command line:

    git clone git@github.com:anaconda-platform/anaconda-client.git
    cd anaconda-client/example-packages/pypi/
    
  2. You can now create your PyPI package with the setup.py script:

    python setup.py sdist
    
  3. Your package now is built as a source “tarball” and is ready to be uploaded with:

    anaconda upload dist/*.tar.gz
    

Your package is now available at:

http://<your-anaconda-repo>/USERNAME/PACKAGE

NOTE: Replace <your-anaconda-repo> with the name of your local Repository, USERNAME with your username and PACKAGE with the package name.

Installing PyPI packages#

The best way to install a PyPI package is using pip. For the following command, you can use the package you authored in the above steps:

pip install --extra-index-url https://pypi.<your-anaconda-repo>/USERNAME/PACKAGE

NOTE: Replace <your-anaconda-repo> with the name of your local Repository, USERNAME with your username and PACKAGE with the test-package name.