o
    NZh+Z                     @  sF  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%ed&dd'd(diid)d*Z'e
jd+kred,d-d.d/e'd0< d1d2 Z(d3d4 Z)ej*d5d6d7d8 Z+ej*d9d: Z,ej*d;d< Z-d=d> Z.d?d@ Z/dAZ0dBdC Z1dDdE Z2dFdG Z3ej45dHdIdJdKe$6dLdMfgdNdO Z7dPdQ Z8dRdS Z9dTdU Z:dVdW Z;dXZ<dYZ=ej4>dZd[d\ Z?d]d^ Z@ej4j5d_eAejBC eAejBd`dadb ZDdcdd ZEdedf ZFdgdh ZGdidj ZHdkdl ZIdmdn ZJdodp ZKdqdr ZLdsdt ZMej45dudvdwgej4jNeO dxkdydzd{d| ZPdddZQdd ZRdd ZSdS )    )annotationsN)suppress)cleandoc)ZipFile)tags)bdist_wheelget_abi_tag)Distribution)SetuptoolsDeprecationWarning)	run_setup>   !dummy_dist-1.0.dist-info/METADATAz&dummy_dist-1.0.dist-info/top_level.txtzdummy_dist-1.0.dist-info/WHEELdummy_dist-1.0.dist-info/RECORD>
   LICENSELICENSE.txtzAUTHORS.txtZLICENCEZAUTHORSZCOPYINGZNOTICEz
NOTICE.rstz
COPYING.mdzLICENCE.txtzLICENSE~zAUTHORS~zQfrom setuptools import setup

setup(
    name='dummy_dist',
    version='1.0',
)
Z	DUMMYFILE )setup.pyZlicenses_diru  
            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.rstz
            [metadata]
            name = licenses-dist
            version = 1.0
            license_files = **/LICENSE
            vendorr   )r   r   src)
dummy-distzsimple-distzcomplex-distzheaders-distzcommasinfilenames-distzunicode-distzutf8-metadata-distlicenses-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*   P/var/www/auris/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   
r7   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 )Nr1   dist	bdist_dirdist_dirc                 s  s    | ]}t |V  qd S Nr3   .0fnamer*   r*   r+   	<genexpr>   s    zwheel_paths.<locals>.<genexpr>z*.whl)r/   r2   r7   r0   r!   ZDirectoryStackcontextr,   r3   runsortedglob)r4   Z
build_baser=   r5   Zexample_dir	build_dirr*   r*   r+   wheel_paths   s   


rI   c                 C  
   t | dS )Nr   r7   r4   r*   r*   r+   
dummy_dist      
rM   c                 C  rJ   )Nr   rK   rL   r*   r*   r+   licenses_dist   rN   rO   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*   rA   r!   r*   r*   r+   rC         z"test_no_scripts.<locals>.<genexpr>z.data/scripts/N)nextr   infolistfilename)rI   r!   entryr*   r*   r+   test_no_scripts  s   rW   c                 C  sX   t dd | D }t|}|d}W d    n1 sw   Y  d |v s*J d S )Nc                 s  rP   )Zunicode_distNr*   rQ   r*   r*   r+   rC     rR   z&test_unicode_record.<locals>.<genexpr>z!unicode_dist-0.1.dist-info/RECORDr   )rS   r   readencode)rI   r!   zfrecordr*   r*   r+   test_unicode_record  s
   
r\   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*   ra   r*   r*   r+   license_paths-  s   zItest_preserve_unicode_metadata.<locals>.simpler_bdist_wheel.license_pathsN)__name__
__module____qualname____doc__rc   propertyrd   r*   r*   r*   r+   simpler_bdist_wheel'  s
    rj   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distinforj   Zcmd_objmetadatar*   r*   r+   test_preserve_unicode_metadata  s   

rv   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r<   $dist/dummy_dist-1.0-py3-none-any.whlc                 S     h | ]}d | qS z"dummy_dist-1.0.dist-info/licenses/r*   r@   r*   r*   r+   	<setcomp>>      z(test_licenses_default.<locals>.<setcomp>)	rl   r,   r3   rE   r   DEFAULT_LICENSE_FILESsetnamelistDEFAULT_FILESrM   rr   rs   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_dir/DUMMYFILEr^   r_   rw   rx   z8dummy_dist-1.0.dist-info/licenses/licenses_dir/DUMMYFILE
joinpathrn   rl   r,   r3   rE   r   r~   r   r   r   r*   r*   r+   test_licenses_deprecatedE  s   


