o
    ZhM                  
   @  s  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mZ d dlmZ d dlZd dlZd dlm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  h dZ!h dZ"ddhZ#dZ$e$ddide%&e"e#B dedddedddideddddedddddddddiided ddd!d"ed#d$d%d&Z'e
jd'kred(d)d*d+e'd,< d-d. Z(d/d0 Z)ej*d1d2d3d4 Z+ej*d5d6 Z,d7d8 Z-d9d: Z.d;Z/d<d= Z0d>d? Z1d@dA Z2ej34dBdCdDdEe$5dFdGfgdHdI Z6dJdK Z7dLdM Z8dNdO Z9dPZ:dQZ;ej3<dRdSdT Z=dUdV Z>ej3j4dWe?ej@A e?ej@dXdYdZ ZBd[d\ ZCd]d^ ZDd_d` ZEdadb ZFdcdd ZGdedf ZHdgdh ZIdidj ZJdkdl ZKej34dmdndogej3jLeM dpkdqdrdsdt ZNd{dwdxZOdydz ZPdS )|    )annotationsN)suppress)cleandoc)ZipFile)tags)bdist_wheelget_abi_tag)Distribution)SetuptoolsDeprecationWarning)	run_setup>   z&dummy_dist-1.0.dist-info/top_level.txtdummy_dist-1.0.dist-info/RECORDzdummy_dist-1.0.dist-info/WHEEL!dummy_dist-1.0.dist-info/METADATA>
   zAUTHORS.txtZCOPYINGLICENSEZLICENCEzLICENCE.txtZNOTICEz
NOTICE.rstzLICENSE.txtz
COPYING.mdZAUTHORSzLICENSE~zAUTHORS~zQfrom setuptools import setup

setup(
    name='dummy_dist',
    version='1.0',
)
	DUMMYFILE )setup.pyZlicensesu  
            from setuptools import setup

            setup(
                name="simple.dist",
                version="0.1",
                description="A testing distribution ☃",
                extras_require={"voting": ["beaglevote"]},
            )
            )r   Z
simpledistui  
            from setuptools import setup

            setup(
                name="complex-dist",
                version="0.1",
                description="Another testing distribution ☃",
                long_description="Another testing distribution ☃",
                author="Illustrious Author",
                author_email="illustrious@example.org",
                url="http://example.org/exemplary",
                packages=["complexdist"],
                setup_requires=["setuptools"],
                install_requires=["quux", "splort"],
                extras_require={"simple": ["simple.dist"]},
                entry_points={
                    "console_scripts": [
                        "complex-dist=complexdist:main",
                        "complex-dist2=complexdist:main",
                    ],
                },
            )
            __init__.pyzdef main(): return)r   Zcomplexdistz
            from setuptools import setup

            setup(
                name="headers.dist",
                version="0.1",
                description="A distribution with headers",
                headers=["header.h"],
            )
            )r   zheadersdist.pyzheader.hak  
            from setuptools import setup

            setup(
                name="testrepo",
                version="0.1",
                packages=["mypackage"],
                description="A test package with commas in file names",
                include_package_data=True,
                package_data={"mypackage.data": ["*"]},
            )
            )r   z	1,2,3.txt)r   data	mypackage)r   r   ztestrepo-0.1.0u  
            from setuptools import setup

            setup(
                name="unicode.dist",
                version="0.1",
                description="A testing distribution ☃",
                packages=["unicodedist"],
                zip_safe=True,
            )
            )r      åäö_日本語.py)r   Zunicodedistu   
            [metadata]
            name = utf8-metadata-dist
            version = 42
            author_email = "John X. Ãørçeč" <john@utf8.org>, Γαμα קּ 東 <gama@utf8.org>
            long_description = file: README.rst
               UTF-8 描述 説明)	setup.cfgz
README.rst)
dummy-distzsimple-distzcomplex-distzheaders-distzcommasinfilenames-distzunicode-distzutf8-metadata-distwin32u  
            from setuptools import Extension, setup

            setup(
                name="extension.dist",
                version="0.1",
                description="A testing distribution ☃",
                ext_modules=[
                    Extension(
                        name="extension", sources=["extension.c"], py_limited_api=True
                    )
                ],
            )
            z![bdist_wheel]
py_limited_api=cp32z5#define Py_LIMITED_API 0x03020000
#include <Python.h>)r   r   extension.czabi3extension-distc                  K  s^   t jdrtdddntddi}|  t|}|  D ]
\}}t||| q|	  |S )zHRun command in the same process so that it is easier to collect coverager   init)Z
stop_afterscript_namez%%build_meta%%)
ospathexistsr   r	   Zparse_config_filesr   itemssetattrfinalize_options)kwargsZdist_objcmdattrvalue r'   X/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/tests/test_bdist_wheel.pybdist_wheel_cmd   s   

r)   c                 C  s&   |  |}tjjt| t|d |S )N)prefix)mktempjaracor   buildEXAMPLESstr)tmp_path_factorynamebasedirr'   r'   r(   	mkexample   s   
r3   session)scopec              	   C  s   |  d}|  d}tD ]/}t| |}|| }tj | tt|t|d	  W d    n1 s6w   Y  qt
dd |dD S )Nr-   dist	bdist_dirdist_dirc                 s  s    | ]}t |V  qd S Nr/   .0fnamer'   r'   r(   	<genexpr>   s    zwheel_paths.<locals>.<genexpr>z*.whl)r+   r.   r3   r,   r   ZDirectoryStackcontextr)   r/   runsortedglob)r0   Z
build_baser9   r1   Zexample_dir	build_dirr'   r'   r(   wheel_paths   s   


rE   c                 C  s
   t | dS )Nr   )r3   )r0   r'   r'   r(   
dummy_dist   s   
rF   c                 C  s6   t dd | D }t| D ]	}d|jvsJ qdS )z0Make sure entry point scripts are not generated.c                 s      | ]	}d |v r|V  qdS )Zcomplex_distNr'   r=   r   r'   r'   r(   r?          z"test_no_scripts.<locals>.<genexpr>z.data/scripts/N)nextr   infolistfilename)rE   r   entryr'   r'   r(   test_no_scripts   s   rN   c                 C  sX   t dd | D }t|}|d}W d    n1 sw   Y  d |v s*J d S )Nc                 s  rG   )zunicode.distNr'   rH   r'   r'   r(   r?      rI   z&test_unicode_record.<locals>.<genexpr>z!unicode.dist-0.1.dist-info/RECORDr   )rJ   r   readencode)rE   r   zfrecordr'   r'   r(   test_unicode_record   s
   
rS   u   Metadata-Version: 2.1
Name: helloworld
Version: 42
Author-email: "John X. Ãørçeč" <john@utf8.org>, Γαμα קּ 東 <gama@utf8.org>


UTF-8 描述 説明
c                 C  s   |  | |d }|d }|  |d jtdd |d   G dd dt}| }||| |d	 jdd}d
|v s?J d|v sEJ d|v sKJ d S )Nzdummy_dist.egg-infodummy_dist.dist-infozPKG-INFOutf-8encodingzdependency_links.txtc                   @  s$   e Zd ZdZdd Zedd ZdS )z;test_preserve_unicode_metadata.<locals>.simpler_bdist_wheelz1Avoid messing with setuptools/distutils internalsc                 S  s   d S r:   r'   selfr'   r'   r(   __init__  s   zDtest_preserve_unicode_metadata.<locals>.simpler_bdist_wheel.__init__c                 S  s   g S r:   r'   rX   r'   r'   r(   license_paths  s   zItest_preserve_unicode_metadata.<locals>.simpler_bdist_wheel.license_pathsN)__name__
__module____qualname____doc__rZ   propertyr[   r'   r'   r'   r(   simpler_bdist_wheel  s
    ra   METADATAu"   Author-email: "John X. Ãørçeč"u   Γαμα קּ 東 r   )chdirmkdir
write_textUTF8_PKG_INFOtouchr   Zegg2dist	read_text)monkeypatchtmp_pathZegginfodistinfora   Zcmd_objmetadatar'   r'   r(   test_preserve_unicode_metadata  s   

rm   c                 C  sp   | |  tt|d  td}dd tD }t| t|B ks&J W d    d S 1 s1w   Y  d S )Nr8   $dist/dummy_dist-1.0-py3-none-any.whlc                 S     h | ]}d | qS zdummy_dist-1.0.dist-info/r'   r<   r'   r'   r(   	<setcomp>+      z(test_licenses_default.<locals>.<setcomp>)	rc   r)   r/   rA   r   DEFAULT_LICENSE_FILESsetnamelistDEFAULT_FILESrF   ri   rj   wflicense_filesr'   r'   r(   test_licenses_default'  s   

"r{   c                 C  s|   |  djddd ||  tt|d  td}dh}t| t	|B ks,J W d    d S 1 s7w   Y  d S )Nr   z*[metadata]
license_file=licenses/DUMMYFILErU   rV   rn   ro   z"dummy_dist-1.0.dist-info/DUMMYFILE
joinpathre   rc   r)   r/   rA   r   ru   rv   rw   rx   r'   r'   r(   test_licenses_deprecated1  s   


"r~   )config_fileconfig)r   z-[metadata]
license_files=licenses/*
  LICENSE)r   z,[metadata]
license_files=licenses/*, LICENSEr   )z2  license_files=['licenses/DUMMYFILE', 'LICENSE'])c                 C  s   |  |j|dd ||  tt|d  td}dd dD }t| t	|B ks0J W d    d S 1 s;w   Y  d S )NrU   rV   rn   ro   c                 S  rp   rq   r'   r<   r'   r'   r(   rr   P  rs   z)test_licenses_override.<locals>.<setcomp>>   r   r   r|   )rF   ri   rj   r   r   ry   rz   r'   r'   r(   test_licenses_override>  s   

"r   c                 C  sr   |  djddd ||  tt|d  td}t| t	ks'J W d    d S 1 s2w   Y  d S )Nr   z[metadata]
license_files=
rU   rV   rn   ro   r|   )rF   ri   rj   ry   r'   r'   r(   test_licenses_disabledV  s   


"r   c                 C  sp   | |  tt|dd  td}t| }d|v s J d|v s&J W d    d S 1 s1w   Y  d S )N2r8   build_numberz&dist/dummy_dist-1.0-2-py3-none-any.whlr   r   )rc   r)   r/   rA   r   ru   rv   )rF   ri   rj   ry   	filenamesr'   r'   r(   test_build_number`  s   

