
    ii;                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  \R"                  " \R$                  5      r\S-  r/ r\R,                   H@  r\R"                  " \5      r \R1                  \R3                  \R$                  5      5        MB     \R7                  S	 S
S9   " S S5      r\R:                  r\R>                  r  " S S\5      rSSS jjr!S r"SSS jjr#SS S jjr$\RJ                  (       a  \RL                  " SS5      r'O\RL                  " S5      r'S!S"S jjr(S#S jr)S r*\*" 5       r+S r,\," 5       r-g! \ a     M  f = f)$a  
Additional helper methods for working specifically with Anaconda distributions are found at
:mod:`PyInstaller.utils.hooks.conda_support<PyInstaller.utils.hooks.conda>`
which is designed to mimic (albeit loosely) the `importlib.metadata`_ package. These functions find and parse the
distribution metadata from json files located in the ``conda-meta`` directory.

.. versionadded:: 4.2.0

This module is available only if run inside a Conda environment. Usage of this module should therefore be wrapped in
a conditional clause::

    from PyInstaller.compat import is_pure_conda

    if is_pure_conda:
        from PyInstaller.utils.hooks import conda_support

        # Code goes here. e.g.
        binaries = conda_support.collect_dynamic_libs("numpy")
        ...

Packages are all referenced by the *distribution name* you use to install it, rather than the *package name* you import
it with. I.e., use ``distribution("pillow")`` instead of ``distribution("PIL")`` or use ``package_distribution("PIL")``.
    )annotationsN)IterableList)PackagePath)compat)loggerz
conda-metac                ,    [        U R                  5      $ N)lenparts)ps    JC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller/utils/hooks/conda.py<lambda>r   >   s    s177|    T)keyreversec                  \    \ rS rSrSrSS jrS rS rS r\	SS j5       r
\	SS j5       rS	rg
)DistributionA   ao  
A bucket class representation of a Conda distribution.

This bucket exports the following attributes:

:ivar name: The distribution's name.
:ivar version: Its version.
:ivar files: All filenames as :meth:`PackagePath`\ s included with this distribution.
:ivar dependencies: Names of other distributions that this distribution depends on (with version constraints
                    removed).
:ivar packages: Names of importable packages included in this distribution.

This class is not intended to be constructed directly by users. Rather use :meth:`distribution` or
:meth:`package_distribution` to provide one for you.
c                ^    [         R                  " U5      U l        U R                  R                  5       (       d   e [        R                  " U R                  R                  5       5      U l        U R                  S   U l        U R                  S   U l        U R                  S    Vs/ s H  n[        U5      PM     snU l        U R!                  5       U l        U R%                  5       U l        g ! [        [
        4 a$    [	        SR                  [        U5      5      5      ef = fs  snf )Nz_Distribution requires a path to a conda-meta json. Perhaps you want `distribution({})` instead?nameversionfiles)pathlibPath
_json_pathexists	TypeErrorAssertionErrorformatreprjsonloads	read_textrawr   r   r   r   _init_dependenciesdependencies_init_package_namespackages)self	json_pathis      r   __init__Distribution.__init__Q   s    	%ll95DO??))++++ DOO$=$=$?@ &)	 HHY/.2hhw.?@.?k!n.?@
 335002 >* 	..4fT)_.E 	 As   <C3 +D*34D'c                v    SR                  [        U 5      R                  U R                  U R                  5      $ )Nz{}(name="{}", packages={}))r    type__name__r   r)   r*   s    r   __repr__Distribution.__repr__e   s,    -44T$Z5H5H$))UYUbUbccr   c                x    / nU R                   S    H$  nUR                  SS9tp4UR                  U5        M&     U$ )z
Read dependencies from ``self.raw["depends"]``.

:return: Dependent distribution names.
:rtype: list

The names in ``self.raw["depends"]`` come with extra version constraint information which must be stripped.
depends   )maxsplit)r%   splitappend)r*   r'   
dependencyr   version_constraintss        r   r&   Distribution._init_dependenciesh   sH     ((9-J)3)9)91)9)E&D% . r   c                r    / nU R                    H$  n[        U5      nUc  M  UR                  U5        M&     U$ )z
Search ``self.files`` for package names shipped by this distribution.