"r   )config_fileconfig)r   z1[metadata]
license_files=licenses_dir/*
  LICENSE)r   z0[metadata]
license_files=licenses_dir/*, LICENSEr   )z6  license_files=['licenses_dir/DUMMYFILE', 'LICENSE'])c                 C  s   |  |j|dd ||  tt|d  td0}dd dD }t| t	|B ks0J |
dd	}d
|v s>J d|v sDJ W d    d S 1 sOw   Y  d S )Nr^   r_   rw   rx   c                 S  ry   rz   r*   r@   r*   r*   r+   r{   d  r|   z)test_licenses_override.<locals>.<setcomp>>   r   zlicenses_dir/DUMMYFILEr   utf8z$License-File: licenses_dir/DUMMYFILELicense-File: LICENSE)r   rn   rl   r,   r3   rE   r   r~   r   r   rX   decode)rM   rr   rs   r   r   r   r   ru   r*   r*   r+   test_licenses_overrideR  s   

"r   c                 C  s   | |  tt|d  ttd td4}dd tD }ddh}t	|
 ||B ks1J |dd	}d
|v s?J d|v sEJ W d    d S 1 sPw   Y  d S )Nrw   r:   z'dist/licenses_dist-1.0-py3-none-any.whlc                 S  s   h | ]}| d dqS )Zdummy_Z	licenses_)replace)rA   r5   r*   r*   r+   r{   s  s    z:test_licenses_preserve_folder_structure.<locals>.<setcomp>z,licenses_dist-1.0.dist-info/licenses/LICENSEz7licenses_dist-1.0.dist-info/licenses/src/vendor/LICENSEz$licenses_dist-1.0.dist-info/METADATAr   z License-File: src/vendor/LICENSEr   )rl   r,   r3   rE   printr    listdirr   r   r~   r   rX   r   )rO   rr   rs   r   Zdefault_filesr   ru   r*   r*   r+   'test_licenses_preserve_folder_structuren  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=
r^   r_   rw   rx   r   )rM   rr   rs   r   r*   r*   r+   test_licenses_disabled~  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r<   build_numberz&dist/dummy_dist-1.0-2-py3-none-any.whlr   r   )rl   r,   r3   rE   r   r~   r   )rM   rr   rs   r   	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)r<   	universalz(dist/dummy_dist-1.0-py2.py3-none-any.whl)
rl   pytestwarnsr
   r,   r3   rE   r    r!   r"   )rM   rr   rs   r*   r*   r+   test_universal_deprecated  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   r^   r_   r   r1   r:   r;   N)	r/   rn   EXTENSION_SETUPPYEXTENSION_EXAMPLEr   rl   r,   r3   rE   )rr   rs   r4   
source_dirrH   r=   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)r3   r   shutilcopytreerl   r    walkchmodr!   joinstatS_IREADr,   rE   )rM   rr   rs   r6   root_dirsfilesrB   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)r<   compressionrx   r   r   )	rl   r,   r3   rE   r   r~   r   filelistr   )rM   rr   rs   r   r   r   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)rU   endswith)rA   fnr*   r*   r+   rC     s    z.test_wheelfile_line_endings.<locals>.<genexpr>   )r   rS   r   rX   )rI   r!   r   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setenvrl   r,   r3   rE   r   r   	date_time)rM   rr   rs   r   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rr   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   )NZ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)rl   r,   rE   )rM   rr   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wr^   r_   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)rl   r#   openwriter   r,   rE   r    r!   r"   r~   r   r   )
rr   rs   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-aarch64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   b  r   z'test_platform_linux32.<locals>.<lambda>F)r$   struct
setuptoolsr	   r   r   Zroot_is_pureZget_tag)r   r   rr   r:   r'   _actualr*   r*   r+   test_platform_linux32Z  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 )Nr5   r3   c                 _  s.   | dkrt d|  tj| g|R i |S )NctypeszNo module named )ModuleNotFoundError	importlib
__import__)r5   argsr&   r*   r*   r+   _fake_importl  s   z$test_no_ctypes.<locals>._fake_importzwheel.macosx_libfiler   zNo module named ctypesr   r   zsetuptools.command.bdist_wheel)r5   r3   )r   KeyErrordelitemr   modulesr$   builtinsr   Zraisesr   Zwheel.macosx_libfilesetuptools.command.bdist_wheel)rr   r   wheelr   r*   r*   r+   test_no_ctypesk  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 )Nr]   rk   zname: helloworldr^   r_   ZFOObar)r<   dist_info_dirzdummy_dist-1.0.dist-info/FOOr   rx   c                 S  s   g | ]
}d t |v r|qS )zegg-infor?   rQ   r*   r*   r+   
<listcomp>  s    z+test_dist_info_provided.<locals>.<listcomp>)	rl   rm   rn   r,   r3   rE   r   r~   r   )rM   rr   rs   rt   r   r   files_foundr*   r*   r+   test_dist_info_provided  s   

r  c                 C  s   ddt dt dddd}tjj|t|d | |d	  d
}tjt|d t	 
  W d    n1 s8w   Y  td-}t| }ddh}||ksRJ |dd}d|v s`J d|v sfJ W d    d S 1 sqw   Y  d S )Nzparent licensezparent noticez
                [project]
                name = "test-proj"
                dynamic = ["version"]      # <---- testing dynamic will not break
                [tool.setuptools.dynamic]
                version.file = "VERSION"
                z
                [metadata]
                license_files =
                  ../LICENSE.txt
                  ../NOTICE.txt
                Z42)zpyproject.tomlr   VERSION)r   z
NOTICE.txtpythonr-   r  z'Pattern '../.*.txt' cannot contain '..'r   z"dist/test_proj-42-py3-none-any.whlz+test_proj-42.dist-info/licenses/LICENSE.txtz*test_proj-42.dist-info/licenses/NOTICE.txtztest_proj-42.dist-info/METADATAr   zLicense-File: LICENSE.txtzLicense-File: NOTICE.txt)r   r0   r!   r1   r3   rl   r   r   r
   r,   rE   r   r~   r   rX   r   )rr   rs   r   msgr   r   Zexpected_filesru   r*   r*   r+   0test_allow_grace_period_parent_directory_license  s6   	
"r  )r   r   )T
__future__r   r   r   Zos.pathr    platformr   r   r   r   r   
contextlibr   inspectr   zipfiler   Zjaraco.pathr0   r   	packagingr   r   r   r   r   Zsetuptools.distr	   Zsetuptools.warningsr
   Zdistutils.corer   r   r}   ZOTHER_IGNORED_FILESZSETUPPY_EXAMPLEdictfromkeysr2   r,   r7   ZfixturerI   rM   rO   rW   r\   ro   rv   r   r   markZparametrizer   r   r   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*   r+   <module>   s$   	 







		

	7

