
    ʨsg                       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	m
Z
 d dlmZ d dlZd dlmZ d dlmZ d dlmZmZmZ d dlmZ d	d
lmZmZ d	dlmZ  G d de      Zej>                  d        Z  G d d      Z! G d d      Z"y)    )annotationsN)Path)mock)path)errors)egg_infomanifest_makerwrite_entries)Distribution   )contextsenvironment)DALSc                      e Zd Zy)EnvironmentN)__name__
__module____qualname__     Q/var/www/html/venv/lib/python3.12/site-packages/setuptools/tests/test_egg_info.pyr   r      s    r   r   c            	   #    K   t        j                  d      5 t              } t        j                  t
        j                         d}t        fd|D              | _        t        t        t        j                  | j                  j                                      t        j                  | j                  d   dt        d| j                  z        ii       |  d d d        y # 1 sw Y   y xY ww)Nzsetuptools-test.)prefix)homelibscriptsdatazegg-basec              3  b   K   | ]&  }|t         j                  j                  |      f ( y w)N)osr   join).0dirnameenv_dirs     r   	<genexpr>zenv.<locals>.<genexpr>"   s%     Ww'277<<#ABWs   ,/r   z.pydistutils.cfgzT
                [egg_info]
                egg-base = %(egg-base)s
                )r   tempdirr   r   chmodstatS_IRWXUdictpathslistmapmkdirvaluesr   buildr   )envsubsr#   s     @r   r0   r0      s     			!3	4 '"
$,,';WRVWW	S399++-./

IIf"D ii	 % 

 
	 	#  s   C5CC) 	C5)C2.C5c                     e Zd Z ed      Zd Zedxd       Zd Zed        Z	d Z
d Zd Zd	 Zd
 Zd ZdydZdj#                  ej&                  j(                        Zdj#                  ej&                  j(                        ZdZ G d d      Zej3                  dddddddddddeee      d         Zd! Zd" Zd# Zd$ Zd% Ze jB                  j3                  d& ed'      d(d)d*f ed+      d(d)df ed,      d(d)d*f ed'      d-d(d.d*f e jD                   ed/      d(d)d*d01      g      d2        Z#e jB                  j3                  d3 ed4      d5d6d7d8d9gg f ed:      d5d6d7d8d9gg f ed;      d5d6d7d8gd9gf ed<      d5d6d7g d8d9gf ed=      d5d6d7d9gd8gf ed>      d(d?d8gd@gf ed,      d(d)dAgg f edB      d-d(d.dAgg f ed4      dCd5d6dDd8d9gg f e jD                  dEd5dFdGdHd6dIdJdKg dLdMgdN1       e jD                   edO      d5dPdQd8gdRgdS1       e jD                   edT      d5d?d8gg dU1      g      dV        Z$e jB                  j3                  d3 edW      d5d6d7g d8d9gf edX      d5d6d7g d8d9gf edY      d5dZd6d[g d\g f ed]      d5dZd6d[g d\g f ed^      d5dZd6d[d8d9gd_gf edY      d(d`d_gd8d9gf eda      dbd5dZd6dcg d\g f e jD                   edd      d5dPdQd8gdRgdS1       e jD                   ede      d5dGdHdfd8dggdhgdi1      g	      dj        Z%dk Z&dl Z'dm Z(dn Z)do Z*dp Z+dq Z,dr Z-ds Z.dt Z/dzdvZ0dw Z1yu){TestEggInfoz
        from setuptools import setup

        setup(
            name='foo',
            py_modules=['hello'],
            entry_points={'console_scripts': ['hi = hello.run']},
            zip_safe=False,
        )
        c                Z    t        j                  | j                  t        d      d       y )NzO
                def run():
                    print('hello')
                )setup.pyzhello.py)r   r/   setup_scriptr   )selfs    r   _create_projectzTestEggInfo._create_project@   s)    

))
 	r   c                    | d   j                  d      d   }t        t        |j                  d      d d       \  }}||fS )Nr    r   .   )splitr,   int)pkg_info_linesversion_strmajorminors       r   _extract_mv_versionzTestEggInfo._extract_mv_versionK   sH    $Q'--c2153 1 1# 6r :;ue|r   c                |   t         j                  j                  |j                  d   d      }t	               }t        |      }|j                          |j                  |       t        |dd      5 }|j                         }ddd       dv sJ d|v sJ d	|v sJ d
}| j                  ||       y# 1 sw Y   0xY w)z
        When the egg_info section is empty or not present, running
        save_version_info should add the settings to the setup.cfg
        in a deterministic order.
        r   	setup.cfgrutf-8encodingN
