Ë
    !åhii;  ã                  ó¤  — d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZ ddlmZ  ej"                  ej$                  «      Zedz  Zg Zej,                  D ]?  Z ej"                  e«      Z	 ej1                  ej3                  ej$                  «      «       ŒA ej7                  d	„ d
¬«        G d„ d«      Zej:                  Zej>                  Z  G d„ de«      Zddd„Z!d„ Z"ddd„Z#dd d„Z$ejJ                  r ejL                  dd«      Z'n ejL                  d«      Z'd!d"d„Z(d#d„Z)d„ Z* e*«       Z+d„ Z, e,«       Z-y# e$ r Y Œìw xY w)$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                ó,   — t        | j                  «      S ©N)ÚlenÚparts)Úps    úIC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/utils/hooks/conda.pyú<lambda>r   >   s   € ¤s¨1¯7©7£|€ ó    T)ÚkeyÚreversec                  óN   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zed
d„«       Z	ed
d„«       Z
y)ÚDistributiona›  
    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                óH  — 	 t        j                  |«      | _        | j                  j                  «       sJ ‚	 t        j                  | j                  j                  «       «      | _        | j                  d   | _        | j                  d   | _        | j                  d   D �cg c]  }t        |«      ‘Œ c}| _        | j!                  «       | _        | j%                  «       | _        y # t        t
        f$ r$ t	        dj                  t        |«      «      «      ‚w xY wc c}w )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__zDistribution.__init__Q   sé   € ð	Ü%Ÿl™l¨9Ó5ˆDŒOØ—?‘?×)Ñ)Ô+Ð+Ñ+ô Ÿ™ D§O¡O×$=Ñ$=Ó$?Ó@ˆŒð Ÿ™ &Ñ)ˆŒ	Ø ŸH™H YÑ/ˆŒØ.2¯h©h°wÑ.?Ö@¨”k !•nÒ@ˆŒ
Ø ×3Ñ3Ó5ˆÔØ×0Ñ0Ó2ˆ�øô œ>Ð*ò 	Üð.ß.4©f´T¸)³_Ó.Eóð ð	üò As   ‚6C) Â$DÃ)3Dc                óv   — dj                  t        | «      j                  | j                  | j                  «      S )Nz{}(name="{}", packages={}))r   ÚtypeÚ__name__r   r(   ©r)   s    r   Ú__repr__zDistribution.__repr__e   s,   € Ø-×4Ñ4´T¸$³Z×5HÑ5HÈ$Ï)É)ÐUY×UbÑUbÓcÐcr   c                ó|   — g }| j                   d   D ]'  }|j                  d¬«      ^}}|j                  |«       Œ) |S )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%   zDistribution._init_dependenciesh   sP   € ð ˆàŸ(™( 9Ñ-ò 	&ˆJà)3×)9Ñ)9À1Ð)9Ó)EÐ&ˆDÐ&Ø×Ñ Õ%ð	&ð Ðr   c                ój   — g }| j                   D ]!  }t        |«      }|€Œ|j                  |«       Œ# |S )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_namer7   )r)   r(   ÚfileÚpackages       r   r'   z Distribution._init_package_namesy   s?   € ð ˆØ—J‘Jò 	)ˆDÜ'¨Ó-ˆGØÑ"Ø—‘ Õ(ð	)ð ˆr   c                óX   — |t         v r	t         |   S t        dj                  |«      «      ‚)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_namezDistribution.from_name‰   s3   € ð ”=Ñ Ü  Ñ&Ð&Ü!ØW×^Ñ^Ð_cÓdó
ð 	
r   c                óX   — |t         v r	t         |   S t        dj                  |«      «      ‚)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_packager@   r   rA   s     r   Úfrom_package_namezDistribution.from_package_name–   s0   € ð Ô+Ñ+Ü+¨DÑ1Ð1Ü!Ð"h×"oÑ"oÐptÓ"uÓvÐvr   N)r*   Ústr)r   rG   )r/   Ú
__module__Ú__qualname__Ú__doc__r,   r1   r%   r'   ÚclassmethodrC   rF   © r   r   r   r   A   sF   „ ñó3ò(dòò"ð  ò

