
    ϶vgk7                        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Z	d dl
Z
d dlmZ d dlmZ ddlmZ d Zd	 Zd
 Ze
j                            dded          d             Z ed          ddddddd ed          dZd Ze
j                            d          d             Z ed          ddddddddididdd ed          d Zd! Z G d" d#          Zd'd%Zd& Z dS )(    N)Path)Mock)SetuptoolsDeprecationWarning)Distribution   )DALSc           	          t          t          ddgdgddgi                    }t          j        d           |                                 |                                 dS )z
    Directories matching the glob in package_data should
    not be included in the package data.

    Regression test for #261.
    setup.pybuild_py zpath/*script_namescript_argspackagespackage_datazpath/subpathN)r   dictosmakedirsparse_command_linerun_commands
tmpdir_cwddists     [/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/tests/test_build_py.py%test_directories_in_package_data_globr      sx     "#Txj)		
 	
 	
 D K    c           	      v   t          t          ddgdgddgi                    }t          j        d           t	          dd                                           |                                 |                                 t          j	        t          j        d	          j
                  s
J d
            dS )zt
    Files matching recursive globs (**) in package_data should
    be included in the package data.

    #1806
    r
   r   r   zpath/**/datar   zpath/subpath/subsubpathzpath/subpath/subsubpath/datawbz&build/lib/path/subpath/subsubpath/datazFile is not includedN)r   r   r   r   opencloser   r   statS_ISREGst_moder   s     r   #test_recursive_in_package_data_globr$   %   s     "#T~./		
 	
 	
 D K)***	'..44666< HIIQRR      r   c           	         t          t          ddgdgddgi                    }t          j        d           t	          dd                                           t	          dd                                           t          j        dt          j                   t          j        dt          j                   |	                                 |
                                 t          j        d	           d
S )z
    Ensure read-only flag is not preserved in copy
    for package modules and package data, as that
    causes problems with deleting read-only files on
    Windows.

    #1451
    r
   r   pkgzdata.datr   pkg/__init__.pyr   zpkg/data.datbuildN)r   r   r   r   r   r    chmodr!   S_IREADr   r   shutilrmtreer   s     r   test_read_onlyr-   ?   s     "#W*.		
 	
 	
 D K	D!!'')))$$&&&H---H^T\***
M'r   zplatform.system() == "Windows"z-On Windows, files do not have executable bitsT)reasonraisesstrictc           	         t          t          ddgdgddgi                    }t          j        d           t	          dd                                           t	          dd                                           t          j        dd	           |                                 |                                 t          j	        d
          j
        t          j        z  s
J d            dS )zv
    Ensure executable bit is preserved in copy for
    package data, as users rely on it for scripts.

    #2041
    r
   r   r&   zrun-mer   r'   r   z
pkg/run-mei  zbuild/lib/pkg/run-mezScript is not executableN)r   r   r   r   r   r    r)   r   r   r!   r#   S_IEXECr   s     r   test_executable_datar3   Z   s     "#W(,		
 	
 	
 D K	D!!'')))t""$$$H\5!!!7)**2T\A  "    r   z
        [metadata]
        name = mypkg
        version = 42

        [options]
        include_package_data = True
        packages = find:

        [options.packages.find]
        exclude = *.tests*
        r   )__init__.pyztest_mypkg.pyztest_file.txt)r4   resource_file.txttestsz
        global-include *.py *.txt
        global-exclude *.py[cod]
        prune dist
        prune build
        prune *.egg-info
        )z	setup.cfgmypkgMANIFEST.inc                 T   t           j                            t                     t	          ddi          }|                                 |                    d          }d}t          j        t          |          5  t          j        d          dk    rt          j        dd	d
           |                                 |                                 d d d            n# 1 swxY w Y   t!          |                    d          j                  }|dz                                  sJ |dz                                  sJ dD ]M}t          j        t(                    5  ||z                                  rJ 	 d d d            n# 1 swxY w Y   Nt          j        d           d S )Nr   	%PEP 517%r   z9Python recognizes 'mypkg\.tests' as an importable package)matchSETUPTOOLS_USE_DISTUTILSstdlibignorez!'encoding' argument not specifiedzdistutils.text_file)modulemypkg/__init__.pyzmypkg/resource_file.txt)zmypkg/tests/__init__.pyzmypkg/tests/test_mypkg.pyzmypkg/tests/test_file.txtzmypkg/testsz#3260)jaracopathr(   EXAMPLE_WITH_MANIFESTr   parse_config_filesget_command_objpytestwarnsr   r   getenvwarningsfilterwarningsfinalize_optionsrunr   	build_libexistsr/   AssertionErrorxfail)r   r   r   msg	build_dirfs         r   test_excluded_subpackagesrT      s,   