[egg_info]tag_build =tag_date = 0	tag_buildtag_date)r   r   r    r*   r   r   initialize_optionssave_version_infoopenread_validate_content_order	r7   
tmpdir_cwdr0   	setup_cfgdisteifcontentexpected_orders	            r   +test_egg_info_save_version_info_setup_emptyz7TestEggInfo.test_egg_info_save_version_info_setup_emptyQ   s     GGLL6!2K@	~d^

Y')S73 	qffhG	 w&&&'''(((

 	$$Wn=	 	s   2B22B;c                    dj                  |      }t        j                  t        j                  z  }t        j                  || |      sJ y)zY
        Assert that the strings in expected appear in content
        in order.
        z.*N)r    re	MULTILINEDOTALLsearch)r[   expectedpatternflagss       r   rT   z#TestEggInfo._validate_content_orderk   s:     ))H%ryy(yy'5111r   c                   t         j                  j                  |j                  d   d      }t        j                  |t        d      i       t               }t        |      }|j                          |j                  |       t        |dd      5 }|j                         }ddd       dv sJ d	|v sJ d
|v sJ d}| j                  ||       y# 1 sw Y   0xY w)z
        When running save_version_info on an existing setup.cfg
        with the 'default' values present from a previous run,
        the file should remain unchanged.
        r   rE   zU
            [egg_info]
            tag_build =
            tag_date = 0
            rF   rG   rH   NrJ   rK   rL   rM   )r   r   r    r*   r/   r   r   r   rP   rQ   rR   rS   rT   rU   s	            r   .test_egg_info_save_version_info_setup_defaultsz:TestEggInfo.test_egg_info_save_version_info_setup_defaultsu   s     GGLL6!2K@	

t
 	 ~d^

Y')S73 	qffhG	 w&&&'''(((

 	$$Wn=	 	s   CCc                    | j                          | j                  ||       t        j                  d      }g d}t	        |      |k(  sJ y )Nfoo.egg-info)PKG-INFOSOURCES.txtzdependency_links.txtentry_points.txtznot-zip-safeztop_level.txt)r8   _run_egg_info_commandr   listdirsorted)r7   rV   r0   actualrc   s        r   test_expected_files_producedz(TestEggInfo.test_expected_files_produced   sG    "":s3N+
 f~)))r   c                   t               }t        |      }t        j                  dt	        d            }t        j                  dd       }|5  |5  dd l}d}t        j                  |j                  j                  |      5  |j                          d d d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)	Nzos.utimeTEST)side_effectz+setuptools.command.egg_info.egg_info.mkpath)
return_valr   z,Cannot update time stamp of directory 'None'match)r   r   r   patchOSErrordistutils.errorspytestraisesr   DistutilsFileErrorrun)	r7   rV   r0   rX   rY   utime_patchmkpath_patch	distutilsmsgs	            r   test_handling_utime_errorz%TestEggInfo.test_handling_utime_error   s    ~d^jjIzz9d
  	, 	#ACy//BB#N 		 	 	 		 	 	 	s<   C2B:B.B:C.B73B::C	?CCc                   t        d      }t        d      }t        j                  ||d       t        j                  t
              5 }| j                  ||       d d d        dj                  j                  d   v sJ y # 1 sw Y   'xY w)Nzp
            [metadata]
            name=foo
            version=0.0.1
            license=file:MIT
            zK
            from setuptools import setup

            setup()
            r5   rE   
ValueErrorr   )	r   r   r/   r{   r|   AssertionErrorrm   valueargs)r7   rV   r0   setup_configr6   excs         r   test_license_is_a_stringz$TestEggInfo.test_license_is_a_string   s    
 
 	

$%
 	 ]]>* 	8c&&z37	8
 syy~~a0000	8 	8s   BB
c                    | j                          | j                  ||       t        j                  j	                  d      }t        j                  d       | j                  ||       t        j                  j	                  d      }||k7  sJ y)z9Ensure timestamps are updated when the command is re-run.ri   gMbP?N)r8   rm   r   r   getmtimetimesleep)r7   rV   r0   timestamp_atimestamp_bs        r   test_rebuiltzTestEggInfo.test_rebuilt   sr    "":s3gg&&~6 	

5"":s3gg&&~6k)))r   c                   | j                          t        j                  t        d      ddid       | j	                  ||       t
        j                  j                  dd      }t
        j                  j                  |d      }t        |d	      5 }d
