o
    LK&hK                     @  s  U 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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m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 d
dlmZ ddl m!Z! ddl"m#Z# de$fddddddddfddddddddfddddddddfddd d!d"d#d$dffZ%ej&j'd%e%d&d' e%D d(d)d* Z(ej)dd+d,Z*d-d. Z+d/d0 Z,d1d2 Z-d3d4 Z.G d5d6 d6Z/e0d7d8d9d:iie0d8gd;e,d<g d=d9gd>id?e0d@e0dAdBdCe0dDdEedFie0dGdEgfgdHe,d<g d=dEgdIid?e0dJdKedLie0e/dMdJdKgdNgdOe,dPdQdRg d=igid?e0dSdTedUie0dTgdVe,d<dTdRg d=igid?e0dWedXedYdZe0d[d\gd]e,d<dRd^d_d`dadbd[d\gigiid?e0dcdde,d<dRg deiiedfdge0dhdiej1djedkdle0dmdnej1dodpe0dqdrdsdtiedudve0dwdsdxej1dyiedzd{e0d|d}dsd~ieddve0dd8dd9d:iiie0d8gdgde,d<ddRg did8d9dd9gigigid?e0ddd9diie0dgdgde,d<ddRg didd9gigid?e0dd8d:dEedidie0d8gddgfgde,d<g d=d9dGdEgigd>id?fZ2de3d< ej&j'de2dd' e2D d(dd Z4dd Z5dd Z6dd Z7dd Z8dS )zwheel tests    )annotationsN)Any)path	parse_tag)canonicalize_name)PY_MAJORDistributionPathMetadata)Wheel   )tempdir)DALS)get_config_var)get_platformzinvalid.whlz&simplewheel-2.0-1-py2.py3-none-any.whlsimplewheelz2.01zpy2.py3noneany)project_nameversionbuild
py_versionabiplatformz$simple.dist-0.1-py2.py3-none-any.whlzsimple.distz0.1z example_pkg_a-1-py3-none-any.whlexample_pkg_apy3z9PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-manylinux1_x86_64.whlPyQt5z5.9z5.9.1zcp35.cp36.cp37abi3manylinux1_x86_64filenameinfoc                 C     g | ]}|d  qS )r    .0tr$   r$   N/var/www/html/venv/lib/python3.10/site-packages/setuptools/tests/test_wheel.py
<listcomp>Q       r)   )idsc                   sl   t |r!t| t|  W d    d S 1 sw   Y  d S t|   fdd| D |ks4J d S )Nc                   s   i | ]}|t  |qS r$   )getattr)r&   kwr$   r(   
<dictcomp>Y   s    z#test_wheel_info.<locals>.<dictcomp>)inspectisclasspytestraisesr   keysr    r$   r.   r(   test_wheel_infoP   s   


"r6   c                 k  s    dt d| di}| r||  t )}t|| tjtj	dddf|d t

tj|ddd	 V  W d    d S 1 sBw   Y  d S )
Nsetup.pyz
            # -*- coding: utf-8 -*-
            from setuptools import setup
            import setuptools
            setup(**%r)
            utf-8-qbdist_wheelcwddist*.whlr   )r   encodeupdater   r   r   
subprocess
check_callsys
executableglobosjoin)extra_file_defskwargs	file_defs
source_dirr$   r$   r(   build_wheel\   s$   	
"rL   c              
   C  sH   t  }t| D ]\}}}|D ]}|tjtj|| | qq|S N)setrF   walkaddr   rG   relpath)rootcontentsdirpathdirnames	filenamesr!   r$   r$   r(   tree_setu   s    rW   c                   sr   t  }|  D ]/\ }t|trt|}|D ]}t|tr+| fddt|D O }q|tj | qq|S )z8Flatten nested dicts and lists into a full list of pathsc                   s   h | ]	}t j |qS r$   )rF   r   rG   )r&   valnoder$   r(   	<setcomp>   s    zflatten_tree.<locals>.<setcomp>)	rN   items
isinstancedictflatten_treerP   rF   r   rG   )treeoutputrS   elemr$   rY   r(   r_   }   s   

