\bgk7ddlZddlZddlZddlZddlmZddlmZddlZ ddl Z ddl m Z ddl mZddlmZdZd Zd Ze jd d ed dZeddddddddeddZdZe jddZedddddddddididddedd Zd!ZGd"d#Zd'd%Zd&Z dS)(N)Path)Mock)SetuptoolsDeprecationWarning) Distribution)DALSc ttddgdgddgi}tjd||dS)z Directories matching the glob in package_data should not be included in the package data. Regression test for #261. setup.pybuild_pyzpath/* script_name script_argspackages package_dataz path/subpathN)rdictosmakedirsparse_command_line run_commands tmpdir_cwddists o/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/setuptools/tests/test_build_py.py%test_directories_in_package_data_globrsx  "# Txj)      DKc vttddgdgddgi}tjdt dd||tj tjd j s Jd d S) zt Files matching recursive globs (**) in package_data should be included in the package data. #1806 r r r z path/**/datar zpath/subpath/subsubpathzpath/subpath/subsubpath/datawbz&build/lib/path/subpath/subsubpath/datazFile is not includedN) rrrropencloserrstatS_ISREGst_moders r#test_recursive_in_package_data_globr$%s  "# T~./      DK)*** '..44666 < HIIQ R R Rrc ttddgdgddgi}tjdt ddt ddtjdtjtjdtj| | tj 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 pkgzdata.datr pkg/__init__.pyrz pkg/data.datbuildN) rrrrrr chmodr!S_IREADrrshutilrmtreers rtest_read_onlyr-?s  "# W*.      DK D!!'')))$$&&&H  ---H^T\*** M'rzplatform.system() == "Windows"z-On Windows, files do not have executable bitsT)reasonraisesstrictc ttddgdgddgi}tjdt ddt ddtjdd ||tj d j tj zs Jd d S) zv Ensure executable bit is preserved in copy for package data, as users rely on it for scripts. #2041 r r r&zrun-mer r'rz pkg/run-meizbuild/lib/pkg/run-mezScript is not executableN) rrrrrr r)rrr!r#S_IEXECrs rtest_executable_datar3Zs  "# W(,      DK D!!'')))t""$$$H\5!!! 7) * * 2T\ A" Arz [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)r4resource_file.txttestsz global-include *.py *.txt global-exclude *.py[cod] prune dist prune build prune *.egg-info )z setup.cfgmypkg MANIFEST.incTtjtt ddi}||d}d}tjt|5tj ddkrtj dd d ||dddn #1swxYwYt!|dj}|d z sJ|d z sJdD]M}tjt(5||z rJ dddn #1swxYwYNtjddS)Nr %PEP 517%r z9Python recognizes 'mypkg\.tests' as an importable package)matchSETUPTOOLS_USE_DISTUTILSstdlibignorez!'encoding' argument not specifiedzdistutils.text_file)modulemypkg/__init__.pyzmypkg/resource_file.txt)zmypkg/tests/__init__.pyzmypkg/tests/test_mypkg.pyzmypkg/tests/test_file.txtz mypkg/testsz#3260)jaracopathr(EXAMPLE_WITH_MANIFESTrparse_config_filesget_command_objpytestwarnsrrgetenvwarningsfilterwarningsfinalize_optionsrunr build_libexistsr/AssertionErrorxfail)rrr msg build_dirfs rtest_excluded_subpackagesrTs, K+,,,  4 5 5D##J//H FC 2# > > > 9/ 0 0H < <  #3,     !!### !$T))*55?@@I + + 3 3 5 555 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  Ls%j d }||vsJd S) zwWhen provided with the ``existing_egg_info_dir`` attribute, build_py should not attempt to run egg_info again. rr:egg_infoz *.egg-infor ) side_effectrL data_filesNcB|tjdS)N/replacersep)xs rz(test_existing_egg_info..sAIIbfc22rr@rZ)!rArBr(rCrrDinclude_package_datarE run_commandnextregg_baseglobis_dirrKrrLsetattr__dict__popreinitialize_commandexisting_egg_info_dir assert_called reset_mockassert_not_calledrXmap get_outputsstrrMr\rr]) r monkeypatchrrV egg_info_dirr egg_info_runoutputsexamples rtest_existing_egg_inforvsW K+,,,  4 5 5D  $$$ $##J//HZ   X.//44\BBCCL      ##J//H ##J//HHL111L%666  ,---h'''&*H" LLNNN    ,---h'''&2H" LLNNN""$$$   22H4H4H4J4JKKG NN7$x)+>??@@HHQTUUG g      ra; [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)r4zmod1.pyzmod2.py)r4r5sub1_sub2)r4zmod3.pyzL global-include *.py *.txt global-exclude *.py[cod] )pyproject.tomlsrcotherr8c|tjtt ddi}||d}d|_||j tj d}d| D}||d|d|d |d |d |d |d hksJd|D}||dd|dd|d d|d d|d d|d d|d diksJdS)Nrz%test%r TrZcNh|]"}|tjd#SrZr[).0r^s r z#test_get_outputs..8s(FFF!qyy%%FFFrz/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.pyci|]D\}}|tjd|tjdESr~r[)rkvs r z$test_get_outputs..BsN Aq "&# "&# 6 6rzsrc/mypkg/__init__.pyzsrc/mypkg/resource_file.txtzsrc/mypkg/sub1/__init__.pyzsrc/mypkg/sub1/mod1.pyzsrc/mypkg/_sub2/mod2.pyzother/__init__.pyz other/mod3.py)rArBr(EXAMPLE_ARBITRARY_MAPPINGrrDrE editable_modeensure_finalizedrMr\rr]roget_output_mappingitems)rrr rMrtmappings rtest_get_outputsr/s K/000 1 2 2D##J//H!H "**26377IFFx/C/C/E/EFFFG  ((( ... --- ))) ))) 444 000    //117799G  (((*A ...0M ---/K )))+C )))+D 4446I 000/      rc ^eZdZedededdZdddddidd hd dd ddd iid dhd dddidddihdd dZejddej dej dgejde dZ ejddgejde dZ dZdS)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_pyprojectdont_include_package_dataexclude_type_infofoor )bar.pyipy.typedr4z foo/bar.pyi foo/py.typed)directory_structureexpected_type_filesbar)rzmod.pyizfoo/bar/mod.pyizfoo/bar/py.typedzfoo.pyi) namespace __init__.pyir>foo/__init__.pyifoo/namespace/foo.pyir)simple_namespacenested_inside_namespacenamespace_nested_inside_regular pyprojectrrzpypa/setuptools#4350)r.)marksruci|j|dd|j|i}|j|d}tj|t }t |}||ksJdSNrryr)EXAMPLES PYPROJECTSrArBr(get_finalized_build_pyroselfrrru structurerr rts r#test_type_files_included_by_defaultz5TestTypeInfoFiles.test_type_files_included_by_defaults mG$%:; doi8  #mG45JK )$$$)++h''"g------rrci|j|dd|j|i}|j|d}tj|t }t |}||sJdSr)rrrArBr(rro isdisjointrs rtest_type_files_can_be_excludedz1TestTypeInfoFiles.test_type_files_can_be_excludeds mG$%:; doi8  #mG45JK )$$$)++h''"--g6666666rctddddd}ddh}tj|t }t |}||ksJdS)Nzl [project] name = "foo-stubs" version = "1" r )rr)ryz foo-stubszfoo-stubs/__init__.pyizfoo-stubs/bar.pyi)rrArBr(rro)rrrrr rts rtest_stub_only_packagez(TestTypeInfoFiles.test_stub_only_packages"+-<<    89LM )$$$)++h''"g------rN)__name__ __module__ __qualname__rrrrFmark parametrizeparamrPkeysrrrrrrrQs!T   &*T  & & "T    %JH! "#%$%2>#B   $&#%$%67I#J $ $ !2"%' " $$$$, , -&&HP [  FL+k''/E'FF       [Y 88 . .98   . [[+>*?@@ [Y 88 7 798A@ 7.....rr%build_py-test%ctd|i}||d}||S)Nrr )rrDrErK)rrr s rrrsP  4 5 5D##J//H  Orclt|jfd|DS)Nch|]@}tj|tjdASr~)rrBrelpathr\r])rr^rRs rrzget_outputs..sK     9%%--bfc::   r)rrMro)r rRs @rrorosJX'((I    %%''   r)r)!rr+r!rIpathlibr unittest.mockr jaraco.pathrArF setuptoolsrsetuptools.distrtextwraprrr$r-rrPrOr3rCrTrJrvrrrrrorrrrs  333333(((((((46$ :      :     4 1!!H+++\MNN33ON3nd  !#! 2    4 C''TD........Dr