|j                         j                  d      v sJ 	 d d d        y # 1 sw Y   y xY w)Nz:
                recursive-include docs *.rst
            z	usage.rstzRun 'hi')MANIFEST.indocsr;   ri   rk   rG   rH   zdocs/usage.rst

r8   r   r/   r   rm   r   r    rR   rS   r=   )r7   rV   r0   egg_info_dirsources_txtrZ   s         r   test_manifest_template_is_readz*TestEggInfo.test_manifest_template_is_read   s    

 Z	
 		 	"":s3ww||C8ggll<?+0 	<A#qvvx~~d';;;;	< 	< 	<s   $CC
Fc                d    t        d      |rdn|z  }|r|nd}t        j                  ||d       y )Nzi
            from setuptools import setup

            setup(name='foo', zip_safe=False, %s)
             r   )r   r   r/   )r7   requiresuse_setup_cfgr6   r   s        r   _setup_script_with_requiresz'TestEggInfo._setup_script_with_requires   sA    
 !Rh0 $1xb

$%
 	r   zpython_version<'{this_ver}')this_verzpython_version < "{this_ver}"z<=>++c                      e Zd Zed        Zy)TestEggInfo.RequiresTestHelperc                    g }g }| D ]>  }|j                         j                  dd      }|j                  d      j                  d      }t        |      dkD  r)|d   j	                         }t        j                  |      }ni }|d   j	                         }	|D 
cg c]  }
 t        |
      j                  d	i | c}
\  }}}|	|df|	dz   |dffD ]r  \  }}}|j                  |       d	}|j                  d
      r|dd  }t        j                  j                  }|j                  t        j                  |||||             t A t        j                  j                  d||      S c c}
w )Nz

   r   r   r   F_in_setup_cfgTr   z@xfail
   )marksz;requires,use_setup_cfg,expected_requires,install_cmd_kwargs)ids)lstripr=   poplenstripastliteral_evalr   formatappend
startswithr{   markxfailparamparametrize)	test_listformat_dictidlist	argvaluestesttest_paramsname_kwargsvalinstall_cmd_kwargsnameasetup_py_requiressetup_cfg_requiresexpected_requiresid_r   use_cfgr   s                     r   r   z*TestEggInfo.RequiresTestHelper.parametrize  s   FI! "kkm11&!<)ooa066t<{#a'%a...0C),)9)9#)>&)+&"1~++-;FL67NDGNN1[1LH!#57H ,e4O+-?F/ *C7 MM#&E**:6#+AB< & 1 1$$$#-."'< ;;**M +  +Ls   "E+N)r   r   r   staticmethodr   r   r   r   RequiresTestHelperr     s    	%	 
%	r   r   z
        install_requires_deterministic

        install_requires=["wheel>=0.5", "pytest"]

        [options]
        install_requires =
            wheel>=0.5
            pytest

        wheel>=0.5
        pytest
        z
        install_requires_ordered

        install_requires=["pytest>=3.0.2,!=10.9999"]

        [options]
        install_requires =
            pytest>=3.0.2,!=10.9999

        pytest!=10.9999,>=3.0.2
        z
        install_requires_with_marker

        install_requires=["barbazquux;{mismatch_marker}"],

        [options]
        install_requires =
            barbazquux; {mismatch_marker}

        [:{mismatch_marker_alternate}]
        barbazquux
        z
        install_requires_with_extra
        {'cmd': ['egg_info']}

        install_requires=["barbazquux [test]"],

        [options]
        install_requires =
            barbazquux [test]

        barbazquux[test]
        a  
        install_requires_with_extra_and_marker

        install_requires=["barbazquux [test]; {mismatch_marker}"],

        [options]
        install_requires =
            barbazquux [test]; {mismatch_marker}

        [:{mismatch_marker_alternate}]
        barbazquux[test]
        z
        setup_requires_with_markers

        setup_requires=["barbazquux;{mismatch_marker}"],

        [options]
        setup_requires =
            barbazquux; {mismatch_marker}

        z
        extras_require_with_extra
        {'cmd': ['egg_info']}

        extras_require={{"extra": ["barbazquux [test]"]}},

        [options.extras_require]
        extra = barbazquux [test]

        [extra]
        barbazquux[test]
        aF  
        extras_require_with_extra_and_marker_in_req

        extras_require={{"extra": ["barbazquux [test]; {mismatch_marker}"]}},

        [options.extras_require]
        extra =
            barbazquux [test]; {mismatch_marker}

        [extra]

        [extra:{mismatch_marker_alternate}]
        barbazquux[test]
        z
        extras_require_with_marker

        extras_require={{":{mismatch_marker}": ["barbazquux"]}},

        @xfail
        [options.extras_require]
        :{mismatch_marker} = barbazquux

        [:{mismatch_marker}]
        barbazquux
        a(  
        extras_require_with_marker_in_req

        extras_require={{"extra": ["barbazquux; {mismatch_marker}"]}},

        [options.extras_require]
        extra =
            barbazquux; {mismatch_marker}

        [extra]

        [extra:{mismatch_marker_alternate}]
        barbazquux
        z
        extras_require_with_empty_section

        extras_require={{"empty": []}},

        [options.extras_require]
        empty =

        [empty]
        )invalid_markermismatch_markermismatch_marker_alternatec                ,   | j                  ||        | j                  ||fi | t        j                  j	                  dd      }t        j                  j	                  |d      }t        j                  j                  |      r't        |d      5 }	|	j                         }