K+,,,455D##J//H
FC	2#	>	>	>  
 9/00H<< #3,    	!!###!              $ T))*55?@@I++33555551199;;;;; 	0 	0 ]>** 	0 	0 "A--//////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 Ls%   <AC  C$'C$!FF	F	z/ignore::setuptools.SetuptoolsDeprecationWarningc                    t           j                            t                     t	          ddi          }|                                 |j        sJ |                    d          }|                    d           t          t          |j                                      d                    }|                                sJ |                    d          }|                                 |                    d          }t          |j                  }|                    |d|           |j                            dd	           |                    |           d	|_        |                                 |                                 |                                 |j                            dd	           |                    |           ||_        |                                 |                                 |j        sJ t5          d
 |                                          }|sJ t9          t          |j        d                                        t>          j         d          }||v sJ d	S )zwWhen provided with the ``existing_egg_info_dir`` attribute, build_py should not
    attempt to run egg_info again.
    r   r:   egg_infoz
*.egg-infor   )side_effectrL   
data_filesNc                 B    |                      t          j        d          S )N/replacer   sep)xs    r   <lambda>z(test_existing_egg_info.<locals>.<lambda>   s    AIIbfc22 r   r@   rZ   )!rA   rB   r(   rC   r   rD   include_package_datarE   run_commandnextr   egg_baseglobis_dirrK   r   rL   setattr__dict__popreinitialize_commandexisting_egg_info_dirassert_called
reset_mockassert_not_calledrX   mapget_outputsstrrM   r\   r   r]   )	r   monkeypatchr   rV   egg_info_dirr   egg_info_runoutputsexamples	            r   test_existing_egg_inforv      sW    K+,,,455D$$$$##J//HZ   X.//44\BBCCL      ##J//H##J//HHL111L%666
 ,---h''' &*H"LLNNN    ,---h''' &2H"LLNNN""$$$ 22H4H4H4J4JKKGNNN$x)+>??@@HHQTUUGgr   a;  
        [project]
        name = "mypkg"
        version = "42"

        [tool.setuptools]
        packages = ["mypkg", "mypkg.sub1", "mypkg.sub2", "mypkg.sub2.nested"]

        [tool.setuptools.package-dir]
        "" = "src"
        "mypkg.sub2" = "src/mypkg/_sub2"
        "mypkg.sub2.nested" = "other"
        r7   )r4   zmod1.pyzmod2.py)r4   r5   sub1_sub2)r4   zmod3.pyzL
        global-include *.py *.txt
        global-exclude *.py[cod]
        )pyproject.tomlsrcotherr8   c                 |   t           j                            t                     t	          ddi          }|                                 |                    d          }d|_        |                                 |j	        
                    t          j        d          }d |                                D             }|| d| d| d	| d
| d| d| dhk    sJ d |                                                                D             }|| dd| dd| d	d| d
d| dd| dd| ddik    sJ d S )Nr   z%test%r   TrZ   c                 N    h | ]"}|                     t          j        d           #S rZ   r[   ).0r^   s     r   	<setcomp>z#test_get_outputs.<locals>.<setcomp>8  s(    FFF!qyy%%FFFr   z/mypkg/__init__.pyz/mypkg/resource_file.txtz/mypkg/sub1/__init__.pyz/mypkg/sub1/mod1.pyz/mypkg/sub2/mod2.pyz/mypkg/sub2/nested/__init__.pyz/mypkg/sub2/nested/mod3.pyc                     i | ]D\  }}|                     t          j        d           |                     t          j        d           ES r~   r[   )r   kvs      r   
<dictcomp>z$test_get_outputs.<locals>.<dictcomp>B  sN       Aq 	
		"&#		"&# 6 6  r   zsrc/mypkg/__init__.pyzsrc/mypkg/resource_file.txtzsrc/mypkg/sub1/__init__.pyzsrc/mypkg/sub1/mod1.pyzsrc/mypkg/_sub2/mod2.pyzother/__init__.pyzother/mod3.py)rA   rB   r(   EXAMPLE_ARBITRARY_MAPPINGr   rD   rE   editable_modeensure_finalizedrM   r\   r   r]   ro   get_output_mappingitems)r   r   r   rM   rt   mappings         r   test_get_outputsr   /  s   