ó ð

ð òwó ñwr   r   c                  ó   — e Zd ZdZd„ Zy)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                óN   — t        j                  t        j                  «      | z  S )z_
        Return a path-like object for this path pointing to the file's true location.
        )r   r   ÚsysÚprefixr0   s    r   ÚlocatezPackagePath.locate´   s   € ô �|‰|œCŸJ™JÓ'¨$Ñ.Ð.r   N)r/   rH   rI   rJ   rQ   rL   r   r   r   r   ­   s   „ ñó/r   r   c                ó„  — |�t        |«      }ddlm} i } || g«      }|ry|j                  «       }	 t        j                  |«      x||<   }t        j                  d|| «       |j                  D ]%  }||v rŒ||k(  rŒ|�||v rŒ|j                  |«       Œ' |rŒy|S # t        $ r t        j                  d|| «       Y ŒŸw xY w)a‘  
    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'.z‰Conda distribution '%s', dependency of '%s', was not found. If you installed this distribution with pip then you may ignore this warning.)ÚsetÚcollectionsrS   Úpopr   rC   r   Údebugr@   Úwarningr&   r7   )ÚinitialÚexcludesrS   ÚdoneÚnames_to_dor   ÚdistributionÚ_names           r   Úwalk_dependency_treer_   »   sî   € ð ÐÜ�x“=ˆõ "Ø€DÙ˜˜	Ó"€Ká