d d d        nd}

j                         |k(  sJ t        j                  t        j                  j	                  |j                  d   d            g k(  sJ y # 1 sw Y   dxY w)	Nr;   ri   zrequires.txtrG   rH   r   r   barbazquux*)r   rm   r   r   r    existsrR   rS   r   globr*   )r7   rV   r0   r   r   r   r   r   requires_txtfpinstall_requiress              r   test_requireszTestEggInfo.test_requires9  s    | 	((=A""":sI6HIww||C8ww||L.A77>>,'lW5 -#%779 - -  "&&(,====yycii&6FG2MMM- -s   D

Dc                    d}| j                  |       t        j                  t              5  | j	                  ||       ddd       y# 1 sw Y   yxY w)z
        Packages that pass unordered install_requires sequences
        should be rejected as they produce non-deterministic
        builds. See #458.
        z0install_requires={"fake-factory==0.5.2", "pytz"}N)r   r{   r|   r   rm   )r7   rV   r0   reqs       r   *test_install_requires_unordered_disallowedz6TestEggInfo.test_install_requires_unordered_disallowed  sI     A((-]]>* 	8&&z37	8 	8 	8s   A		Ac                l   d}|j                  | j                        }| j                  |       t        j                  t
              5  | j                  ||       d d d        t        j                  t        j                  j                  |j                  d   d            g k(  sJ y # 1 sw Y   OxY w)Nz/extras_require={{":{marker}": ["barbazquux"]}},markerr   r   r   r   r   r{   r|   r   rm   r   r   r   r    r*   r7   rV   r0   tmplr   s        r   'test_extras_require_with_invalid_markerz3TestEggInfo.test_extras_require_with_invalid_marker  s    @kk!4!4k5((-]]>* 	8&&z37	8yycii&6FG2MMM	8 	8   	B**B3c                l   d}|j                  | j                        }| j                  |       t        j                  t
              5  | j                  ||       d d d        t        j                  t        j                  j                  |j                  d   d            g k(  sJ y # 1 sw Y   OxY w)Nz5extras_require={{"extra": ["barbazquux; {marker}"]}},r   r   r   r   r   s        r   .test_extras_require_with_invalid_marker_in_reqz:TestEggInfo.test_extras_require_with_invalid_marker_in_req  s    Fkk!4!4k5((-]]>* 	8&&z37	8yycii&6FG2MMM	8 	8r   c           	     P   | j                  d       t        j                  j                         j	                  |j
                  d         }t        j                  dgt        j                  j                  |j
                  d   t        |      g      d|       t        j                  j                  dd	      }t        t        j                  j                  |d
      d      5 }|j                         j                  d      }d d d        dv sJ d|v sJ y # 1 sw Y   xY w)Nz*extras_require={"foobar": ["barbazquux"]},r   HOMEr   r   r   cmdpypathdata_streamr0   r;   ri   rj   rG   rH   r   zProvides-Extra: foobarMetadata-Version: 2.1r   r   environcopyupdater*   r   run_setup_pypathsepr    strr   rR   rS   r=   r7   rV   r0   r   r   r   r?   s          r   test_provides_extrazTestEggInfo.test_provides_extra  s    (()UV**//#**6" + 
 	  ::??CIIe$4c*o#FG		
 ww||C8"'',,|Z87K 	3rWWY__T2N	3'>999&.888	3 	3s   ' DD%c           	     &   | j                  d       t        j                  j                         j	                  |j
                  d         }t        j                  dgt        j                  j                  |j
                  d   t        |      g      d|       t        j                  j                  dd	      }t        t        j                  j                  |d
      d      5 }|j                         }d d d        dvsJ y # 1 sw Y   xY w)Nz0install_requires=["spam ; python_version<'3.6'"]r   r   r   r   r   r   r;   ri   rj   rG   rH   zProvides-Extra:)r   r   r   r   r   r*   r   r   r   r    r   r   rR   rS   )r7   rV   r0   r   r   r   pkg_info_texts          r   test_doesnt_provides_extraz&TestEggInfo.test_doesnt_provides_extra  s    ((B	
 **//#**6" + 
 	  ::??CIIe$4c*o#FG		
 ww||C8"'',,|Z87K 	&rGGIM	& 555	& 	&s   'DD)fileslicense_in_sourcesz}
                              [metadata]
                              license_file = LICENSE
                              zTest license)rE   LICENSETz
                              [metadata]
                              license_file = INVALID_LICENSE
                              z
                              zexclude LICENSE)rE   r   r   z
                              [metadata]
                              license_file = LICEN[CS]E*
                              glob_pattern)idc           	        | j                          t        j                  |       t        j                  dgt
        j                  j                  |j                  d   t        |      g             t
        j                  j                  dd      }t        |d      j                  d      }|rd	|v sJ y d	|vsJ d
