
    ]cA                     r    d dl Z d dlZg dZ	 d dlmZ d Zd Z G d d      Z	d Z
y# e$ r	 d dlmZ Y !w xY w)	    N)install
NullFinderProtocol)r   c                 b    t         j                  j                   |               t                | S )z
    Class decorator for installation on sys.meta_path.

    Adds the backport DistributionFinder to sys.meta_path and
    attempts to disable the finder functionality of the stdlib
    DistributionFinder.
    )sys	meta_pathappenddisable_stdlib_finder)clss    </usr/lib/python3/dist-packages/importlib_metadata/_compat.pyr   r      s#     MMJ    c                  L    d } t        | t        j                        D ]  }|` y)z
    Give the backport primacy for discovering path-based distributions
    by monkey-patching the stdlib O_O.

    See #91 for more background for rationale on this sketchy
    behavior.
    c                 >    t        | dd       dk(  xr t        | d      S )N
__module___frozen_importlib_externalfind_distributions)getattrhasattr)finders    r   matchesz&disable_stdlib_finder.<locals>.matches%   s0    L$
)* T.5f>R.S	Tr   N)filterr   r   r   )r   r   s     r   r
   r
      s*    T
 #--0 &%&r   c                   $    e Zd ZdZed        ZeZy)r   zj
    A "Finder" (aka "MetaClassFinder") that never finds any modules,
    but may find distributions.
    c                       y )N )argskwargss     r   	find_speczNullFinder.find_spec4   s    r   N)__name__r   __qualname____doc__staticmethodr   find_moduler   r   r   r   r   .   s"    
   Kr   r   c                 :    t        j                         dk(  }| |z   S )zY
    Adjust for variable stacklevel on partial under PyPy.

    Workaround for #327.
    PyPy)platformpython_implementation)valis_pypys     r   pypy_partialr)   A   s!     ,,.&8G=r   )r   r%   __all__typingr   ImportErrortyping_extensionsr   r
   r   r)   r   r   r   <module>r.      sH    
  0+
&$ &o  +*+s   ( 66