
    ,hj7                        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(                  j+                  dded      d        Z ed      ddddddd ed      dZd Ze
j(                  j5                  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 y)'    N)Path)Mock)SetuptoolsDeprecationWarning)Distribution   )DALSc           	          t        t        ddgdgddgi            }t        j                  d       |j	                          |j                          y)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/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/tests/test_build_py.py%test_directories_in_package_data_globr      sS     "#Txj)		
D KK    c           	      N   t        t        ddgdgddgi            }t        j                  d       t	        dd      j                          |j                          |j                          t        j                  t        j                  d	      j                        sJ d
       y)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 KK)*	'.446<< HIQQR Rr   c           	         t        t        ddgdgddgi            }t        j                  d       t	        dd      j                          t	        dd      j                          t        j                  dt        j                         t        j                  dt        j                         |j                          |j                          t        j                  d	       y
)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 KK	D!'')$$&HH-HH^T\\*
MM'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      j                          t	        dd      j                          t        j                  dd	       |j                          |j                          t        j                  d
      j                  t        j                  z  sJ d       y)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 KK	D!'')t""$HH\5!77)*22T\\A "Ar   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         j                  j                  t               t	        ddi      }|j                          |j                  d      }d}t        j                  t        |      5  t        j                  d      dk(  rt        j                  dd	d
       |j                          |j                          d d d        t!        |j                  d      j"                        }|dz  j%                         sJ |dz  j%                         sJ dD ]:  }t        j&                  t(              5  ||z  j%                         rJ 	 d d d        < t        j*                  d       y # 1 sw Y   xY w# 1 sw Y   hxY w)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      sT   
KK+,45D##J/H
FC	2#	> 
 99/0H< ##3, 	!!#!$ T))*5??@I++33551199;; 	0 ]]>* 	0 "A--///	0 	0	0 LLG <	0 	0s   /AE+4E7+E47F 	z/ignore::setuptools.SetuptoolsDeprecationWarningc                 h   t         j                  j                  t               t	        ddi      }|j                          |j                  sJ |j                  d      }|j                  d       t        t        |j                        j                  d            }|j                         sJ |j                  d      }|j                          |j                  d      }t        |j                         }|j#                  |d|       |j$                  j'                  dd	       |j)                  |       d	|_        |j!                          |j-                          |j/                          |j$                  j'                  dd	       |j)                  |       ||_        |j!                          |j1                          |j2                  sJ t5        d
 |j7                               }|sJ t9        t        |j:                  d            j=                  t>        j@                  d      }||v sJ y	)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    | j                  t        j                  d      S N/)replacer   sep)xs    r   <lambda>z(test_existing_egg_info.<locals>.<lambda>   s    AIIbffc2 r   r@   r[   )!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      s    KK+,45D$$$##J/HZ X../44\BCL   ##J/H##J/HHLL1L%6
 ,-h' &*H"LLN  ,-h' &2H"LLN""$ 2H4H4H4JKGN$x))+>?@HHQT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                  j                  t               t	        ddi      }|j                          |j                  d      }d|_        |j                          |j                  j                  t        j                  d      }|j                         D ch c]"  }|j                  t        j                  d      $ }}|| d| d| d| d	| d
| d| dhk(  sJ |j                         j                         D ci c]D  \  }}|j                  t        j                  d      |j                  t        j                  d      F }}}|| dd| dd| dd| d	d| d
d| dd| ddik(  sJ y c c}w c c}}w )Nr   z%test%r   Tr[   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.pyz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   r^   rt   kvmappings	            r   test_get_outputsr   /  s   
KK/012D##J/H!H""**26637I/7/C/C/EF!qyy%FGF+'(+-.+,-+()+()+34+/0   //1779Aq 	
		"&&#		"&&# 66G  +'(*A+-.0M+,-/K+()+C+()+D+346I+/0/    Gs   %'F	A	Fc            
       0   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                  j                  dd ej                  dej                  j                  d            g      ej                  j                  dej                               d               Zej                  j                  ddg      ej                  j                  dej                               d               Zd Zy)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                  j	                  |       t               }t        |      }||k  sJ y 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|    
mmG$%:;
dooi8
	 #mmG45JK)$)+h'"g---r   r   c                     i | j                   |   d   d| j                  |   i}| j                   |   d   }t        j                  j	                  |       t               }t        |      }|j                  |      sJ y r   )r   r   rA   rB   r(   r   ro   
isdisjointr   s           r   test_type_files_can_be_excludedz1TestTypeInfoFiles.test_type_files_can_be_excluded  s    
mmG$%:;
dooi8
	 #mmG45JK)$)+h'"--g666r   c                     t        d      dddd}ddh}t        j                  j                  |       t	               }t        |      }||k  sJ y )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   !
 &*	&
 "

%JH ! "#%$ %2>#B	
 $&#%$ %67I#J
$
 !2" %' "$$,
-&HP [[FLL+kk''/E'F	
	 [[Y8
. 9	
. [[[+>*?@[[Y8
7 9 A
7.r   r   c                     t        d| i      }|j                          |j                  d      }|j                          |S )Nr   r   )r   rD   rE   rK   )r   r   r   s      r   r   r     s>    45D##J/HOr   c                     t        | j                        }| j                         D ch c]@  }t        j                  j                  ||      j                  t        j                  d      B c}S c c}w rZ   )r   rM   ro   r   rB   relpathr\   r]   )r   rR   r^   s      r   ro   ro     s]    X''(I %%' 	9%--bffc:  s   AA0)z%build_py-test%)!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      sU   	        3 ( (46 $:	  : 	 
 	1! H+\ MN3 O3n 	  	!#!
 2

  	C' TD. .Dr   