"r   c                 C  s`   | |  tjtdd tt|dd  W d    n1 s!w   Y  tj	ds.J d S )Nz.*universal is deprecatedmatchT)r8   	universalz(dist/dummy_dist-1.0-py2.py3-none-any.whl)
rc   pytestZwarnsr
   r)   r/   rA   r   r   r   )rF   ri   rj   r'   r'   r(   test_universal_deprecatedi  s
   
r   a&  #include <Python.h>

static PyMethodDef methods[] = {
  { NULL, NULL, 0, NULL }
};

static struct PyModuleDef module_def = {
  PyModuleDef_HEAD_INIT,
  "extension",
  "Dummy extension module",
  -1,
  methods
};

PyMODINIT_FUNC PyInit_extension(void) {
  return PyModule_Create(&module_def);
}
u   from __future__ import annotations

from setuptools import Extension, setup

setup(
    name="extension.dist",
    version="0.1",
    description="A testing distribution ☃",
    ext_modules=[Extension(name="extension", sources=["extension.c"])],
)
zEonce:Config variable '.*' is unset.*, Python ABI tag may be incorrectc                 C  sh   | d}|d jtdd |d jtdd |d}|d}| | tt|t|d  d	S )
z=Test that building a binary wheel with the limited ABI works.Zextension_distr   rU   rV   r   r-   r6   r7   N)	r+   re   EXTENSION_SETUPPYEXTENSION_EXAMPLEr}   rc   r)   r/   rA   )ri   rj   r0   
source_dirrD   r9   r'   r'   r(   test_limited_abi  s   



r   c                 C  sn   t |d}tt | | || t|D ]\}}}|D ]}ttj	||t
j q qt   d S )Ndummy)r/   r}   shutilcopytreerc   r   walkchmodr   joinstatS_IREADr)   rA   )rF   ri   rj   r2   root_dirsfilesr>   r'   r'   r(   test_build_from_readonly_tree  s   
r   )optioncompress_type)Zidsc                 C  s   | |  tt||d  td(}t| }d|v s J d|v s&J |jD ]	}|j|ks2J q)W d    d S 1 s>w   Y  d S )N)r8   compressionro   r   r   )	rc   r)   r/   rA   r   ru   rv   filelistr   )rF   ri   rj   r   r   ry   r   zinfor'   r'   r(   test_compression  s   


"r   c              	   C  s`   | D ]+}t |}tdd |jD }||}d|vsJ W d    n1 s(w   Y  qd S )Nc                 s  s     | ]}|j d r|V  qdS )WHEELN)rL   endswith)r=   fnr'   r'   r(   r?     s    z.test_wheelfile_line_endings.<locals>.<genexpr>   )r   rJ   r   rO   )rE   r   ry   Z	wheelfileZwheelfile_contentsr'   r'   r(   test_wheelfile_line_endings  s   

r   c                 C  sr   | dd ||  tt|dd  td}|jD ]	}|jdks&J qW d    d S 1 s2w   Y  d S )NSOURCE_DATE_EPOCH0Z2ar   z'dist/dummy_dist-1.0-2a-py3-none-any.whl)i     r   r   r   r   )Zsetenvrc   r)   r/   rA   r   r   	date_time)rF   ri   rj   ry   r   r'   r'   r(   test_unix_epoch_timestamps  s   


