o
    LK&h+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/WHEEL&dummy_dist-1.0.dist-info/top_level.txtdummy_dist-1.0.dist-info/RECORD!dummy_dist-1.0.dist-info/METADATA>
   
COPYING.md
NOTICE.rstAUTHORS.txtLICENCE.txtNOTICEAUTHORSCOPYINGLICENCELICENSELICENSE.txtzLICENSE~zAUTHORS~zQfrom setuptools import setup

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

            setup(
                name="simple.dist",
                version="0.1",
                description="A testing distribution ☃",
                extras_require={"voting": ["beaglevote"]},
            )
            )r   
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   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   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)
stop_afterscript_namez%%build_meta%%)
ospathexistsr   r	   parse_config_filesr   itemssetattrfinalize_options)kwargsdist_objcmdattrvalue r<   T/var/www/html/venv/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jaracor1   buildEXAMPLESstr)tmp_path_factorynamebasedirr<   r<   r=   	mkexample   s   
rI   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 )NrC   dist	bdist_dirdist_dirc                 s  s    | ]}t |V  qd S NrE   .0fnamer<   r<   r=   	<genexpr>   s    zwheel_paths.<locals>.<genexpr>z*.whl)rA   rD   rI   rB   r1   DirectoryStackcontextr>   rE   runsortedglob)rF   
build_baserO   rG   example_dir	build_dirr<   r<   r=   wheel_paths   s   


r^   c                 C  
   t | dS )Nr)   rI   rF   r<   r<   r=   