K/000122D##J//H!H"**26377IFFx/C/C/E/EFFFG(((...---))))))444000     //117799  G (((*A...0M---/K)))+C)))+D4446I000/      r   c            
       ^   e Zd Z ed           ed           ed          dZdddddidd	hd
dddddiiddhd
dddidddih dd
dZej                            dd ej	        dej        
                    d                    g          ej                            de                                          d                         Zej                            ddg          ej                            de                                          d                         Zd ZdS )TestTypeInfoFileszV
            [project]
            name = "foo"
            version = "1"
            z
            [project]
            name = "foo"
            version = "1"

            [tool.setuptools]
            include-package-data = false
            z
            [project]
            name = "foo"
            version = "1"

            [tool.setuptools]
            include-package-data = false

            [tool.setuptools.exclude-package-data]
            "*" = ["py.typed", "*.pyi"]
            )default_pyprojectdont_include_package_dataexclude_type_infofoor   )bar.pyipy.typedr4   zfoo/bar.pyifoo/py.typed)directory_structureexpected_type_filesbar)r   zmod.pyizfoo/bar/mod.pyizfoo/bar/py.typedzfoo.pyi)	namespace__init__.pyir   >   foo/__init__.pyifoo/namespace/foo.pyir   )simple_namespacenested_inside_namespacenamespace_nested_inside_regular	pyprojectr   r   zpypa/setuptools#4350)r.   )marksru   c                     i | j         |         d         d| j        |         i}| j         |         d         }t          j                            |           t                      }t          |          }||k    sJ d S Nr   ry   r   )EXAMPLES
PYPROJECTSrA   rB   r(   get_finalized_build_pyro   selfr   r   ru   	structurer   r   rt   s           r   #test_type_files_included_by_defaultz5TestTypeInfoFiles.test_type_files_included_by_default  s    
mG$%:;
doi8
 
	 #mG45JK)$$$)++h''"g------r   r   c                    i | j         |         d         d| j        |         i}| j         |         d         }t          j                            |           t                      }t          |          }|                    |          sJ d S r   )r   r   rA   rB   r(   r   ro   
isdisjointr   s           r   test_type_files_can_be_excludedz1TestTypeInfoFiles.test_type_files_can_be_excluded  s    
mG$%:;
doi8
 
	 #mG45JK)$$$)++h''"--g6666666r   c                     t          d          dddd}ddh}t          j                            |           t	                      }t          |          }||k    sJ d S )Nzl
                [project]
                name = "foo-stubs"
                version = "1"
                r   )r   r   )ry   z	foo-stubszfoo-stubs/__init__.pyizfoo-stubs/bar.pyi)r   rA   rB   r(   r   ro   )r   r   r   r   r   rt   s         r   test_stub_only_packagez(TestTypeInfoFiles.test_stub_only_package  s    "  +-<<	
 	
	  89LM)$$$)++h''"g------r   N)__name__
__module____qualname__r   r   r   rF   markparametrizeparamrP   keysr   r   r    r   r   r   r   Q  s       !T
 
 &*T	&
 	&
 "T

 
% JH ! "#% $ %2>#B	
 	
 $&#% $ %67I#J
$
 
$
 !2" %' " $$ $ $,
 ,
-& &HP [FL+k''/E'FF  	
	 	 [Y88
. 
. 98	 	
. [[+>*?@@[Y88
7 
7 98 A@
7. . . . .r   r   %build_py-test%c                     t          d| i          }|                                 |                    d          }|                                 |S )Nr   r   )r   rD   rE   rK   )r   r   r   s      r   r   r     sP    455D##J//HOr   c                 l    t          | j                  fd|                                 D             S )Nc                     h | ]@}t           j                            |                              t           j        d           AS r~   )r   rB   relpathr\   r]   )r   r^   rR   s     r   r   zget_outputs.<locals>.<setcomp>  sK        	9%%--bfc::  r   )r   rM   ro   )r   rR   s    @r   ro   ro     sJ    X'((I   %%''   r   )r   )!r   r+   r!   rI   pathlibr   unittest.mockr   jaraco.pathrA   rF   
setuptoolsr   setuptools.distr   textwrapr   r   r$   r-   r   rP   rO   r3   rC   rT   rJ   rv   r   r   r   r   ro   r   r   r   <module>r      s   				                     3 3 3 3 3 3 ( ( ( ( ( (        (  4  6 $:	     : 	  
 
  4	 1! ! H+ + +\ MNN3 3 ON3n d	   	!#! 
 2

 

   4	 C' ' T  D. . . . . . . .D       r   