r_   c                 C  s   dd | D S )Nc                 S  s*   h | ]}|j tt td ptddqS )
EXT_SUFFIXSO)r   r   	shlib_ext)formatr   r   r   )r&   xr$   r$   r(   r[      s    z&format_install_tree.<locals>.<setcomp>r$   )r`   r$   r$   r(   format_install_tree   s   rh   c                 C  s   t | }tj|| }|| |d ur)t|}t|}	||	s)J ||	 t	|tj|d}
t
j||
d}|j|ksAJ |j|ksHJ |d u rU|drSJ d S ||d ks`J d S )NEGG-INFO)metadatarequires.txt)r   rF   r   rG   egg_nameinstall_as_eggrh   rW   issubsetr
   r	   from_filenamer   r   has_metadataget_metadatalstrip)r!   install_dirinstall_tree_includesr   r   requires_txtr/   egg_pathinstall_treeexprj   r=   r$   r$   r(   _check_wheel_install   s   
ry   c                   @  s   e Zd Zdd ZdddZdS )	Recordc                 K  s   || _ || _d S rM   _id_fields)selfidrI   r$   r$   r(   __init__   s   
zRecord.__init__returnstrc                 C  s   | j  d| jdS )Nz(**)r{   )r~   r$   r$   r(   __repr__   s   zRecord.__repr__N)r   r   )__name__
__module____qualname__r   r   r$   r$   r$   r(   rz      s    rz   basicfoo__init__.py )packagesfoo-1.0-py{py_version}.egg)PKG-INFORECORDWHEELtop_level.txt)ri   r   r   rJ   setup_kwargsrw   r8   u   Description accentuée)description)r   r   datazdata.txtz.
                Some data...
                data_dir)
data_files)ri   r   	extensionzextension.can  
                #include "Python.h"

                #if PY_MAJOR_VERSION >= 3

                static struct PyModuleDef moduledef = {
                        PyModuleDef_HEAD_INIT,
                        "extension",
                        NULL,
                        0,
                        NULL,
                        NULL,
                        NULL,
                        NULL,
                        NULL
                };

                #define INITERROR return NULL

                PyMODINIT_FUNC PyInit_extension(void)

                #else

                #define INITERROR return

                void initextension(void)

                #endif
                {
                #if PY_MAJOR_VERSION >= 3
                    PyObject *module = PyModule_Create(&moduledef);
                #else
                    PyObject *module = Py_InitModule("extension", NULL);
                #endif
                    if (module == NULL)
                        INITERROR;
                #if PY_MAJOR_VERSION >= 3
                    return module;
                #endif
                }
                zsetuptools.Extension)namesources)ext_modulesz%foo-1.0-py{py_version}-{platform}.eggzextension{shlib_ext}ri   headerzheader.hz
                )headersscriptX
                #/usr/bin/python
                print('hello world!')
                N
                #/bin/sh
                echo 'hello world!'
                	script.py	script.shr   r   scriptsr   r   r   r   r   	requires1zfoobar==2.0)r   r   r   rk   r   z%
            foobar==2.0
            )r   install_requiresrw   ru   	requires2z
        bar
        foo<=2.0; z in sys_platform
        z2
            bar
            foo<=2.0
            )r   r   ru   	requires3z
        bar; z != sys_platform
        )r   r   	requires4z
        foo
        extrazfoobar>3zG
            foo

            [extra]
            foobar>3
            )r   r   extras_requireru   	requires5zfoobar; z != sys_platformz!
            [extra]
            )r   r   ru   requires_ensure_orderz9
        foo
        bar
        baz
        qux
        za
            foobar>3
            barbaz>4
            bazqux>5
            quxzap>6
            z
            foo
            bar
            baz
            qux

            [extra]
            foobar>3
            barbaz>4
            bazqux>5
            quxzap>6
            namespace_packagebarzfoo.bar)namespace_packagesr   z foo-1.0-py{py_version}-nspkg.pth)r   r   r   znamespace_packages.txtr   empty_namespace_packagefoobarz7__import__('pkg_resources').declare_namespace(__name__)data_in_packagez>
                        Some data...
                        )r   r   zfoo/data_dirzfoo/data_dir/data.txt)r   r   ztuple[dict[str, Any], ...]WHEEL_INSTALL_TESTSparamsc                 C  r#   )r   r$   )r&   r   r$   r$   r(   r)   *  r*   c              	   C  s   |  dd}|  dd}|  dg }|  di }|  dd }|  d}|  d	i }|  d