à�‰Ó ˆð		ä(4×(>Ñ(>¸tÓ(DÐDˆD�‰J˜Ü�L‰LÐSÐUYÐ[bÔcð "×.Ñ.ò 	&ˆEØ˜‰}àØ˜Š}ð ØÐ#¨°Ñ(9àØ×Ñ˜uÕ%ð	&ò ð4 €Køô' #ò 	Ü�N‰Nð`ØaeÐgnôñ ð	ús   ²1B Â B?Â>B?c                óf   — |rt        | |«      j                  «       S t        j                  | «      gS r
   )r_   Úvaluesr   rC   )r   r&   rZ   s      r   Ú_iter_distributionsrb   í   s/   € ÙÜ# D¨(Ó3×:Ñ:Ó<Ð<ä×&Ñ& tÓ,Ð-Ð-r   c                ó`   — |rt        | «      j                  S t        | «      j                  d   S )a  
    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.
    r3   )r]   r&   r$   )r   Ústrip_versionss     r   Úrequiresre   ô   s.   € ñ Ü˜DÓ!×.Ñ.Ð.Ü˜Ó×!Ñ! )Ñ,Ð,r   c                ój   — t        | ||«      D ��cg c]  }|j                  D ]  }|‘Œ Œ c}}S c c}}w )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
    )rb   r   )r   r&   rZ   Údistr<   s        r   r   r     s5   € ô$ 1°°|ÀXÓN×f�TÐ[_×[eÑ[eÒfÐSWŠDÐfˆDÓfÐfùÓfs   ‘/ÚLibraryÚbinÚlibc           	     óV  — d}g }t        | ||«      D ]�  }t        j                  |«      j                  t        k7  rŒ*|j                  «       }|j                  «       sŒKt        |D �cg c]  }|j                  |«      ‘Œ c}«      sŒt|j                  t        |«      |f«       Œ‘ |S c c}w )a²  
    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_dirrQ   Úis_fileÚanyÚmatchr7   rG   )	r   Údestr&   rZ   ÚDLL_SUFFIXESÚ_filesr<   Úresolved_fileÚsuffixs	            r   Úcollect_dynamic_libsrw      s¢   € ð& :€LØ€FÜ�d˜L¨(Ó3ò 2ˆô ×Ñ˜DÓ!×(Ñ(¬GÒ3ØàŸ™›ˆØ×$Ñ$Ô&Øä¸lÖK°F�M×'Ñ'¨Õ/ÒKÔLØà�‰”s˜=Ó)¨4Ð0Õ1ð%2ð& €Mùò	 Ls   Á&B&
c                óÌ  — t        j                  | «      } | j                  dk(  r)| j                  t        j
                  v r| j                  } n| j                  t        j
                  vryt        D ]q  }t        | j                  «      t        |j                  «      dz   k7  rŒ2t        j                  t        | j                  «      t        |«      «      sŒe| j                  c S  y)au  
    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,   Nr4   )r   r   Ústemrv   r   ÚALL_SUFFIXESrm   ÚPYTHONPATH_PREFIXESr   r   ÚfnmatchrG   )r<   rP   s     r   r;   r;   N  s¨   € ô �<‰<˜Ó€Dð
 ‡y�y�JÒ 4§;¡;´&×2EÑ2EÑ#EØ�{‰{‰Ø	�‰œF×/Ñ/Ñ	/àô
 &ò ˆÜˆt�z‰z‹?œc &§,¡,Ó/°!Ñ3Ò3àô �?‰?œ3˜tŸ{™{Ó+¬S°«[Õ9Ø—9‘9Òñr   c                 ór   — i } t         j                  d«      D ]  }t        |«      }|| |j                  <   Œ | S )Nz*.json)ÚCONDA_META_DIRÚglobr   r   )r?   Úpathrg   s      r   Ú_init_distributionsr�   ~  sA   € Ø€MÜ×#Ñ# HÓ-ò (ˆÜ˜DÓ!ˆØ#'ˆ�d—i‘iÒ ð(ð Ðr   c                 óh   — i } t         j                  «       D ]  }|j                  D ]  }|| |<   Œ	 Œ | S r
   )r?   ra   r(   )rE   r]   r=   s      r   Ú_init_packagesrƒ   ‰  sH   € Ø!ÐÜ%×,Ñ,Ó.ò =ˆØ#×,Ñ,ò 	=ˆGØ0<Ð$ WÒ-ñ	=ð=ð $Ð#r   r
   )rY   rG   rZ   úIterable[str] | None)F)r   rG   rd   ÚboolÚreturnz	List[str])FN)r   rG   r&   r…   rZ   zlist | Noner†   zList[PackagePath])ú.TN)r   rG   rr   rG   r&   r…   rZ   r„   )r<   r   ).rJ   Ú
__future__r   r|   r!   r   rO   Útypingr   r   Úimportlib.metadatar   Ú_PackagePathÚPyInstallerr   ÚPyInstaller.logr   r   rP   Ú
CONDA_ROOTr~   r{   r€   Ú_pathr7   Úrelative_toÚ
ValueErrorÚsortr   rC   r]   rF   Úpackage_distributionr_   rb   re   r   Úis_winrl   rn   rw   r;   r�   r?   rƒ   rE   rL   r   r   ú<module>r•      sc  ðñõ. #ã Û Û Û 
ß !Ý :å Ý "ð ˆW�\‰\˜#Ÿ*™*Ó%€
Ø˜lÑ*€ð Ð Ø�X‰Xò €EØˆG�L‰L˜Ó€EðØ×"Ñ" 5×#4Ñ#4°S·Z±ZÓ#@ÕAðð × Ñ Ñ3¸TÐ Ô B÷ewñ ewðP ×%Ñ%€Ø#×5Ñ5Ð ô/�,ô /ô/òd.ô-ô"gð* 
‡=‚=Øˆg×Ñ˜y¨%Ó0�Gàˆg×Ñ˜uÓ%€Gô(ó\"ò`ñ $Ó%€ò$ñ *Ó+Ñ øðm
 ò Ùðús   Á8*EÅEÅE