===================================================
Configuring your PyPI or Anaconda Repository mirror
===================================================

NOTE: This documentation is for Anaconda Repository 2.3.0+.  For documentation of older versions, please see :doc:`2.2 documentation <mirrors-sync-configuration-2.2>`.


Before you begin
================

Before installing Anaconda Repository 2.3.0 and using the updated features listed below, you must install the supplemental cas-mirror package::

  conda install cas-mirror


Although some aspects of mirroring PyPI and Anaconda Repository differ, the methodology for the specification of which packages to mirror is identical. You can specify:

- platforms (valid options are: 'linux-64', 'linux-32', 'osx-64', 'win-32', and 'win-64')
- pkg_list 
- python_versions (valid options are: 2.6, 2.7, 3.3, 3.4)
- license_blacklist (valid options are:  AGPL, GPL2, GPL3, LGPL, BSD, MIT, Apache, PSF, Public-Domain, Proprietary and Other) * 
- blacklist
- whitelist

Other useful configuration options include:

- remote_url
  
  Specifies the remote URL from which the conda packages and the Anaconda and Miniconda installers are downloaded. 
  The default value is: `https://repo.continuum.io/ <https://repo.continuum.io/>`_.

- channels

  Specifies the remote channels from which conda packages are downloaded. 
  The default is a list of the channels <remote_url>/pkgs/free/ and <remote_url>/pkgs/pro/


NOTE: the license_blacklist feature is not available for PyPI due to the non-standardization of license metadata for these packages.  

All specification information should be included in the same file, and can be passed to the anaconda-server-sync-pypi or anaconda-server-sync-conda command via the --mirror-config argument::

  anaconda-server-sync-conda --mirror-config /etc/binstar/mirrors/conda.yaml
  anaconda-server-sync-pypi --mirror-config /etc/binstar/mirrors/pypi.yaml
  
  
Platform-specific mirroring
===========================

By default, the anaconda-server-sync-pypi and anaconda-server-sync-conda tools will mirror all platforms.  If you know that you will *not* need all platforms, it will save you time and disk space if you edit the YAML file to specify the platform(s) you want mirrored::

  platforms:
    - linux-64
    - win-32


Package-specific mirroring
==========================

In some cases you may want to mirror only a small subset of the Anaconda Repository.  Rather than blacklisting a long list of packages you do not want mirrored, you can instead simply enumerate the list of packages you DO want mirrored.

NOTE: This argument cannot be used with the blacklist, whitelist or license_blacklist arguments.  It can be used with the platform-specific argument.

For example::

  pkg_list:
  - accelerate
  - pyqt
  - zope 

This example mirrors only the three packages: Accelerate, PyQt & Zope.  All other packages will be completely ignored.

Python version-specific mirroring
=================================

A new feature in Anaconda Repository 2.3.0 allows you to mirror the Anaconda Repository with a Python version or versions specified.  

For example::

  python_versions:
  - 3.3

Mirrors only Anaconda packages built for Python 3.3.


"License blacklist" mirroring
=============================

As of Anaconda Repository 2.3.0, the Anaconda mirroring script supports license blacklisting for the following license families:

* AGPL 
* GPL2
* GPL3
* LGPL
* BSD
* MIT
* Apache
* PSF
* Public-Domain
* Proprietary
* Other

For example::

  license_blacklist:
    - GPL2
    - GPL3
    - BSD

Mirrors all the packages in the repository EXCEPT those that are GPL2-, GPL3-, or BSD-licensed, because those three licenses have been completely blacklisted.

NOTE: Older versions of Anaconda Mirror support only license blacklisting for GPL.  If you are using an older version of Anaconda Repository, see the documentation for :doc:`customizing your PyPI or Anaconda Repository mirror <mirrors-sync-configuration-2.2>`.



"Blacklist" mirroring
=====================

The blacklist allows access to all packages EXCEPT those explicitly listed.

For example::

  blacklist:
    - bzip2
    - tk
    - openssl

Mirrors the entire Anaconda Repository except the bzip2, tk, and openssl packages.


"Whitelist" mirroring
=====================

The whitelist functions in combination with either the license_blacklist or blacklist arguments, AND re-adds packages that were excluded by a previous argument.  

For example::

  license_blacklist:
    - GPL2
    - GPL3
  whitelist:
    - readline

Mirrors the entire Anaconda Repository EXCEPT any GPL2- or GPL3-licenses packages, but including readline, despite the fact that it is GPL3-licensed.  


Combining multiple mirror configurations
========================================

You may find that combining two or more of the arguments above is the simplest way to get the exact combination of packages that you want.

The *platform* argument is evaluated before any other argument.  For example::

    platforms:
      - linux-64
    pkg_list:
      - dnspython
      - shapely
      - gdal

Mirrors ONLY linux-64 distributions of the dnspython, shapely and gdal packages.

If the *license_blacklist* and *blacklist* arguments are combined, the *license_blacklist* is evaluated first, and the *blacklist* is a supplemental modifier::

    license_blacklist:
      - GPL2
    blacklist:
      - pyqt

In this example, the mirror configuration does not mirror GPL2-licensed packages. It does not mirror the GPL3 licensed package pyqt because it has been blacklisted. It does mirror all other packages in the repository.

If the *blacklist* and *whitelist* arguments are both employed, the *blacklist* is evaluated first, with the *whitelist* functioning as a modifier::

    blacklist:
     - accelerate
     - astropy
     - pygments
    whitelist:
     - accelerate

This mirrors all packages in the repository except astropy and pygments.  Despite being listed on the blacklist, accelerate IS mirrored because it is listed on the whitelist.