|vsJ y )Nr   r   r   r   r;   ri   rk   rG   rH   r   INVALID_LICENSE)r8   r   r/   r   r   r   r   r    r*   r   r   	read_text)r7   rV   r0   r   r   r   sources_texts          r   test_setup_cfg_license_filez'TestEggInfo.test_setup_cfg_license_file!  s    D 	

5  ::??CIIe$4c*o#FG	
 ww||C8L-8BBGBT,,,L000$L888r   )r   incl_licensesexcl_licensesz
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                              ABC licenseXYZ license)rE   LICENSE-ABCLICENSE-XYZr  r  z
                              [metadata]
                              license_files = LICENSE-ABC, LICENSE-XYZ
                              z
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                              zv
                              [metadata]
                              license_files =
                              z
                              [metadata]
                              license_files = LICENSE-XYZ
                              z
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  INVALID_LICENSE
                              )rE   r  r   r   z~
                              [metadata]
                              license_files = LICENSE
                              zexclude LICENSE-XYZ)rE   r   r  r  r   zABC copyingz
ABC noticezABC authorsLicensezInvalid license)rE   r  COPYING-ABC
NOTICE-ABCAUTHORS-ABCLICENCE-XYZr   INVALID-LICENSE)r  r  r  r	  r
  r   r  default_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE*
                              z
XYZ notice)rE   r  
NOTICE-XYZr  no_default_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  LICENSE*
                              files_only_added_oncec           	     4   | j                          t        j                  |       t        j                  dgt
        j                  j                  |j                  d   t        |      g             t
        j                  j                  dd      }t        |d      j                  d      }|j                         D cg c]  }|j                          }	}|D ]  }
|	j                  |
      d	k(  rJ  |D ]  }
|	j                  |
      d
k(  rJ  y c c}w Nr   r   r   r;   ri   rk   rG   rH   r   r   r8   r   r/   r   r   r   r   r    r*   r   r   r   
splitlinesr   countr7   rV   r0   r   r   r  r   r   linesources_lineslfs              r   test_setup_cfg_license_filesz(TestEggInfo.test_setup_cfg_license_filesu  s    D 	

5  ::??CIIe$4c*o#FG	
 ww||C8L-8BBGBT2>2I2I2KL$LL 	0B &&r*a///	0   	0B &&r*a///	0 M   Dz
                              [metadata]
                              license_file =
                              license_files =
                              z
                              [metadata]
                              license_file =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                              a  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              zPQR license)rE   r  LICENSE-PQRr  )r  r  r  a9  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              z
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                              r  )rE   r  a  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                LICENSE-PQR
                                LICENSE-XYZ
                              z'exclude LICENSE-ABC
exclude LICENSE-PQR)rE   r   r  r  r  z~
                              [metadata]
                              license_file = LICENSE*
                              z
                              [metadata]
                              license_file = LICENSE*
                              license_files =
                                NOTICE*
                              )rE   r  r  r	  r  r	  combined_glob_patterrnsc           	     4   | j                          t        j                  |       t        j                  dgt
        j                  j                  |j                  d   t        |      g             t
        j                  j                  dd      }t        |d      j                  d      }|j                         D cg c]  }|j                          }	}|D ]  }
|	j                  |
      d	k(  rJ  |D ]  }
|	j                  |
      d
