ó
¼S]c           @@  s#  d  Z  d d l m Z d d l m Z m Z d d l m Z d d l Z d d l	 m
 Z
 m Z m Z d d l m Z d d l m Z d d	 l m Z g  a d
 „  Z d „  Z d d „ Z d e f d „  ƒ  YZ d e e ƒ f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d e f d „  ƒ  YZ d S(   s'   Abstract high-level interface to Conda.i    (   t   absolute_import(   t   ABCMetat   abstractmethod(   t   deepcopyN(   t   _CommentedMapt   _CommentedSeqt   _block_style_all_nodes(   t   with_metaclass(   t	   conda_api(   t   _combine_conda_package_listsc         C@  s&   t  |  t ƒ s t ‚ t j |  ƒ d S(   s9   Push the concrete subtype of ``CondaManager`` to be used.N(   t
   issubclasst   CondaManagert   AssertionErrort   _conda_manager_classest   append(   t   klass(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   push_conda_manager_class   s    c           C@  s&   t  t ƒ d k s t ‚ t j ƒ  d S(   sE   Remove the most recently-pushed concrete subtype of ``CondaManager``.i    N(   t   lenR   R   t   pop(    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   pop_conda_manager_class   s    c         C@  sB   t  t ƒ d k r+ d d l m } | } n
 t d } | d |  ƒ S(   s'   Create a new concrete ``CondaManager``.i    (   t   DefaultCondaManageriÿÿÿÿt   frontend(   R   R   t/   anaconda_project.internal.default_conda_managerR   (   R   R   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   new_conda_manager%   s
    	
t   CondaManagerErrorc           B@  s   e  Z d  Z RS(   s   General Conda error.(   t   __name__t
   __module__t   __doc__(    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR   0   s   R   c           B@  sP   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d e d „ ƒ Z e d „  ƒ Z	 RS(   sJ  Methods for interacting with Conda.

    This is meant to be a stateless class. Multiple may be created
    and they may be used from multiple threads. If instances are
    implemented using any global state under the hood, that global
    state should be protected by locks, and shared among
    ``CondaManager`` instances.

    c         C@  s   d S(   sš  Compute the full transitive graph to install to satisfy package_specs.

        Raised exceptions that are user-interesting conda problems
        should be subtypes of ``CondaManagerError``.

        The passed-in package specs can be any constraints we want
        to "hold constant" while computing the other deps.

        The returned value is a ``CondaLockSet``.

        Args:
            package_specs (list of str): list of specs to hold constant
            channels (list of str): list of channels to resolve against
            platforms (list of str): list of platforms to resolve for

        Returns:
            a ``CondaLockSet`` instance

        N(    (   t   selft   package_specst   channelst	   platforms(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   resolve_dependenciesA   s    c         C@  s   d S(   s  Compute a ``CondaEnvironmentDeviations`` describing deviations of the env at prefix from the spec.

        Raised exceptions that are user-interesting conda problems
        should be subtypes of ``CondaManagerError``.

        The prefix may not exist (which would be considered a
        deviation).

        Args:
            prefix (str): the environment prefix (absolute path)
            spec (EnvSpec): specification for the environment

        Returns:
            a ``CondaEnvironmentDeviations`` instance

        N(    (   R   t   prefixt   spec(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   find_environment_deviationsX   s    c         C@  s   d S(   sr  Fix deviations of the env in prefix from the spec.

        Raised exceptions that are user-interesting conda problems
        should be subtypes of ``CondaManagerError``.

        The prefix may not exist (this method should then try to create it).

        Args:
            prefix (str): the environment prefix (absolute path)
            spec (EnvSpec): specification for the environment
            deviations (CondaEnvironmentDeviations): optional previous result from find_environment_deviations()
            create (bool): True if we should create if completely nonexistent

        Returns:
            None
        N(    (   R   R!   R"   t
   deviationst   create(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   fix_environment_deviationsl   s    c         C@  s   d S(   s¢  Remove the given package name from the environment in prefix.

        This method ideally would not exist. The ideal approach is
        that in find_enviroment_deviations, the generated
        deviation could include "pruned" or "unnecessary" packages
        that are in the prefix but aren't needed for the
        spec. fix_environment_deviations would then remove any
        extra packages. In effect we'd always force the
        environment to be the fresh env we would install from
        scratch, given the spec.

        Args:
           prefix (str): environment path
           package (list of str): package names

        Returns:
           None

        N(    (   R   R!   t   packages(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   remove_packages€   s    N(
   R   R   R   R   R    R#   t   Nonet   TrueR&   R(   (    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR   6   s   	t   CondaEnvironmentDeviationsc           B@  s†   e  Z d  Z e e d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z RS(	   sD   Represents differences between actual and desired environment state.c         C@  s~   | |  _  | |  _ | |  _ t | ƒ |  _ t | ƒ |  _ t | ƒ |  _ t | ƒ |  _ |  j rj |  j	 sz |  j sz t
 ‚ d S(   sè  Construct a ``CondaEnvironmentDeviations``.

        Args:
          summary (str): the most immediate reason the environment deviates
          missing_packages (iterable of str): packages that aren't in the env
          wrong_version_packages (iterable of str): packages that are the wrong version
          broken (bool): True if it's broken for some other reason besides wrong packages
          unfixable (bool): True if fix_environment_deviations won't be able to solve it
        N(   t   _summaryt   _brokent
   _unfixablet   tuplet   _missing_packagest   _wrong_version_packagest   _missing_pip_packagest   _wrong_version_pip_packagest	   unfixablet   okR   (   R   t   summaryt   missing_packagest   wrong_version_packagest   missing_pip_packagest   wrong_version_pip_packagest   brokenR4   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   __init__›   s    			c         C@  s\   t  |  j ƒ d k o[ t  |  j ƒ d k o[ t  |  j ƒ d k o[ t  |  j ƒ d k o[ |  j S(   s  True if no deviations were found, environment exists and looks good.

        If the deviations are "ok" then
        ``CondaManager.fix_environment_deviations()`` would be
        expected to have no work to do and doesn't need to be
        called.

        i    (   R   R7   R8   R9   R:   R-   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR5   ·   s
    
c         C@  s   |  j  S(   s6   True if fix_environment_deviations can't resolve this.(   R.   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR4   Ç   s    c         C@  s   |  j  S(   s   Summary description of status.(   R,   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR6   Ì   s    c         C@  s   |  j  S(   s-   Iterable collection of missing package names.(   R0   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR7   Ñ   s    c         C@  s   |  j  S(   sG   Iterable collection of package names an unacceptable version installed.(   R1   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR8   Ö   s    c         C@  s   |  j  S(   s1   Iterable collection of missing pip package names.(   R2   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR9   Û   s    c         C@  s   |  j  S(   sK   Iterable collection of pip package names an unacceptable version installed.(   R3   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR:   à   s    (   R   R   R   t   FalseR<   t   propertyR5   R4   R6   R7   R8   R9   R:   (    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR+   ˜   s   c         @  sd   t  t j |  | ƒ ƒ } t d „  | ƒ } t d „  | ƒ } ‡  f d †  } t | | ƒ } t  | ƒ S(   Nc         S@  s   |  d d k S(   Ni    t    (    (   t   x(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   <lambda>ð   t    c         S@  s   |  d d k S(   Ni    t   ?(    (   R@   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRA   ò   RB   c         @  sF   |  j  d ƒ r d ˆ  |  d S|  j  d ƒ r> d ˆ  |  d S|  Sd  S(   Ns   + i   s   - (   t
   startswith(   t   s(   t   indent(    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   indent_moreô   s
    (   t   listt   difflibt   ndifft   filtert   map(   t   old_listt   new_listRF   t   diffRG   (    (   RF   s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   _pretty_diffæ   s    	t   CondaLockSetc           B@  s¿   e  Z d  Z e d e d „ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z d „  Z d	 „  Z d
 „  Z e d „  ƒ Z e d „  ƒ Z d „  Z RS(   s,   Represents a locked set of package versions.c         C@  sj   | d k	 s t ‚ | d k	 s$ t ‚ t | ƒ |  _ t t j | ƒ ƒ |  _ | |  _ | |  _	 | |  _
 d S(   sB  Construct a ``CondaLockSet``.

        The passed-in dict should be like:

        {
           "all" : [ "bokeh=0.12.4=1" ],
           "linux-64" : [ "libffi=1.2=0" ]
        }

        Args:
          packages_by_platform (dict): dict from platform to spec list
          platforms (list of str): platform list
        N(   R)   R   R   t   _package_specs_by_platformR/   R   t   sort_platform_listt
   _platformst   _enabledt   _env_spec_hasht   _missing(   R   t   package_specs_by_platformR   t   enabledt   env_spec_hasht   missing(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR<     s    		c         C@  s   |  j  S(   s,   Platform list the lock set was resolved for.(   RT   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR     s    c         C@  s   |  j  S(   s0   Whether locking is enabled for this environment.(   RU   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRY      s    c         C@  s   |  j  S(   s   Whether locking is disabled for this environment.

        (yes, this is just "not enabled" but this can be more readable sometimes)
        (   RU   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   disabled%  s    c         C@  s   |  j  S(   s¼   Whether a lock set existed in the lock file.

        This says whether the lock set was loaded from anaconda-project-lock.yml
        or was just a default we made up on the fly.
        (   RW   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyR[   -  s    c         C@  s   |  j  S(   s2   Hash of the env spec we created this lock set for.(   RV   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRZ   6  s    c         C@  s"   |  j  d  k s t ‚ | |  _  d  S(   N(   RV   R)   R   (   R   t   value(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRZ   ;  s    c         C@  s4   |  j  | j  k o3 |  j | j k o3 |  j | j k S(   s3   Determine if this lock set the same as another one.(   RR   RT   RU   (   R   t   other(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   equivalent_toA  s    c   
      C@  sÁ  t  |  j j ƒ  ƒ } | d k	 rO | t  | j j ƒ  ƒ } t  t | ƒ ƒ } n  t j | ƒ } g  } xç | D]ß } | d k r† g  } n | j j | g  ƒ } |  j j | g  ƒ } t | | d d ƒ} | rk | d k sæ | | j k rú | j	 d | ƒ n4 | |  j k r| j	 d | ƒ n | j	 d | ƒ | j
 t d „  | ƒ ƒ qk qk W| rdd g | } n  | d k ryg  } n	 | j } t | |  j d d ƒ}	 |	 r°d	 g |	 }	 n  d
 j |	 | ƒ S(   s„   A string showing the comparison between this lock set and another one.

        "old" can be None to mean diff vs. nothing.
        RF   s       s   +   %s:s   -   %s:s       %s:c         S@  s   |  S(   N(    (   R@   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRA   j  RB   s     packages:s     s     platforms:s   
N(   RH   RR   t   keysR)   t   setR   RS   t   getRP   R   t   extendRL   R   t   join(
   R   t   oldR`   t   packages_difft   keyRM   RN   RO   t   old_platformst   platforms_diff(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt	   diff_fromJ  s8    	 		c         C@  sÈ   | |  j  k s t ‚ |  j s$ t ‚ |  j j d g  ƒ } t j | ƒ d } | t j k r‚ |  j j d g  ƒ } t | | ƒ } n  |  j j | g  ƒ } t | | ƒ } |  j j | g  ƒ } t | | ƒ S(   s<   Sequence of package spec strings for the requested platform.t   alli    t   unix(	   R   R   RY   RR   Rb   R   t   parse_platformt   unix_platform_namesR	   (   R   t   platformt   sharedt   platform_namet   shared_unixt   shared_across_bitst   per_platform(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   package_specs_for_platformy  s    c         C@  s%   |  j  s t ‚ |  j d t j ƒ  ƒ S(   s:   Sequence of package spec strings for the current platform.Ro   (   t   supports_current_platformR   Ru   R   t   current_platform(   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt"   package_specs_for_current_platform  s    c         C@  s   |  j  o t j ƒ  |  j k S(   s5   Whether we have locked deps for the current platform.(   RY   R   Rw   R   (   R   (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRv   “  s    c         C@  så   t  ƒ  } |  j | d <|  j d k	 r5 |  j | d <n  t ƒ  } x |  j D] } | j | ƒ qH W| | d <t  ƒ  } xX t j |  j	 j
 ƒ  ƒ D]> } t ƒ  } x" |  j	 | D] } | j | ƒ q¨ W| | | <q‹ W| | d <t | ƒ | S(   s"   JSON/YAML version of the lock set.t   lockedRZ   R   R'   N(   R   RY   RZ   R)   R   R   R   R   RS   RR   R`   R   (   R   t	   yaml_dictt   platforms_listRo   t   packages_dictR'   t   package(    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   to_json˜  s"    		
		

N(   R   R   R   R*   R)   R=   R<   R>   R   RY   R\   R[   RZ   t   setterR_   Rj   Ru   Rx   Rv   R~   (    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyRQ     s   				/	(   R   t
   __future__R    t   abcR   R   t   copyR   RI   t   anaconda_project.yaml_fileR   R   R   t#   anaconda_project.internal.metaclassR   t   anaconda_project.internalR   t   anaconda_project.env_specR	   R   R   R   R)   R   t	   ExceptionR   R   t   objectR+   RP   RQ   (    (    (    s=   lib/python2.7/site-packages/anaconda_project/conda_manager.pyt   <module>   s"   		bN	