
    ϶vg;                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ d dlZd dlZd dlmZmZmZ d dlZd dlZ G d de          Z G d d          Z G d	 d
          Zd Zd Zd Zej                            dddefddefg          ej                            ej        dd         dk    oej        j         dk    d          d                         Z!ej                            ej        dd         dk    oej        j         dk    d          d             Z"ej                            dddg          d             Z#d Z$ G d d           Z%dS )!    )annotationsN)mock)DistInfoDistributionDistributionEggInfoDistributionc                      e Zd Zd ZdS )
EggRemoverc                    | t           j        v rt           j                            |            t          j                            |           rt          j        |            d S d S N)syspathremoveosexists)selfs    c/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/pkg_resources/tests/test_pkg_resources.py__call__zEggRemover.__call__   sT    38HOOD!!!7>>$ 	IdOOOOO	 	    N)__name__
__module____qualname__r    r   r   r	   r	      s#            r   r	   c                      e Zd ZU g Zded<    ej        dddddd          Z	 ed	             Zed
             Z	d Z
d ZdS )TestZipProviderzlist[EggRemover]
finalizersi              r   c                   t          j        dd          }t          j        |d          }t          j                    }d|_        | j                                        |_        |	                    |d           t          j                    }d|_        | j                                        |_        |	                    |d           t          j                    }d	|_        | j                                        |_        |	                    |d
           t          j                    }d|_        | j                                        |_        |	                    |d           |
                                 |
                                 t          j                            |j                   t          j                            |j        d          }t          j                            |           | j                            t%          |                     | j                            t%          |j                             dS )z'create a zip egg and add it to sys.pathz.eggF)suffixdeletewmod.pyzx = 3
data.dathello, world!zsubdir/mod2.pyzx = 6
zsubdir/data2.datzgoodbye, world!subdirN)tempfileNamedTemporaryFilezipfileZipFileZipInfofilenameref_time	timetuple	date_timewritestrcloser   r   appendnamer   joinr   r	   )clseggzip_eggzip_infor'   s        r   setup_classzTestZipProvider.setup_class%   s    )FFF/#s++?$$$ \33559---?$$& \3355?333?$$, \33559---?$$. \3355#4555		!!!ch11j00111j2233333r   c                .    | j         D ]} |             d S r   )r   )r6   	finalizers     r   teardown_classzTestZipProvider.teardown_classC   s*     	 	IIKKKK	 	r   c                   dd l }t          j        |          }g d}t          |                    d                    |k    sJ ddg}t          |                    d                    |k    sJ t          |                    d                    |k    sJ |                    d          g k    sJ |                    d	          g k    sJ dd l}t          j        |          }t          |                    d                    |k    sJ |                    d          g k    sJ |                    d          g k    sJ d S )
Nr   )r%   r$   r'    z	data2.datzmod2.pyr'   zsubdir/nonexistentznonexistent/)modpkg_resourcesZipProvidersortedresource_listdirmod2)r   rA   zpexpected_rootexpected_subdirrF   zp2s          r   test_resource_listdirz%TestZipProvider.test_resource_listdirH   sg   


&s++888b))"--..-????&	2b))(3344GGGGb)))4455HHHH""=11R7777"">22b8888'--c**2..//?BBBB##H--3333##I.."444444r   c                   ddl }t          j                    }t          j        |          }|                    |d          }t
          j                            t          j        |          j	                  }|| j
        k    sJ t          |dd          }|                    d           |                                 | j
                                        }t          j        |||f           |                    |d          }t          |d          5 }|                                dk    sJ 	 ddd           n# 1 swxY w Y   |                                 dS )	a  
        If a previous call to get_resource_filename has saved the file, but
        the file has been subsequently mutated with different file of the
        same size and modification time, it should not be overwritten on a
        subsequent call to get_resource_filename.
        r   Nr%   r#   zutf-8)encodingzhello, world?r&   )rA   rB   ResourceManagerrC   get_resource_filenamedatetimefromtimestampr   statst_mtimer.   openwriter2   	timestamputimereadcleanup_resources)r   rA   managerrG   r-   actualftss           r   )test_resource_filename_rewrites_on_changez9TestZipProvider.test_resource_filename_rewrites_on_change`   s    	