k(  rJ  y c c}w r  r  r  s              r   )test_setup_cfg_license_file_license_filesz5TestEggInfo.test_setup_cfg_license_file_license_filesI  s    L 	

5  ::??CIIe$4c*o#FG	
 ww||C8L-8BBGBT2>2I2I2KL$LL 	0B &&r*a///	0   	0B &&r*a///	0 Mr  c           	        | j                          t        j                  t        d      ddddd       t	        j
                  dgt        j                  j                  |j                  d   t        |      g      	       t        j                  j                  d
d      }t        t        j                  j                  |d      d      5 }|j                         j                  d      }ddd       D cg c]  }|j                  d      s| }}d|d   k(  sJ d|dd v sJ d|dd v sJ y# 1 sw Y   GxY wc c}w )zCAll matched license files should have a corresponding License-File.z
                              [metadata]
                              license_files =
                                  NOTICE*
                                  LICENSE*
                              r  r  includedznot include)rE   r  r  NOTICEIGNOREr   r   r   r;   ri   rj   rG   rH   r   NzLicense-File:zLicense-File: NOTICEr   zLicense-File: LICENSE-ABCr   zLicense-File: LICENSE-XYZ)r8   r   r/   r   r   r   r   r   r    r*   r   rR   rS   r=   r   )r7   rV   r0   r   r   r?   r  license_file_liness           r   test_license_file_attr_pkg_infoz+TestEggInfo.test_license_file_attr_pkg_info  s9   

" )( #
 	 	  ::??CIIe$4c*o#FG	
 ww||C8"'',,|Z87K 	3rWWY__T2N	3 ,
t/OD
 
 &);A)>>>>*.@.DDDD*.@.DDDD	3 	3