"r   c                 C  s   |  tddd  |  tddd  t dksJ |  tddd d	 t d
ks*J |  tddd  t dks:J | td t dksGJ d S )Ninterpreter_namec                   S     dS )Ncpr'   r'   r'   r'   r(   <lambda>      z*test_get_abi_tag_windows.<locals>.<lambda>get_config_varc                 S  r   )Nzcp313-win_amd64r'   xr'   r'   r(   r     r   Zcp313gettotalrefcountc                   S  r   )Nr   r'   r'   r'   r'   r(   r     r   FZcp313dc                 S  r   )Nzcp313t-win_amd64r'   r   r'   r'   r(   r     r   Zcp313tdZcp313t)r!   r   	sysconfigr   sysdelattrri   r'   r'   r(   test_get_abi_tag_windows  s   r   c                 C  6   |  tddd  |  tddd  t dksJ d S )Nr   c                   S  r   Nppr'   r'   r'   r'   r(   r     r   z+test_get_abi_tag_pypy_old.<locals>.<lambda>r   c                 S  r   )Nzpypy36-pp73r'   r   r'   r'   r(   r     r   Zpypy36_pp73)r!   r   r   r   r   r'   r'   r(   test_get_abi_tag_pypy_old     r   c                 C  r   )Nr   c                 S  r   )Nzpypy37-pp73-darwinr'   r   r'   r'   r(   r     r   z+test_get_abi_tag_pypy_new.<locals>.<lambda>r   c                   S  r   r   r'   r'   r'   r'   r(   r     r   Zpypy37_pp73r!   r   r   r   r   r'   r'   r(   test_get_abi_tag_pypy_new  r   r   c                 C  r   )Nr   c                 S  r   )Nz"graalpy231-310-native-x86_64-linuxr'   r   r'   r'   r(   r     r   z*test_get_abi_tag_graalpy.<locals>.<lambda>r   c                   S  r   )Ngraalpyr'   r'   r'   r'   r(   r     r   Zgraalpy231_310_nativer   r   r'   r'   r(   test_get_abi_tag_graalpy  s
   
r   c                 C  r   )Nr   c                 S  r   )Nzunknown-python-310r'   r   r'   r'   r(   r     r   z+test_get_abi_tag_fallback.<locals>.<lambda>r   c                   S  r   )Nzunknown-pythonr'   r'   r'   r'   r(   r     r   Zunknown_python_310r   r   r'   r'   r(   test_get_abi_tag_fallback  r   r   c                 C  s   | |  tdd  dS )z>Ensure building on platforms with a space in the name succeed.zisilon onefs)	plat_nameN)rc   r)   rA   )rF   ri   r'   r'   r(   test_platform_with_space  s   
r   c           
   	   C  s   |  | ddddd}| D ]"\}}t|ddd}|t| W d   n1 s-w   Y  qt   d	}tj	|sBJ t
