
    ?wg                      8   d 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m	Z	 ddl
mZ ddlZddlmZ dd	lmZmZ ej$                  j&                  Z ed
d      \  Z	 defdefdefdefdefdefdefdefdefdefdefgZdddZddiddidZdddZej4                  d d!fZd"Zej:                  d#        Z ej:                  d$%      d&        Zej$                  jA                  d'e      ej$                  jB                  d(               Z"d) Z#d* Z$d+ Z%d, Z&d- Z'y).a  Integration tests for setuptools that focus on building packages via pip.

The idea behind these tests is not to exhaustively check all the possible
combinations of packages, operating systems, supporting libraries, etc, but
rather check a limited number of popular packages and how they interact with
the exposed public API. This way if any change in API is introduced, we hope to
identify backward compatibility problems before publishing a release.

The number of tested packages is purposefully kept small, to minimise duration
and the associated maintenance cost (changes in the way these packages define
their build process may require changes in the tests).
    N)Enum)glob)md5)urlopen)Requirement   )ArchiverunvLATESTpippytestmypybotocore
kiwisolverbrotlipyyamlcharset-normalizerprotobufrequestscelery)z
Cython<3.0)zmypy>=1.4.1)r   r   PYYAML_FORCE_CYTHON1CHARSET_NORMALIZER_USE_MYPYCyamlzgoogle.protobuf)r   r   -m
virtualenv)z--ignore-installedz--no-build-isolationc                     t        g t        t        | dz               d | j                  d      D        }t	        j
                  dt        j                  j                  |            S )Nz.venvc              3   F   K   | ]  }t        |j                          y w)N)strparent).0ps     j/var/www/horilla/myenv/lib/python3.12/site-packages/setuptools/tests/integration/test_pip_install_sdist.py	<genexpr>zvenv_python.<locals>.<genexpr>f   s     MqS]Ms   !z.venv/*/python*python)path)	r
   
VIRTUALENVr    r   shutilwhichospathsepjoin)tmp_pathpossible_paths     r$   venv_pythonr0   c   sQ    .*.c(W,-./MHMM:K,LMM<<rzz}'EFF    T)autousec              #   B  K   t        j                  dt        |             }t        j                  |d       |j	                  dd       d  t        d       t        d       t        t
        | j                  d             t        d	       t        |d
ddg       y w)NDOWNLOAD_PATHT)exist_ok	USE_MYPYCr   <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~zTemporary directory:*zVirtual environment:r   r   freeze)	r+   getenvr    makedirssetenvprintmapr   r
   )r.   r0   monkeypatchdownload_paths       r$   _preparerA   j   s~     IIos8}=MKK- {C(	 

HI	
 !x}}S!"	
 !dE8,-s   BB)packageversionc                    |ddf}t        | ||      }t        | |      }|r(t        d       t        d|       t        g |d|       t        j                  | i       }t        g |dd|       t        g |dt        ||       t        j                  | |       j                  dd      }	d	|	 d
|	 d}
t        |d|
g       y )Nr   r   r7   zDependencies:installz--force-reinstall-_zimport z; print(getattr(z, '__version__', 0))z-c)	retrieve_sdist
build_depsr=   r
   EXTRA_ENV_VARSgetINSTALL_OPTIONSIMPORT_NAMEreplace)rB   rC   r.   r0   setuptools_wheelvenv_pipsdistdepsenvpkgscripts              r$   test_install_sdistrV   }   s     T5)H7GX6Egu%DLMot$)h)	)D)* 

Wb
)CE(EIE2E4DEF7(7I777= //'7
+
3
3C
=Cse+C50DEFdF#$r1   c                    t        j                  dt        |            }t        | |      }t	        t         j
                  j                  ||  d            D ]   }|d   |k7  st        j                  |       " t         j
                  j                  ||d         }t         j
                  j                  |      st        |d   ||d          |S )z5Either use cached sdist file or download it from PyPIr4   r8   filenameurl
md5_digest)
r+   r:   r    retrieve_pypi_sdist_metadatar   r'   r-   unlinkexistsdownload)rB   rC   r.   r@   distfile	dist_files          r$   rH   rH      s     IIos8}=M'9D RWW\\-G9A?@ 
t#IIdO ]D,<=I77>>)$eil);<r1   c                 &   |t         u r| n|  d| }t        d| d      5 }t        j                  |      }d d d        d   d   rt	        d|  d| d      |d   d	   }|t         u r|d
   |   n|d   }t        d |      \  }|S # 1 sw Y   QxY w)N/zhttps://pypi.org/pypi/z/jsoninfoyankedzRelease for  z was yankedrC   releasesurlsc                     | d   dk(  S )NpackagetyperQ    )ds    r$   <lambda>z.retrieve_pypi_sdist_metadata.<locals>.<lambda>   s    - 0G ; r1   )r   r   jsonload
ValueErrorfilter)rB   rC   id_fmetadatareleaserQ   s          r$   r[   r[      s    &'wiq	,BC	)#e4	5  99Q<  !<y'+FGGvy)G/6&/@hz"7+hvFVG;WEHUL   s   BBc                 F   t        |       5 }|j                         }d d d        t              j                         |k(  sJ t	        |d      5 }|j                  |       d d d        t        j                  j                  |      sJ y # 1 sw Y   oxY w# 1 sw Y   7xY w)Nwb)	r   readr   	hexdigestopenwriter+   r'   r]   )rY   destrZ   rs   datas        r$   r^   r^      s    	 vvx t9 J...	dD	 Q	 77>>$ 
 s   BBBB c                 |   ddl m} t        |      }|j                  t	        |            }|j                  di       j                  dg       }|t        j                  | g       z  }|D ci c]  }t        |      j                  | }}|j                         D 	cg c]  \  }}	|dk7  s|	 c}	}S c c}w c c}	}w )zFind out what are the build dependencies for a package.

    "Manually" install them, since pip will not install build
    deps with `--no-build-isolation`.
    r   )tomllibzbuild-systemrequires
setuptools)
setuptools.compat.py310r   r	   loads_read_pyprojectrK   EXTRA_BUILD_DEPSr   nameitems)
rB   
sdist_filer   archiverd   rR   rl   requirementskr   s
             r$   rI   rI      s     0j!G==12D88NB'++J;D  "--D489qKN''*9L9&,,.D$!Q!|2CADD :Ds   +B3B8+B8c                 2      fd D        }t        |d      S )Nc              3      K   | ]F  }t         j                  j                  j                  |            d k(  rj	                  |       H yw)zpyproject.tomlN)r+   r'   basenameget_nameget_content)r"   memberr   s     r$   r%   z"_read_pyproject.<locals>.<genexpr>   sG      77G,,V459II 	F#s   AA )next)r   contentss   ` r$   r   r      s!    H
 "r1   )(__doc__rn   r+   r)   sysenumr   r   hashlibr   urllib.requestr   r   packaging.requirementsr   helpersr	   r
   markintegration
pytestmarkr   EXAMPLESr   rJ   rM   
executabler(   rL   fixturer0   rA   parametrizeuses_networkrV   rH   r[   r^   rI   r   rk   r1   r$   <module>r      s    	  
    "  . ![[$$
 h	 # FOvV6vv6"v* *  %c*93? ! nndL1
 G G . .$ /:%  ;%0(	 E&r1   