s    D39D?D?3D<c           	        | j                  d       t        j                  dgt        j                  j                  |j                  d   t        |      g      d       t        j                  j                  dd      }t        t        j                  j                  |d      d	
      5 }|j                         j                  d      }ddd       | j                        dk(  sJ y# 1 sw Y    xY w)z5Make sure latest metadata version is used by default.r   r   r   r   r   r   r   r;   ri   rj   rG   rH   r   N)r<   r   )r   r   r   r   r   r    r*   r   r   rR   rS   r=   rC   r7   rV   r0   r   r   r?   s         r   test_metadata_versionz!TestEggInfo.test_metadata_version$  s    ((,  ::??CIIe$4c*o#FG	

 ww||C8"'',,|Z87K 	3rWWY__T2N	3 ''76AAA	3 	3s   + C**C3c           	     T   | j                  d       t        j                  j                         j	                  |j
                  d         }t        j                  dgt        j                  j                  |j
                  d   t        |      g      d|       t        j                  j                  dd	      }t        t        j                  j                  |d
      d      5 }|j                         j                  d      }d d d        d}|v sJ d|v sJ y # 1 sw Y   xY w)Nz.long_description_content_type='text/markdown',r   r   r   r   r   r   r;   ri   rj   rG   rH   r   z'Description-Content-Type: text/markdownr   r   r7   rV   r0   r   r   r   r?   expected_lines           r   "test_long_description_content_typez.TestEggInfo.test_long_description_content_type2  s     	((@	
 **//#**6" + 
 	  ::??CIIe$4c*o#FG		
 ww||C8"'',,|Z87K 	3rWWY__T2N	3A...&.888		3 	3s   ' DD'c           	         | j                  d       t        j                  dgt        j                  j                  |j                  d   t        |      g      d       t        j                  j                  dd      }t        t        j                  j                  |d      d	
      5 }|j                         j                  d      }d d d        dv sJ d|d   k(  sJ ||j                  d      d  }d|v sJ d|v sJ y # 1 sw Y   :xY w)Nzqlong_description='This is a long description\nover multiple lines',long_description_content_type='text/markdown',r   r   r   r&  r;   ri   rj   rG   rH   r   r   r   zThis is a long descriptionzover multiple lines)r   r   r   r   r   r    r*   r   r   rR   rS   r=   index)r7   rV   r0   r   r   r?   long_desc_liness          r   test_long_descriptionz!TestEggInfo.test_long_descriptionM  s    
 	((=	
 	  ::??CIIe$4c*o#FG	

 ww||C8"'',,|Z87K 	3rWWY__T2N	3&.888^B''''()=)=b)A)CD+>>>$777	3 	3s   + DDc           	        | j                  d       t        j                  j                         j	                  |j
                  d         }t        j                  dgt        j                  j                  |j
                  d   t        |      g      d|       t        j                  j                  dd	      }t        t        j                  j                  |d
      d      5 }|j                         j                  d      }d d d        d}|v sJ d}||v sJ | j                  |      dk\  sJ y # 1 sw Y   0xY w)Nzproject_urls={
                'Link One': 'https://example.com/one/',
                'Link Two': 'https://example.com/two/',
                },r   r   r   r   r   r   r;   ri   rj   rG   rH   r   z/Project-URL: Link One, https://example.com/one/z/Project-URL: Link Two, https://example.com/two/r   r<   r   r   r   r   r   r*   r   r   r   r    r   r   rR   rS   r=   rC   r*  s           r   test_project_urlszTestEggInfo.test_project_urlsd  s    	((	
 **//#**6" + 
 	  ::??CIIe$4c*o#FG		
 ww||C8"'',,|Z87K 	3rWWY__T2N	3I...I...''76AAA	3 	3s   ' D66D?c           	        | j                  d       t        j                  dgt        j                  j                  |j                  d   t        |      g      d       t        j                  j                  dd      }t        t        j                  j                  |d      d	
      5 }|j                         j                  d      }ddd       dv sJ y# 1 sw Y   xY w)zTest single line license.zlicense='MIT',r   r   r   r&  r;   ri   rj   rG   rH   r   NzLicense: MITr   r   r   r   r   r    r*   r   r   rR   rS   r=   r'  s         r   test_licensezTestEggInfo.test_license  s    (()9:  ::??CIIe$4c*o#FG	

 ww||C8"'',,|Z87K 	3rWWY__T2N	3///	3 	3s   + CC#c           	        | j                  d       t        j                  dgt        j                  j                  |j                  d   t        |      g      d       t        j                  j                  dd      }t        t        j                  j                  |d      d	
      5 }|j                         j                  d      }ddd       dv sJ d|v sJ ddj                  |      v sJ y# 1 sw Y   +xY w)z:Test license is escaped correctly if longer than one line.z<license='This is a long license text \nover multiple lines',r   r   r   r&  r;   ri   rj   rG   rH   r   Nz%License: This is a long license text z        over multiple linesztext 
        over multipler7  r'  s         r   test_license_escapezTestEggInfo.test_license_escape  s    ((K	
 	  ::??CIIe$4c*o#FG	

 ww||C8"'',,|Z87K 	3rWWY__T2N	3 7.HHH,>>>->1JJJJ	3 	3s   + C55C>c           	     p   | j                  d       t        j                  j                         j	                  |j
                  d         }t        j                  dgt        j                  j                  |j
                  d   t        |      g      d|       t        j                  j                  dd	      }t        t        j                  j                  |d
      d      5 }|j                         j                  d      }d d d        dv sJ | j                  |      dk\  sJ y # 1 sw Y   &xY w)Nzpython_requires='>=2.7.12',r   r   r   r   r   r   r;   ri   rj   rG   rH   r   zRequires-Python: >=2.7.12r3  r4  r   s          r   test_python_requires_egg_infoz)TestEggInfo.test_python_requires_egg_info  s    (()JK**//#**6" + 
 	  ::??CIIe$4c*o#FG		
 ww||C8"'',,|Z87K 	3rWWY__T2N	3*n<<<''76AAA	3 	3s   ' D,,D5c                H    ddg}|D ]  }t        j                  |      rJ  y )Nz:standard file not found: should have one of foo.py, bar.pyz"standard file 'setup.py' not found)r	   _should_suppress_warning)r7   fixturesr   s      r   'test_manifest_maker_warning_suppressionz3TestEggInfo.test_manifest_maker_warning_suppression  s6    H0

  	@C!::3???	@r   c                   | j                          t        ddd      }d|_        t        |      }|j	                          |j                          d|j                  j                  v sJ t        |j                  dz   d      5 }|j                         j                  d	      }d|v sJ 	 d d d        y # 1 sw Y   y xY w)
Nfoo0.0.1r   versionznon_setup.pyr5   z/SOURCES.txtrG   rH   r   )r8   r   script_namer   finalize_optionsr~   filelistr   rR   rS   r=   )r7   rV   rX   egg_info_instancerZ   sourcess         r   test_egg_info_includes_setup_pyz+TestEggInfo.test_egg_info_includes_setup_py  s    Uw?@)$TN**,.77=====#,,~=P 	)TUffhnnT*G(((	) 	) 	)s   &B55B>Nc           	     J   t         j                  j                         j                  |j                  d         }|dg}t        j                  |t         j                  j                  |j                  d   t        |      g      d|      \  }}|rJ |       |r||v sJ y y )Nr   r   r   r   r   r   )
r   r   r   r   r*   r   r   r   r    r   )r7   rV   r0   r   outputr   coder   s           r   rm   z!TestEggInfo._run_egg_info_command  s    **//#**6" + 
 ;C !--::??CIIe$4c*o#FG	