t| }d
D ]}||v sTJ qLdD ]}	|	|vs_J qWdS )z
    Setuptools allow authors to set PEP 440's local version segments
    using ``egg_info.tag_build``. This should be reflected not only in the
    ``.whl`` file name, but also in the ``.dist-info`` and ``.data`` dirs.
    See pypa/setuptools#3997.
    z]
            from setuptools import setup
            setup(headers=["hello.h"])
            z
            [metadata]
            name = test
            version = 1.0

            [options.data_files]
            hello/world = file.txt

            [egg_info]
            tag_build = +what
            tag_date = 0
            r   )r   r   zfile.txtzhello.hwrU   rV   Nz#dist/test-1.0+what-py3-none-any.whl)z"test-1.0+what.data/headers/hello.hz,test-1.0+what.data/data/hello/world/file.txtz test-1.0+what.dist-info/METADATAztest-1.0+what.dist-info/WHEEL)ztest.data/headers/hello.hz'test-1.0.data/data/hello/world/file.txtztest.dist-info/METADATAztest-1.0.dist-info/WHEEL)rc   r    openwriter   r)   rA   r   r   r   ru   r   rv   )
ri   rj   r   filecontentfh
wheel_pathentriesexpectedZnot_expectedr'   r'   r(   test_data_dir_with_tag_build  s(   

r   )reportedr   )zlinux-x86_64
linux_i686)zlinux-aarch64Zlinux_armv7lLinuxz!Only makes sense to test on Linux)reasonc                 C  sL   | tddd  t }t|}| |_d|_| \}}}||ks$J d S )Ncalcsizec                 S  r   )N   r'   r   r'   r'   r(   r   :  r   z'test_platform_linux32.<locals>.<lambda>F)r!   struct
setuptoolsr	   r   r   Zroot_is_pureZget_tag)r   r   ri   r6   r$   _actualr'   r'   r(   test_platform_linux322  s   r   returnNonec                 C  s   ddd}t t | tjd W d    n1 sw   Y  | td| tjt	dd d	d l
}W d    n1 s=w   Y  | tjd
 d	d l}d S )Nr1   r/   c                 _  s.   | dkrt d|  tj| g|R i |S )NctypeszNo module named )ModuleNotFoundError	importlib