:return: Package names.
:rtype: list

These are names you would ``import`` rather than names you would install.
)r   _get_package_namer:   )r*   r)   filepackages       r   r(    Distribution._init_package_namesy   s:     JJD'-G"(  r   c                \    U[         ;   a	  [         U   $ [        SR                  U5      5      e)z
Get distribution information for a given distribution **name** (i.e., something you would ``conda install``).

:rtype: :class:`Distribution`
zIDistribution {} is either not installed or was not installed using Conda.)distributionsModuleNotFoundErrorr    clsr   s     r   	from_nameDistribution.from_name   s3     =  &&!W^^_cd
 	
r   c                \    U[         ;   a	  [         U   $ [        SR                  U5      5      e)a|  
Get distribution information for a **package** (i.e., something you would import).

:rtype: :class:`Distribution`

For example, the package ``pkg_resources`` belongs to the distribution ``setuptools``, which contains three
packages.

>>> package_distribution("pkg_resources")
Distribution(name="setuptools",
             packages=['easy_install', 'pkg_resources', 'setuptools'])
zDPackage {} is either not installed or was not installed using Conda.)distributions_by_packagerE   r    rF   s     r   from_package_nameDistribution.from_package_name   s0     +++D11!"h"o"opt"uvvr   )r   r'   r   r   r)   r%   r   N)r+   str)r   rN   )r1   
__module____qualname____firstlineno____doc__r-   r3   r&   r(   classmethodrH   rL   __static_attributes__ r   r   r   r   A   sF    3(d"  

 

 w wr   r   c                      \ rS rSrSrS rSrg)r      z
A filename relative to Conda's root (``sys.prefix``).

This class inherits from :class:`pathlib.PurePosixPath` even on non-Posix OSs. To convert to a :class:`pathlib.Path`
pointing to the real file, use the :meth:`locate` method.
c                P    [         R                  " [        R                  5      U -  $ )zO
Return a path-like object for this path pointing to the file's true location.
)r   r   sysprefixr2   s    r   locatePackagePath.locate   s     ||CJJ'$..r   rU   N)r1   rO   rP   rQ   rR   r[   rT   rU   r   r   r   r      s    /r   r   c                   Ub  [        U5      nSSKJn  0 nU" U /5      nU(       a  UR                  5       n [        R                  U5      =X5'   n[        R                  " SXP5        UR                   H,  nXs;   a  M
  Xu:X  a  M  Ub  Xq;   a  M  UR                  U5        M.     U(       a  M  U$ ! [         a    [        R                  " SXP5         M  f = f)ai  
Collect a :class:`Distribution` and all direct and indirect dependencies of that distribution.

Arguments:
    initial:
        Distribution name to collect from.
    excludes:
        Distributions to exclude.
Returns:
    A ``{name: distribution}`` mapping where ``distribution`` is the output of
    :func:`conda_support.distribution(name) <distribution>`.
r   )dequez8Collected Conda distribution '%s', a dependency of '%s'.zConda distribution '%s', dependency of '%s', was not found. If you installed this distribution with pip then you may ignore this warning.)setcollectionsr^   popr   rH   r   debugrE   warningr'   r:   )initialexcludesr^   donenames_to_dor   distribution_names           r   walk_dependency_treerj      s     x= "D	"K
 		(4(>(>t(DDDJLLSUYc "..E}} #(9u% / +4 K' # 	NN`ae 	s   0B/ /!CCc                n    U(       a  [        X5      R                  5       $ [        R                  U 5      /$ r
   )rj   valuesr   rH   )r   r'   re   s      r   _iter_distributionsrm      s-    #D3::<<&&t,--r   c                j    U(       a  [        U 5      R                  $ [        U 5      R                  S   $ )z
List requirements of a distribution.

Arguments:
    name:
        The name of the distribution.
    strip_versions:
        List only their names, not their version constraints.
Returns:
    A list of distribution names.
r6   )rh   r'   r%   )r   strip_versionss     r   requiresrp      s.     D!...!!),,r   c                p    [        XU5       VVs/ s H  o3R                    H  oDPM     M     snn$ s  snnf )a  
List all files belonging to a distribution.

Arguments:
    name:
        The name of the distribution.
    dependencies:
        Recursively collect files of dependencies too.
    excludes:
        Distributions to ignore if **dependencies** is true.
Returns:
    All filenames belonging to the given distribution.

With ``dependencies=False``, this is just a shortcut for::

    conda_support.distribution(name).files
)rm   r   )r   r'   re   distr@   s        r   r   r     s3    $ 1XNfNT[e[eSWD[eDNfffs   2Librarybinlibc           	     z   Sn/ n[        XU5       H  n[        R                  " U5      R                  [        :w  a  M-  UR                  5       nUR                  5       (       d  MT  [        U Vs/ s H  oR                  U5      PM     sn5      (       d  M  UR                  [        U5      U45        M     U$ s  snf )av  
Collect DLLs for distribution **name**.

Arguments:
    name:
        The distribution's project-name.
    dest:
        Target destination, defaults to ``'.'``.
    dependencies:
        Recursively collect libs for dependent distributions (recommended).
    excludes:
        Dependent distributions to skip, defaults to ``None``.
Returns:
    List of DLLs in PyInstaller's ``(source, dest)`` format.

This collects libraries only from Conda's shared ``lib`` (Unix) or ``Library/bin`` (Windows) folders. To collect
from inside a distribution's installation use the regular :func:`PyInstaller.utils.hooks.collect_dynamic_libs`.
)z*.dllz*.dylibz*.soz*.so.*)r   r   PurePathparentlib_dirr[   is_fileanymatchr:   rN   )	r   destr'   re   DLL_SUFFIXES_filesr@   resolved_filesuffixs	            r   collect_dynamic_libsr      s    & :LFd(3 D!((G3$$&&lKlF''/lKLLs=)401% 4& M	 Ls   .B8
c                   [         R                  " U 5      n U R                  S:X  a+  U R                  [        R
                  ;   a  U R                  n OU R                  [        R
                  ;  a  g[         Hz  n[        U R                  5      [        UR                  5      S-   :w  a  M4  [        R                  " [        U R                  5      [        U5      5      (       d  Mn  U R                  s  $    g)aQ  
Determine the package name of a Python file in :data:`sys.path`.

Arguments:
    file:
        A Python filename relative to Conda root (sys.prefix).
Returns:
    Package name or None.

This function only considers single file packages e.g. ``foo.py`` or top level ``foo/__init__.py``\ s.
Anything else is ignored (returning ``None``).
r-   Nr7   )r   r   stemr   r   ALL_SUFFIXESrx   PYTHONPATH_PREFIXESr   r   fnmatchrN   )r@   rZ   s     r   r?   r?   N  s     <<D
 yyJ4;;&2E2E#E{{	F//	/
 &tzz?c&,,/!33 ??3t{{+S[9999 &r   c                 t    0 n [         R                  S5       H  n[        U5      nX UR                  '   M     U $ )Nz*.json)CONDA_META_DIRglobr   r   )rD   pathrr   s      r   _init_distributionsr   ~  s:    M##H-D!#'dii  . r   c                 n    0 n [         R                  5        H  nUR                   H  nXU'   M	     M     U $ r
   )rD   rl   r)   )rK   rh   rA   s      r   _init_packagesr     s;    !%,,.#,,G0<W- - / $#r   r
   )rd   rN   re   Iterable[str] | None)F)r   rN   ro   boolreturnz	List[str])FN)r   rN   r'   r   re   zlist | Noner   zList[PackagePath]).TN)r   rN   r}   rN   r'   r   re   r   )r@   r   ).rR   
__future__r   r   r"   r   rY   typingr   r   importlib.metadatar   _PackagePathPyInstallerr   PyInstaller.logr   r   rZ   
CONDA_ROOTr   r   r   _pathr:   relative_to
ValueErrorsortr   rH   rh   rL   package_distributionrj   rm   rp   r   is_winrw   ry   r   r?   r   rD   r   rK   rU   r   r   <module>r      sV  . #    
 ! :  " \\#**%
l*  XXELLE""5#4#4SZZ#@A    3T  Bew ewP %%#55 /, //d.-"g* 
==y%0Gu%G(\"` $%$ *+ m
  s   8*EEE