dummy_dist      
rb   c                 C  r_   )Nr*   r`   ra   r<   r<   r=   licenses_dist   rc   rd   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 )complex_distNr<   rS   r1   r<   r<   r=   rU         z"test_no_scripts.<locals>.<genexpr>z.data/scripts/N)nextr   infolistfilename)r^   r1   entryr<   r<   r=   test_no_scripts  s   rm   c                 C  sX   t dd | D }t|}|d}W d    n1 sw   Y  d |v s*J d S )Nc                 s  re   )unicode_distNr<   rg   r<   r<   r=   rU     rh   z&test_unicode_record.<locals>.<genexpr>z!unicode_dist-0.1.dist-info/RECORDr#   )ri   r   readencode)r^   r1   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 rP   r<   selfr<   r<   r=   __init__*  s   zDtest_preserve_unicode_metadata.<locals>.simpler_bdist_wheel.__init__c                 S  s   g S rP   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
    r   METADATAu"   Author-email: "John X. Ãørçeč"u   Γαμα קּ 東 r%   )chdirmkdir
write_textUTF8_PKG_INFOtouchr   egg2dist	read_text)monkeypatchtmp_pathegginfodistinfor   cmd_objmetadatar<   r<   r=   test_preserve_unicode_metadata  s   

r   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rN   $dist/dummy_dist-1.0-py3-none-any.whlc                 S     h | ]}d | qS z"dummy_dist-1.0.dist-info/licenses/r<   rR   r<   r<   r=   	<setcomp>>      z(test_licenses_default.<locals>.<setcomp>)	r   r>   rE   rX   r   DEFAULT_LICENSE_FILESsetnamelistDEFAULT_FILESrb   r   r   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/DUMMYFILEru   rv   r   r   z8dummy_dist-1.0.dist-info/licenses/licenses_dir/DUMMYFILE
joinpathr   r   r>   rE   rX   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 )Nru   rv   r   r   c                 S  r   r   r<   rR   r<   r<   r=   r   d  r   z)test_licenses_override.<locals>.<setcomp>>   licenses_dir/DUMMYFILEr   r   utf8z$License-File: licenses_dir/DUMMYFILELicense-File: LICENSE)r   r   r   r>   rE   rX   r   r   r   r   ro   decode)rb   r   r   r   r   r   r   r   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 )Nr   rL   z'dist/licenses_dist-1.0-py3-none-any.whlc                 S  s   h | ]}| d dqS )dummy_	licenses_)replace)rS   rG   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   )r   r>   rE   rX   printr0   listdirr   r   r   r   ro   r   )rd   r   r   r   default_filesr   r   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=
ru   rv   r   r   r   )rb   r   r   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rN   build_numberz&dist/dummy_dist-1.0-2-py3-none-any.whlr   r   )r   r>   rE   rX   r   r   r   )rb   r   r   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)rN   	universalz(dist/dummy_dist-1.0-py2.py3-none-any.whl)
r   pytestwarnsr
   r>   rE   rX   r0   r1   r2   )rb   r   r   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.extension_distr   ru   rv   r,   rC   rL   rM   N)	rA   r   EXTENSION_SETUPPYEXTENSION_EXAMPLEr   r   r>   rE   rX   )r   r   rF   
source_dirr]   rO   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)rE   r   shutilcopytreer   r0   walkchmodr1   joinstatS_IREADr>   rX   )rb   r   r   rH   root_dirsfilesrT   r<   r<   r=   test_build_from_readonly_tree  s   
r   )optioncompress_type)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)rN   compressionr   r   r   )	r   r>   rE   rX   r   r   r   filelistr   )rb   r   r   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)rk   endswith)rS   fnr<   r<   r=   rU     s    z.test_wheelfile_line_endings.<locals>.<genexpr>   )r   ri   r   ro   )r^   r1   r   	wheelfile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02ar   z'dist/dummy_dist-1.0-2a-py3-none-any.whl)i     r   r   r   r   )setenvr   r>   rE   rX   r   r   	date_time)rb   r   r   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   cp313gettotalrefcountc                   S  r   )Nr   r<   r<   r<   r<   r=   r     r   Fcp313dc                 S  r   )Nzcp313t-win_amd64r<   r   r<   r<   r=   r     r   cp313tdcp313t)r5   r   	sysconfigr   sysdelattrr   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   pypy36_pp73)r5   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   pypy37_pp73r5   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   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   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)r   r>   rX   )rb   r   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)r   r4   openwriter   r>   rX   r0   r1   r2   r   r   r   )
r   r   r   filecontentfh
wheel_pathentriesexpected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)r5   struct
setuptoolsr	   r   r  root_is_pureget_tag)r  r  r   rL   r9   _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 )NrG   rE   c                 _  s.   | dkrt d|  tj| g|R i |S )NctypeszNo module named )ModuleNotFoundError	importlib
__import__)rG   argsr7   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)rG   rE   )r   KeyErrordelitemr   modulesr5   builtinsr   raisesr!  wheel.macosx_libfilesetuptools.command.bdist_wheel)r   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 )Nrt   r   zname: helloworldru   rv   FOObar)rN   dist_info_dirzdummy_dist-1.0.dist-info/FOOr   r   c                 S  s   g | ]
}d t |v r|qS )zegg-inforQ   rg   r<   r<   r=   
<listcomp>  s    z+test_dist_info_provided.<locals>.<listcomp>)	r   r   r   r>   rE   rX   r   r   r   )rb   r   r   r   r  r   files_foundr<   r<   r=   test_dist_info_provided  s   

r4  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
                42)zpyproject.tomlr&   VERSION)r   z
NOTICE.txtpythonr?   r7  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   rB   r1   rC   rE   r   r   r   r
   r>   rX   r   r   r   ro   r   )r   r   r   msgr   r3  expected_filesr   r<   r<   r=   0test_allow_grace_period_parent_directory_license  s6   	
"r:  )r  r  )T
__future__r   r)  r"  os.pathr0   platformr   r   r  r   r   
contextlibr   inspectr   zipfiler   jaraco.pathrB   r   	packagingr   r  r,  r   r   setuptools.distr	   setuptools.warningsr
   distutils.corer   r   r   OTHER_IGNORED_FILESSETUPPY_EXAMPLEdictfromkeysrD   r>   rI   fixturer^   rb   rd   rm   rs   r   r   r   r   markparametrizer   r   r   r   r   r   r   r   filterwarningsr   r   listsupported_compressionsr4   r   r   r   r   r   r   r   r  r  r  skipifsystemr  r.  r4  r:  r<   r<   r<   r=   <module>   s$   	 







		

	7