__import__)r1   argsr#   r'   r'   r(   _fake_importD  s   z$test_no_ctypes.<locals>._fake_importzwheel.macosx_libfiler   zNo module named ctypesr   r   zsetuptools.command.bdist_wheel)r1   r/   )r   KeyErrordelitemr   modulesr!   builtinsr   Zraisesr   Zwheel.macosx_libfilesetuptools.command.bdist_wheel)ri   r   wheelr   r'   r'   r(   test_no_ctypesC  s   


r   c                 C  s   | |  |d }|  |d jddd |d jddd tt|t|d  d	d
h}td}t| }W d    n1 sDw   Y  || t ksRJ dd |D r[J d S )NrT   rb   zname: helloworldrU   rV   ZFOObar)r8   dist_info_dirzdummy_dist-1.0.dist-info/FOOr   ro   c                 S  s   g | ]
}d t |v r|qS )zegg-infor;   rH   r'   r'   r(   
<listcomp>o  s    z+test_dist_info_provided.<locals>.<listcomp>)	rc   rd   re   r)   r/   rA   r   ru   rv   )rF   ri   rj   rk   r   ry   Zfiles_foundr'   r'   r(   test_dist_info_providedY  s   

r   )r   r   )Q
__future__r   r   r   Zos.pathr   platformr   r   r   r   r   
contextlibr   inspectr   zipfiler   Zjaraco.pathr,   r   	packagingr   r   r   r   r   Zsetuptools.distr	   Zsetuptools.warningsr
   Zdistutils.corer   rw   rt   ZOTHER_IGNORED_FILESZSETUPPY_EXAMPLEdictfromkeysr.   r)   r3   ZfixturerE   rF   rN   rS   rf   rm   r{   r~   markZparametrizereplacer   r   r   r   r   r   filterwarningsr   r   listZsupported_compressionsr    r   r   r   r   r   r   r   r   r   r   Zskipifsystemr   r   r   r'   r'   r'   r(   <module>   s   	
w






		

	7