/11&s++++GZ@@"001B1B1KLL&&&&3111	   				]$$&&
B8$$$++GZ@@(W--- 	/6688.....	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/!!#####s   D??EEN)r   r   r   r   __annotations__rP   r.   classmethodr:   r=   rK   r^   r   r   r   r   r      s         #%J%%%% x q"b"a88H.4 4 [4:   [5 5 50$ $ $ $ $r   r   c                  "    e Zd Zd Zd Z	 d ZdS )TestResourceManagerc                    t          j                    }|                    d          }t          t	          |                    }d|z   }t          |t                    s
J |            d S )Nfooz%Unexpected type from get_cache_path: )rB   rN   get_cache_pathstrtype
isinstance)r   mgrr   type_messages        r   test_get_cache_pathz'TestResourceManager.test_get_cache_pathz   sb    +--!!%((DJJ9EA$$$--g-----r   c                   t           j        ffd	g _        t          j                    }|                    t          |                     t          j                            d          }t          j
                            t           d          5  |                    |           d d d            n# 1 swxY w Y   j        }t          |          dk    sJ |d                             t          j                  dd          dd	gk    sJ |d
                             t          j                  dd          dgk    sJ d S )Nc                ~    j                             |             ||           }|st          j        |            |S r   )dirnamesr3   r   makedirs)dirnameunpatched_isdirwas_dirpatched_isdirs      r   rt   zCTestResourceManager.test_get_cache_path_race.<locals>.patched_isdir   sF    "))'222%og..G %G$$$Nr   )rd   barbazisdir)new   r   rd   ru      )rB   rw   ro   rN   set_extraction_pathrf   r   sepr5   r   patchobjectre   lensplit)r   tmpdirri   archive_namecalled_dirnamesrt   s        @r   test_get_cache_path_racez,TestResourceManager.test_get_cache_path_race   s   3@3F 	 	 	 	 	 	 "$ +--F,,,v{{#899Z}g=II 	- 	-|,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- (0?##q((((q!''//4FFFFq!''//4??????s   B77B;>B;c                v    d}t           j        dd                    |          g}t          j        |           dS )z
        In a separate Python environment, import pkg_resources and assert
        that action doesn't cause setuptools to be imported.
        )zimport pkg_resourcesz
import syszAassert "setuptools" not in sys.modules, "setuptools was imported"z-cz; N)r   
executabler5   
subprocess
check_call)r   linescmds      r   test_setuptools_not_importedz0TestResourceManager.test_setuptools_not_imported   s<    


 ~tTYYu%5%56c"""""r   N)r   r   r   rl   r   r   r   r   r   rb   rb   y   sI        . . .@ @ @8# # # # #r   rb   c                0   t           j                            |           }t          j        |           t	          | d          5 }|                    |           ddd           n# 1 swxY w Y   t          t          j        |                    }|\  }|S )a  
    Make a test Distribution object, and return it.

    :param metadata_path: the path to the metadata file that should be
        created. This should be inside a distribution directory that should
        also be created. For example, an argument value might end with
        "<project>.dist-info/METADATA".
    :param metadata: the desired contents of the metadata file, as bytes.
    wbN)	r   r   rq   mkdirrT   rU   listrB   distributions_from_metadata)metadata_pathmetadatadist_dirr\   distsdists         r   make_test_distributionr      s     w}--HHX	mT	"	" a	              :8DDEEEGTKs   A&&A*-A*c                   d}t           j                            t          |           d|          }d                    d          }t          ||          }t          j        t                    5 }|	                    |           ddd           n# 1 swxY w Y   |j
        }t          |          }d}||v sJ d                    |                      |                    |          sJ d                    |                      dS )	zI
    Test a metadata file with bytes that can't be decoded as utf-8.
    METADATAzfoo.dist-infou   néez
iso-8859-1)r   Nz`codec can't decode byte 0xe9 in position 1: invalid continuation byte in METADATA file at path: z
actual: {})r   r   r5   rf   encoder   pytestraisesUnicodeDecodeErrorget_metadatavalueformatendswith)	r   r-   r   r   r   excinfoexcr[   expecteds	            r   test_get_metadata__bad_utf8r      s;    HGLLVoxHHM}}\**H!-(CCCD	)	*	* $g(###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ -CXXF	?  v|226::??=))FF<+>+>v+F+FFFFFFs   0BBBc                    | |z  }|                                  |                    d                                           t          t	          j        |                    }t          |          dk    sJ |\  }||fS )zN
    Create a distribution directory with no file containing the version.
    ztemp.txtr{   )
ensure_dirr5   ensurer   rB   r   r   )r   basenamer   r   r   s        r   make_distribution_no_versionr      s|      H MM*$$&&&:8DDEEEu::????GT>r   )r!   expected_filenameexpected_dist_typezegg-infozPKG-INFOz	dist-infor   ry   )   r   finalz/https://github.com/python/cpython/issues/103632reasonc                   d                     |          }t          | |          \  }}d                     |          }t          j                            ||          }t          j        t                    5 }	|j         ddd           n# 1 swxY w Y   t          |	j
                  }
||
v sJ t          ||
f                      |	j
        j        \  }}||v sJ ||v sJ t          ||f                      t          |          |u sJ dS )zI
    Test Distribution.version when the "Version" header is missing.
    zfoo.{}z2Missing 'Version:' header and/or {} file at path: N)r   r   r   r   r5   r   r   
ValueErrorversionrf   r   argsrg   )r   r!   r   r   r   r   r   expected_textr   r   errmsgs               r   !test_distribution_version_missingr      sa   " v&&H1&(CCND(IQQ M GLL+<==M 
z	"	" g               gm

C CmS%9!:!: "ICCCmS%9!:!:::+++++++s   7BBBc                     t          d          } t          j        t                    5 }| j         ddd           n# 1 swxY w Y   |j        j        \  }} d}||k    sJ dS )zl
    Test Distribution.version when the "Version" header is missing and
    the path can't be detected.
    z/fooNzJMissing 'Version:' header and/or PKG-INFO file at path: [could not detect])r   r   r   r   r   r   r   )r   r   r   r   s       r   1test_distribution_version_missing_undetected_pathr     s     D	z	"	" g               "ICT  (??????s   =AAonlyFTc                    | dz  }|                                  t          j        t          |           t          |          |          rJ dS )z5Test path containing a file with dist-info extension.zfoobar.dist-infoN)touchrB   dist_factoryrf   )tmp_pathr   	dist_infos      r   test_dist_info_is_not_dirr   .  sL     --IOO)#h--YNNNNNNNr   c                   t           j        |                     dt          j        d                     t          dz  d          5 }t          j        ddi|           ddd           n# 1 swxY w Y   |                     d	t          j        d
                     fd}t          j        dt          j        |                    5 }t          j	        
                                 t          j	                    ddgk    sJ t          j	        
                                 ddd           n# 1 swxY w Y   |                                 dS )z-Regression test for pkg_resources._macos_verszplatform.mac_ver)r?   r   r?   )return_value
fake.plistr   ProductVersionz11.4Nzos.path.existsTc                "     dz  g|R i |S )Nr   r   )filer   kwargs	orig_openr   s      r   	fake_openz+test_macos_vers_fallback.<locals>.fake_openD  s(    yL0B4BBB6BBBr   zbuiltins.open)side_effect114)builtinsrT   setattrr   Mockplistlibdumpr   rB   _macos_verscache_clearassert_called)monkeypatchr   	fake_filer   mr   s    `   @r   test_macos_vers_fallbackr   6  s   I *DI<,P,P,PQQQ 
h%t	,	, =	'0)<<<= = = = = = = = = = = = = = = ($)*F*F*FGGGC C C C C C 
OTY9%E%E%E	F	F 0!!--///(**tSk9999!--///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 OOs%   A//A36A3AD55D9<D9c                  (   e Zd Zej        d             Zd Zd Zej        	                    dg d          d             Z
ej                            ej                            d          ej                            d          k    d	
          ej        	                    ddg          d                         Zej                            ej        j        dk    d
          ej        	                    dg d          d                         ZdS )TestDeepVersionLookupDistutilsc                B    G d dt                     } |          }                    t          j                   d}t	          fd|D                       |_        t          t          t          j	        |j        
                                                     |S )zq
        Create a package environment, similar to a virtualenv,
        in which packages are installed.
        c                      e Zd ZdS )7TestDeepVersionLookupDistutils.env.<locals>.EnvironmentN)r   r   r   r   r   r   Environmentr   X  s        Dr   r   )homelibscriptsdatazegg-basec              3  @   K   | ]}|t          |z            fV  d S r   )rf   ).0rq   r   s     r   	<genexpr>z5TestDeepVersionLookupDistutils.env.<locals>.<genexpr>^  s5      NNg'3v'7#8#89NNNNNNr   )rf   chmodrR   S_IRWXUdictpathsr   mapr   r   values)r   r   r   envsubss    `   r   r   z"TestDeepVersionLookupDistutils.envQ  s    	 	 	 	 	# 	 	 	 k&!!T\""";NNNNNNNNN	S39++--..///
r   c                P   d}t          d||          }t          j                            |          }t          j        j                            |          }|                                 |j        d         |_        |	                                 |
                                 dS )zj
        Create a foo package installed (distutils-style) to env.paths['lib']
        as version.
        u&   This package has unicode metadata! ❄rd   )r4   r   long_descriptionr   N)r   	distutilsr   r   commandinstall_egg_infoinitialize_optionsr   install_dirfinalize_optionsrun)r   r   r   ldattrsr   iei_cmds          r   create_foo_pkgz-TestDeepVersionLookupDistutils.create_foo_pkgb  s    
 6%2FFF~**511#4EEdKK""$$$!i.  """r   c                    d}|                      ||           t          j                            d          }t          j        |j        d         g                              |          }|j        |k    sJ d S )Nz1.11.0.dev0+2329eaezfoo>=1.9r   )r   rB   Requirementparse