d xT>!> r   c                   | j                          t        j                  dt        d      i       | j	                  ||       t
        j                  j                  dd      }t        t
        j                  j                  |d      d      5 }|j                         j                  d      }d d d        d	v sJ y # 1 sw Y   xY w)
NrE   z
                              [egg_info]
                              tag_build = dev
                              tag_date = 0
                              tag_svn_revision = 0
                              r;   ri   rj   rG   rH   r   zVersion: 0.0.0.dev0r   r'  s         r   test_egg_info_tag_only_oncez'TestEggInfo.test_egg_info_tag_only_once  s    

"	
 		 	"":s3ww||C8"'',,|Z87K 	3rWWY__T2N	3$666	3 	3s    B==C)r?   z	list[str]returnztuple[int, int])F)NN)2r   r   r   r   r6   r8   r   rC   r]   rT   rg   rq   r   r   r   r   r   r   sysversion_inforA   r   r   r   r   r   r   r   r   r   r   r   r{   r   r   r   r  r  r$  r(  r,  r1  r5  r8  r:  r<  r@  rK  rm   rP  r   r   r   r3   r3   2   s   		L	  
>4 2 2!>F* 1B*<$ 4::!!'' ; O !@ F F!!'' !G ! N' 'R ##	
												 &'";g $ TjNkTjN*	8NN9"6$ [[' "&""  .  "&""  .  "&""  . 	 "&"" $5-	  FLL!%""  . !a=	
@B9C@B9& [[3 "&"" $1#0 .$ "&"" $1#0	 .  "&"" $1#0
 " "&"" $1#0	 .  "&"" $1#0	   "&"" $2
 "#" "&""  . 
 "&"" $5-	   "&"" $9#0#0 .!$ FLL!##0#0".#0#0('8	 ##*+. FLL!%"" $1".
 -  FLL!%"" $1
 *W{	
~~0~~0* [[3 "&"" $1#0
 ." "&"" $1#0 .& "&"" $1#0#0 >!( "&"	" $1#0#0  >%, "&"" $1#0#0 .!( "&"" $2 .& "&"" $N#0#0#0  >%( FLL!%"" $1".	 - FLL!%"" $1".#0 -,![_	
bF0GbF0*!EFB968.B@0K$B"@)"&7r   r3   c                      e Zd Zd Zd Zy)TestWriteEntriesc                "   t        ddd      }ddi|_        |j                  d      }d}t        j                  t
        j                  |      5 }t        |dd	       d
|j                  j                  d   v sJ 	 d d d        y # 1 sw Y   y xY w)NrB  rC  rD  zfoo = invalid-identifier:foor   z(Problems to parse .*invalid-identifier.*rv   entry_pointsrl   z#ensure entry-point follows the specr   )
r   rW  get_command_objr{   r|   r   OptionErrorr
   r   r   )r7   rV   r0   rX   r   expected_msgexs          r   test_invalid_entry_pointz)TestWriteEntries.test_invalid_entry_point  s    Uw?@"$BC"":.B]]6--\B 	Mb#~/AB8BHHMM!<LLLL	M 	M 	Ms   +BBc                    t        ddd      }ddgd|_        |j                  d      }t        |dd	       t	        d	      j                  d
      }d|v sJ d|v sJ y )NrB  rC  rD  zfoo = bar:bazzfaa = bor:boz)abcdefr   rW  rl   rG   rH   z[abc]
foo = bar:baz
z[def]
faa = bor:boz
)r   rW  rX  r
   r   r   )r7   rV   r0   rX   r   r[   s         r   test_valid_entry_pointz'TestWriteEntries.test_valid_entry_point  sx    Uw?@"#$
 "":.c>+=>)*44g4F'7222'7222r   N)r   r   r   r\  r`  r   r   r   rU  rU    s    M
3r   rU  )#
__future__r   r   r   r   r_   r'   rR  r   pathlibr   unittestr   r{   jaracor   
setuptoolsr   setuptools.command.egg_infor   r	   r
   setuptools.distr   r   r   r   textwrapr   r   r   fixturer0   r3   rU  r   r   r   <module>rj     sv    " 
  	 	  
       O O ( # 	# 	  *|7 |7~%3 3r   