i }td|||||d|-}	t }
t|	|
|||| W d    n1 sTw   Y  W d    d S W d    d S 1 slw   Y  d S )Nr   r   r   1.0r   r   ru   rw   rJ   r   r   r   r   r   rH   r$   )getrL   r   ry   )r   r   r   r   r   ru   rw   rJ   r   r!   rs   r$   r$   r(   test_wheel_install'  s4   
	Pr   c               	   C  s   d} d}t | |d=}t !}|| t| }t|| t||d t| |d  W d    n1 s2w   Y  W d    d S W d    d S 1 sJw   Y  d S )NFoo_Barr   )r   r   )rL   r   replacer   shutilmovery   )r   r   r!   rs   new_filenamer$   r$   r(   test_wheel_install_pep_503E  s,   Pr   c               
   C  s   d} d}|  d| d}t  Q}tj||}t|d  t  &}tt	 t
||d | |d  W d    n1 s<w   Y  W d    n1 sKw   Y  W d    d S W d    d S 1 scw   Y  d S )N
nodistinfor   -z-py2.py3-none-any.whlr/   )r   rF   r   rG   zipfileZipFilecloser3   r4   
ValueErrorry   )r   r   
wheel_namerK   
wheel_pathrs   r$   r$   r(   test_wheel_no_dist_dir[  s"   "r   c                 C  s(   dd }|  d| td sJ d S )Nc                   S  s   dd t dD S )Nc                 S  s   h | ]
}|j |j|jfqS r$   )interpreterr   r   r%   r$   r$   r(   r[   l  s    z=test_wheel_is_compatible.<locals>.sys_tags.<locals>.<setcomp>zcp36-cp36m-manylinux1_x86_64r   r$   r$   r$   r(   sys_tagsk  s   z*test_wheel_is_compatible.<locals>.sys_tagsz$setuptools.wheel._get_supported_tagsz2onnxruntime-0.1.2-cp36-cp36m-manylinux1_x86_64.whl)setattrr   is_compatible)monkeypatchr   r$   r$   r(   test_wheel_is_compatiblej  s   r   c                  C  st  t jddd} tdtdtddtddgd	td
ddddddddgigiid}|dd}|dd}|d}|di }|di }| d||g i |d|[}t ?}t|||||d  t|}	t	
||	  }
|
d d d }| s~J tjdkrtt| jdksJ W d    n1 sw   Y  W d    d S W d    d S 1 sw   Y  d S )Nc                 {  s    dt d| di}| r||  t 6}t|| t|d }t	|d t
jtjdddf|d ttj|d	d
d V  W d    d S 1 sOw   Y  d S )Nr7   z
                # -*- coding: utf-8 -*-
                from setuptools import setup
                import setuptools
                setup(**%r)
                r8   r   i  r9   r:   r;   r=   r>   r   )r   r?   r@   r   r   r   pathlibPathrF   chmodrA   rB   rC   rD   rE   rG   )rH   rI   rJ   rK   runshr$   r$   r(   rL   v  s(   	
"z$test_wheel_mode.<locals>.build_wheelr   r   r   r   r   r   r   r   ri   r   r   r   r   r   r   r   r   r   r   rw   rJ   r   r   win320o777rM   r$   )
contextlibcontextmanagerr^   r   r_   r   r   ry   r   r   r   rl   existsrC   r   octstatS_IMODEst_mode)rL   r   r   r   rw   rJ   r   r!   rs   r/   base	script_shr$   r$   r(   test_wheel_modeu  sp   
 
	
Pr   rM   )9__doc__
__future__r   r   rE   r1   rF   r   r   r   rA   rC   r   typingr   r3   jaracor   packaging.tagsr   packaging.utilsr   pkg_resourcesr   r	   r
   setuptools.wheelr   contextsr   textwrapr   distutils.sysconfigr   distutils.utilr   r   WHEEL_INFO_TESTSmarkparametrizer6   r   rL   rW   r_   rh   ry   rz   r^   r   r   __annotations__r   r   r   r   r   r$   r$   r$   r(   <module>   sh   1
	

-D

 
!
    p