WorkingSetr   findr   )r   r   r   reqr   s        r   #test_version_resolved_from_egg_infozBTestDeepVersionLookupDistutils.test_version_resolved_from_egg_infop  sv    'C))) '--j99'5)9(:;;@@EE|w&&&&&&r   )unnormalized
normalized))rd   rd   )zfoo/rd   )foo/barr  )zfoo/bar/r  c                f    t          j        |          }t          j        |          }||k    sJ dS )zeEnsure the trailing slash is cleaned for path comparison.

        See pypa/setuptools#1519.
        NrB   normalize_pathr   r  r  result_from_unnormalizedresult_from_normalizeds        r    test_normalize_path_trailing_sepz?TestDeepVersionLookupDistutils.test_normalize_path_trailing_sepz  s>     $1#?#M#M !.!=j!I!I'+AAAAAAAr   Aaz%Testing case-insensitive filesystems.r   )z
MiXeD/CasEz
mixed/casec                f    t          j        |          }t          j        |          }||k    sJ dS )z@Ensure mixed case is normalized on case-insensitive filesystems.Nr  r
  s        r   test_normalize_path_normcasez;TestDeepVersionLookupDistutils.test_normalize_path_normcase  s>     $1#?#M#M !.!=j!I!I'+AAAAAAAr   \z5Testing systems using backslashes as path separators.)r  r   ))zforward/slashforward\slash)zforward/slash/r  )zbackward\slash\zbackward\slashc                \    t          j        |          }|                    |          sJ dS )z;Ensure path seps are cleaned on backslash path sep systems.N)rB   r	  r   )r   r  r   results       r   !test_normalize_path_backslash_sepz@TestDeepVersionLookupDistutils.test_normalize_path_backslash_sep  s2     -l;;x(((((((r   N)r   r   r   r   fixturer   r   r  markparametrizer  skipifr   r   normcaser  r~   r  r   r   r   r   r   P  s       ^  ^   ' ' ' [&	
 	
 	
 B B B [
!1!1#!6!666    [&(	
 B B 	 B [
tF    [$	
 	
 	
 ) ) 	 ) ) )r   r   )&
__future__r   r   rP   r   r   rR   r   r   r(   r*   unittestr   r   rB   r   r   r   "distutils.command.install_egg_infor   distutils.distrf   r	   r   rb   r   r   r   r  r  xfailversion_inforeleaselevelr   r   r   r   r   r   r   r   <module>r#     s   " " " " " "   				       



              Q Q Q Q Q Q Q Q Q Q ) ) ) )           W$ W$ W$ W$ W$ W$ W$ W$t3# 3# 3# 3# 3# 3# 3# 3#l  (G G G4  " 9	Z!45	j"67  RaRG#P(8(E(P<   , ,	  ,> RaRG#P(8(E(P<    	 $ %//O O 0/O  4[) [) [) [) [) [) [) [) [) [)r   