K ih ~dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddlm Z ddl mZddlZddlZddlmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lm Z d dl!m"Z"ddl#Z#ddl$m%Z%dddgddgidejLjOddgfgdZ(de(dZ)edejLjOddgejLjOddgZ*e*jVe*jXzZ-ej\dZ/dZ0dZ1d Z2d!Z3ejhjke3d"#Z6ejhjod$d%#Z8ejhjoe#jrjud& d'#Z;d(Zd,Z?Gd-d.Z@d/ZAd0ZBy)1z sdist testsNcleandoc)Path)mock)CommandSetuptoolsDeprecationWarning)metadata)manifest_maker)sdist) Distribution) Extension) fail_on_ascii) Filenames) run_setup sdist_testz0.0z*.txtdatade.dat)nameversionpackages package_data data_filesz&from setuptools import setup setup(**z) sdist_test.fzf.cf.hrsourcesdependsc#2Ktjtj}}tjtjct_t_ d||ct_t_y#||ct_t_wxYwwN)sysstdoutstderrioStringIO) old_stdout old_stderrs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/tests/test_sdist.pyquietr*6s[ ZZ J[[]BKKMCJ 8 !+Z CJZ CJsABA;#B;BBct|ts/|jtjj ddS|jtjdS)Nascii//) isinstancestrreplaceossepencodepaths r)posixr7As? dC ||BFFMM'2D99||BFFC((ct|trtjd|S |j d}tjd|}|j d}|S#t $rY|SwxYw)NNFDutf-8)r/r0 unicodedata normalizedecoder4 UnicodeErrorr5s r) decomposer@Isr$$$UD11 {{7#$$UD1{{7# K   K s8A"" A/.A/cft|d5}|jcdddS#1swYyxYw)Nrb)openread)filenamefps r)read_all_bytesrGUs, h wwys'0c tjtj\}}t j |t j |y#t$rYywxYw)N)suffixT)tempfilemkstemprlatin_1r2closeremove Exception)descrEs r) latin1_failrQZsJ!))1B1BCh  ( sAA A A z)System does not support latin-1 filenames)reasonz%os.environ.get('PYTEST_XDIST_WORKER')zpytest-dev/pytest-xdist#843 setuptoolsz/the test is not supported with stdlib distutilsc:t|dj|S)Nwb)rCrMr5s r)touchrVsst Kr8c tj|||S#ttf$rt j dYywxYw)Nzsymlink not supported in OS)r2symlinkOSErrorNotImplementedErrorpytestskip)srcdsts r)symlink_or_skip_testr_xsC 3 J ( ) 12s$AAceZdZejddZdZdZdZdZ dZ d Z d Z d d d ddZ eejj!de j#dZdZdZdZdZdZdZedZedZedZedZedZ eedZ!e"dZ#eedZ$d d!d"d#d$Z%ejj!d%e%j#ejjMd&d'Z'd(Z(d)Z)d*Z*ejjWd+d,Z,y-). TestSdistTestT)autousec#K|dz }|j|dz jtd|dz }|j|dz }|jdD]}t||z t|dz tD]}t||z |j 5|dddy#1swYyxYww) N project_rootsetup.pyr;encodingrr)z __init__.pya.txtb.txtc.rstr)mkdir write_textSETUP_PYrVEXTENSION_SOURCESas_cwd)selftmpdirtest_pkg data_folderfnames r) source_dirzTestSdistTest.source_dirs.(  * ((G(DL(sl @ $E (U" # $ kG#$' "E &5. ! "]]_ L   sB&C(B6- C6B?;CcP|jj}tjj dd|vsJtjj dd|vsJtjj dd|vsJtjj dd|vsJy)Nrrhrirjrr)filelistfilesr2r6join)rpcmdmanifests r)assert_package_data_in_manifestz-TestSdistTest.assert_package_data_in_manifests<<%%ww||L'2h>>>ww||L'2h>>>ww||L'2(BBBww||C)X555r8citdtgi}t|}d|_t |}|j t 5|jddd|S#1swY|SxYw)N ext_modulesre) SETUP_ATTRS EXTENSIONr script_namer ensure_finalizedr*runrp setup_attrsdistrzs r)setup_with_extensionz"TestSdistTest.setup_with_extensionshAAmi[A K(%Dk  W  GGI    s A$$A.ctt}d|_t|}|j t 5|j ddd|j|y#1swYxYw)zRegression test for pull request #4: ensures that files listed in package_data are included in the manifest even if they're not added to version control. reN)r rrr rr*rr|)rprrzs r)test_package_data_in_sdistz(TestSdistTest.test_package_data_in_sdists^ K(%Dk  W  GGI  ,,S1  s A''A0citddi}|dsJt|}d|_t|}|j t 5|j ddd|j|y#1swYxYw)zU Ensure package_data and include_package_data work together. include_package_dataTrreN)rr rr rr*rr|rs r)3test_package_data_and_include_package_data_in_sdistzATestSdistTest.test_package_data_and_include_package_data_in_sdists DC&***K(%Dk  W  GGI  ,,S1  s A66A?c|j}|j||jj}tD]}||vrJy)z Ensure that the files listed in Extension.sources and Extension.depends are automatically included in the manifest. N)rr|rwrxrn)rprzr{r6s r)test_extension_sources_in_sdistz-TestSdistTest.test_extension_sources_in_sdistsL '') ,,S1<<%%% $D8# ## $r8ctD]}tj||j}|j ||j j }tD]}||vrJy)z Similar to test_extension_sources_in_sdist but the referenced files don't exist. Missing files should not be included in distribution (with no error raised). N)rnr2rNrr|rwrx)rpr6rzr{s r)test_missing_extension_sourcesz,TestSdistTest.test_missing_extension_sourcessh & D IIdO '') ,,S1<<%%% (Dx' '' (r8cg}tD]|}tjj|\}}|dz|z}tj||t tjj |||j|~|j}|j||jj}tD]}||vrJ|D]}||vrJy)z Similar to test_extension_sources_in_sdist but the referenced files are instead symbolic links to project-local files. Referenced file paths should be included. Symlink targets themselves should NOT be included. z_target.N) rnr2r6splitextrenamer_basenameappendrr|rwrx)rp symlinkedr6baseexttargetrzr{s r) test_symlinked_extension_sourcesz.TestSdistTest.test_symlinked_extension_sourcess  % %D((.ID#J&,F IIdF # !1!1&!94 @   V $  %'') ,,S1<<%%% $D8# ## $ (Dx' '' (r8c|tjjtjjddS)Nrr)r2r6abspathryr8r)zTestSdistTest.s& GGOOBGGLLu= >r8cFtjjddddS)Nr..rr2r6ryrr8r)rzTestSdistTest.s GGLLt\5 Ar8cBtjjddS)Nrzthis_file_does_not_exist.hrrr8r)rzTestSdistTest.s GGLL'C Dr8chtttjj dddS)Nrzoutside_of_project_root.hz symlink.h)r_rVr2r6ryrr8r)rzTestSdistTest. s* bggll4)DEF r8)zmust be relativezcan't have `..` segmentsz doesn't existzmust be inside the project rootrRc|j|}tdg|g}itd|gi}t|}d|_t |}|j t5|jtj5|jdddddd|j||jj}||vsJ|jD cgc]$\} } } | dk(r| tjk(r|| vr| &} } } } t!| dk(sJ| \} || vsJy#1swYxYw#1swYxYwcc} } } w)a Due to backwards compatibility reasons, `Extension.depends` should accept invalid/weird paths, but then ignore them when building a sdist. This test verifies that the source distribution is still built successfully with such paths, but that instead of adding these paths to the manifest, we emit an informational message, notifying the user that the invalid path won't be automatically included. rrr~reNrootr)_INVALID_PATHSr rr rr rr*at_levelloggingINFOrr|rwrx record_tupleslen) rprRcaplog invalid_path extensionrrrzr{loggerlevelmessageexpected_messages r)test_invalid_extension_dependsz,TestSdistTest.test_invalid_extension_dependss^3t**624 !N BAmi[A K(%Dk  W foogll3  GGI   ,,S1<<%%8+++-3,@,@  (& W\\) G+   #$))). ))))%     s*( D:D.D:&)E.D7 3D::EcPddlm}tjGfdd|}itddi}|dsJt |}d|_t|}|jd |i|_ d |i|j_ |jjd |k(sJd }t5tjt| 5|j!d d d d d d j#|j%|y #1swY3xYw#1swY7xYw) zq Ensure projects defining custom build_py don't break when creating sdists (issue #2849) r)build_pyc&eZdZdZfdZxZS)9TestSdistTest.test_custom_build_py..CustomBuildPyzX Some projects have custom commands inheriting from `distutils` c.t|Sr!)superget_data_files)rp __class__using_custom_command_guards r)rzHTestSdistTest.test_custom_build_py..CustomBuildPy.get_data_filesNs*,w-//r8)__name__ __module__ __qualname____doc__r __classcell__)rrs@r) CustomBuildPyrIs  0 0r8rrTrrerzsetuptools instead of distutils)matchN)distutils.command.build_pyrrMockrr rr rcmdclass distributionget_command_classr*r[warnsrr assert_calledr|)rp OrigBuildPyrrrrzmsgrs @r)test_custom_build_pyz"TestSdistTest.test_custom_build_py@s G%)YY[" 0K 0DC&***K(%Dk #M2 %/$?!11*=NNN/ W fll#?sK  GGI   #002 ,,S1     s$1D DDD DD%ctt}d|_t|}|j t 5|j ddd|jj}d|vsJy#1swY&xYwNfoo.pyre) r rrr rr*rrwrxrprrzr{s r)test_setup_py_existsz"TestSdistTest.test_setup_py_existsfskK(#Dk  W  GGI <<%%X%%%   s A22A;cdtt}d|_t|}|j t j jdrt jdt5|jddd|jj}d|vsJy#1swY&xYwr) r rrr rr2r6existsrNr*rrwrxrs r)test_setup_py_missingz#TestSdistTest.test_setup_py_missingrsK(#Dk  77>>* % IIj ! W  GGI <<%%)))   s 0B&&B/cdtddd5}|jddddtt}d|_t |}|j t5|jddd|jj}d|vsJy#1swYzxYw#1swY2xYw)N MANIFEST.inwr;rfzexclude setup.pyrre) rCwriter rrr rr*rrwrx)rp manifest_filerrzr{s r)test_setup_py_excludedz$TestSdistTest.test_setup_py_excludeds -w 7 4=    2 3 4K(#Dk  W  GGI <<%%))) 4 4  sB$B&B#&B/ct|dz t|dz tt}d|_t |}|j t 5|jdddtd|jj}d|vsJ|d|vsJ|d|vsJ|y#1swYLxYw)z Make sure default files (README.*, etc.) are added in a case-sensitive way to avoid problems with packages built on Windows. z readme.rstz SETUP.cfgzsetup.PYNc"|jSr!)lower)xs r)rz>TestSdistTest.test_defaults_case_sensitivity..s r8rez setup.cfg) rVr rrr rr*rmaprwrxrprurrzr{s r)test_defaults_case_sensitivityz,TestSdistTest.test_defaults_case_sensitivitys j<'( j;&'K(&Dk  W  GGI  *CLL,>,>?8+5X5+)383)(*4H4*  s B44B=cdddddddd}dddd}i||jD]I\}}t||jjddt||j |dK|j }|j ||jjDchc]"}|jtjd $}}|D]0} tjj| sJ| |vr)J| |f|D]0} tjj| sJ| |vr)J| |fycc}w) NzJglobal-include LICEN[CS]E* COPYING* NOTICE* AUTHORS* global-include *.txt )rzBtest/.venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rstzDsrc/.nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txtzEdoc/.tox/default/lib/python3.11/site-packages/foo-4.dist-info/LICENSEz.venv-requirements.txtz.tox-coveragerc.txtz.noxy/coveragerc.txt)zA.tox/release/lib/python3.11/site-packages/foo-4.dist-info/LICENSEz@.nox/py/lib/python3.12/site-packages/bar-2.dist-info/COPYING.txtz=.venv/lib/python3.9/site-packages/bar-2.dist-info/AUTHORS.rstT)parentsexist_okr;rfr.)itemsrparentrkrlrr|rwrxr1r2r3r6r) rpruincludedexcludedfilecontentrzfr{r6s r)#test_exclude_dev_only_cache_foldersz1TestSdistTest.test_exclude_dev_only_cache_folderssh) SUTVUW&(#%$& (RTPRMO  65H5;;= IMD' T " ) ) / /t / L T " - -g - H I'') ,,S147LL4F4FGqAIIbffc*GG :D77>>$' ''x' 9$)9 9' : 6D77>>$' ''8# 5dH%5 5# 6 Hs*'D>c.tt}d|_t|}tj j dd|_t jdtj j dd}t|t5|j|jj||jdddt|j}|j!d}t#||vsJy#1swY?xYw)Nresdist_test.egg-info SOURCES.txtru smörbröd.pyUTF-8)r rrr r2r6ryr{rkrVr*rrwrwrite_manifestrGr>r7)rprmmrEcontents u_contentss r)+test_manifest_is_written_with_utf8_encodingz9TestSdistTest.test_manifest_is_written_with_utf8_encodingsK(% D !ggll#8-H  &'77<< o> hW FFH KK  x (     ""++.__W- X*,,,  s rwrxrrrGr7rprrrE u_filenamers r))test_write_manifest_allows_utf8_filenamesz7TestSdistTest.test_write_manifest_allows_utf8_filenamessK(% D !ggll#8-H  &'77<< y? hW FFH!1J KK   $ $Z 0      ""++.  X(***R[[.....!  s AEEctt}d|_t|}tj j dd|_t jdtj j dtj}t5|j|jdd}|jj||j!dddt#|j}|jdt%||vsJ|jj&vsJy#1swYYxYw) a Files that cannot be encoded to UTF-8 (specifically, those that weren't originally successfully decoded and have surrogate escapes) should be omitted from the manifest. See https://bitbucket.org/tarek/distribute/issue/303 for history. rerrrr;surrogateescapeNr)r rrr r2r6ryr{rkrrLr*rr>rwrrrGr7rxrs r),test_write_manifest_skips_non_utf8_filenamesz:TestSdistTest.test_write_manifest_skips_non_utf8_filenamessK(% D !ggll#8-H  &'77<< y/@/@AW FFH!2CDJ KK  z *      ""++.  Xh...!2!2222!  s AD::Ectt}d|_t|}|j t 5|j dddtjjdtj}tjjdd|_ t|jd}|jd|z|jt!|g|j"_t 5|j'ddd|j)d}||j"j$vsJy#1swYxYw#1swYBxYw)Nrerrrab r;)r rrr rr*rr2r6ryrrr{rCrrMrVrwrx read_manifestr>rprrzrEr{s r)(test_manifest_is_read_with_utf8_encodingz6TestSdistTest.test_manifest_is_read_with_utf8_encoding5sK(%Dk W  GGI 77<< y?ww||$9=I  d+ux'( h   W     ??7+3<<-----)    E E EE#ctt}d|_t|}|j t 5|j dddtjjdtj}tjjdd|_ t|jd}|jd|z|jt!|g|j"_t 5|j'ddd|j)d}||j"j$vsJy#1swYxYw#1swYBxYw)Nrerrrrrlatin-1)r rrr rr*rr2r6ryrrLr{rCrrMrVrwrxrr>rs r)+test_read_manifest_skips_non_utf8_filenamesz9TestSdistTest.test_read_manifest_skips_non_utf8_filenamesTsK(%Dk W  GGI 77<< y/@/@Aww||$9=I  d+ux'( h   W     ??9-s||11111)    rct|jt}d|_t |}|j t jjdtj}t|t5|jdddtjdk(r t!|}tj"}tjdk(r]|dk(r+|j%d}||j&j(vs.J|j%d}||j&j(vsJyy|j%d}||j&j(vsJy#1swYxYw)Nrerdarwinwin32cp1252mbcsr;)r make_stringsrrr rr2r6ryrrrVr*rr"platformr@getfilesystemencodingr>rwrxrprrzrEfs_encs r)%test_sdist_with_utf8_encoded_filenamez3TestSdistTest.test_sdist_with_utf8_encoded_filenamess+D--k:;%Dk 77<< y? h W  GGI  <<8 # *H**, <<7 "!#??843<<#5#5555#??623<<#5#55556  w/Hs||111 11%  s E++E4ct|tr3|jDcic]\}}||j|c}}St|trt t |j|St |Scc}}wr!)r/dictrrlistrr0)clsitemkeyvalues r)rzTestSdistTest.make_stringssi dD !CG::<PZS%C))%00P P dD !C,,d34 44yQsA>ct|jt}d|_t |}|j t jjdtj}t|t jj|sJt5|jdddtj dk(rGtj"}|dk7rd}|j%|}||j&j(vsJy|j%d}||j&j(vsJy#1swYxYw)Nrerr rr )r rrrr rr2r6ryrrLrVisfiler*rr"rrr>rwrxrs r)'test_sdist_with_latin1_encoded_filenamez5TestSdistTest.test_sdist_with_latin1_encoded_filenames D--k:;%Dk 77<< y/@/@A hww~~h''' W  GGI  <<7 "..0F"v.Hs||111 11 y1H3<<#5#55 55!  s %EE z [metadata] name = testing version = file: src/VERSION.txt license_files = DOWHATYOUWANT long_description = file: README.rst, USAGE.rst a  [project] name = "testing" readme = "USAGE.rst" license-files = ["DOWHATYOUWANT"] dynamic = ["version"] [tool.setuptools.dynamic] version = {file = ["src/VERSION.txt"]} a [project] name = "testing" readme = "USAGE.rst" license-files = ["DOWHATYOUWANT"] dynamic = ["version"] [tool.setuptools.dynamic] version = {file = "src/VERSION.txt"} a  [project] name = "testing" readme = "USAGE.rst" license = {file = "DOWHATYOUWANT"} dynamic = ["version"] [tool.setuptools.dynamic] version = {file = "src/VERSION.txt"} )z(setup.cfg - long_description and versionz@pyproject.toml - static readme/license files and dynamic versionz3pyproject.toml - directive with str instead of listz9pyproject.toml - deprecated license table with file entryconfigz6ignore:.project.license. as a TOML table is deprecatedc^|jd\}}}|j|}|dz j|dz jdd|dz jdd|d z jdd|d z jdd||z j|dt d gi}d |_|j t|}|jt5|jdddd|jjvsd |jjvsJd |jjvsJd |jjvsJd|jjvsJd|jjvsJy#1swYxYw)Nz - r]zsrc/VERSION.txtz0.42r;rfz README.rstz hello world!z USAGE.rst DOWHATYOUWANTrrezsrc\VERSION.txtr.\) partition_EXAMPLE_DIRECTIVESrkrlr rparse_config_filesr rr*rrwrx)rprur  config_file_ config_textrrzs r).test_add_files_referenced_by_config_directivesz.build_customcyr!rrps r)initialize_optionszYTestSdistTest.test_build_subcommand_source_files..build_custom.initialize_options0r8cyr!rr9s r)finalize_optionszWTestSdistTest.test_build_subcommand_source_files..build_custom.finalize_options2r;r8cyr!rr9s r)rzJTestSdistTest.test_build_subcommand_source_files..build_custom.run4r;r8cdgS)Nr3rr9s r)get_source_fileszWTestSdistTest.test_build_subcommand_source_files..build_custom.get_source_files6s "|#r8N)rrrr:r=rr@rr8r)r5r7/s - +  $r8r5)r5T)rVr rr rr*rrwrxget_command_obj sub_commandsrrupdate use_defaults)rprurrzr{r4r5s r)"test_build_subcommand_source_filesz0TestSdistTest.test_build_subcommand_source_filess? j:%&F{FM:FGDk  W  GGI <<%%)))F{FM:FG$$W-Ju11J3IJ $7 $ ,7Dk  W  GGI <<%%X%%%9  2  s EEEEz6os.environ.get('SETUPTOOLS_USE_DISTUTILS') == 'stdlib'c titdddtjdiid}t |}|j t 5|jdddy#1swYyxYw)zS Ensure if build_base is a pathlib.Path, the build still succeeds. rer4 build_base)roptionsN)r rpathlibrr rr*r)rprurrzs r)test_build_base_pathlibz%TestSdistTest.test_build_base_pathlibCss   %, W0E!FG   Dk  W  GGI   s A--A6N)-rrrr[fixturerur|rrrrrrrskip_under_stdlib_distutilsmark parametrizekeysrrrrrrrrrrskip_under_xdistrr fail_on_latin1_encoded_filenamesr r classmethodrrr%filterwarningsr*r-r1rEskipifrJrr8r)rarasV^^D!"06 2 2$ $ ((0 %  , N$! [[X~':':'<=)*>!)*V$2L & * *58&6P--8//@!3!3F..<&2&2<%2&2<&6&6>5M@F5#J [[X':'?'?'AB [[@.C.8 ,0 #&J [[PQ R r8ractjjd\}|j}t |dsJy)a When _default_revctrl was removed from the `setuptools.command.sdist` module in 10.0, it broke some systems which keep an old install of setuptools (Distribute) around. Those old versions require that the setuptools package continue to implement that interface, so this function provides that interface, stubbed. See #320 for details. This interface must be maintained until Ubuntu 12.04 is no longer supported (by Setuptools). zg [setuptools.file_finders] svn_cvs = setuptools.command.sdist:_default_revctrl __iter__N)r EntryPoints _from_textloadhasattr)epress r)test_default_revctrlr]Ss>  + +  ER '')C 3 ## #r8ceZdZdZedZejjdddZ edZ ejjdddZ y ) TestRegressionszp Can be removed/changed if the project decides to change how it handles symlinks or external files. c6dddiitd|dddddS) Ndirfile.hr[ from setuptools import Extension, setup setup( name="myproj", version="42", ext_modules=[ Extension( "hello", sources=["hello.pyx"], depends=[e] ) ], ) global-include *.hrez hello.pyxrexternalprojectr)tmp_pathdep_paths r)&files_for_symlink_in_extension_dependsz6TestRegressions.files_for_symlink_in_extension_dependsnsI"~%*+36  3#   r8rk)zmyheaders/dir/file.hzmyheaders/dir/../dir/file.hc|j||}tjj|t |t |dz |dz t ||dz }dD]}||vrJy)Nprefixrhzproject/myheadersri)zmyproj-42/hello.pyxzmyproj-42/myheaders/dir/file.h)rljaracor6r4r0r_ run_sdist)rp monkeypatchrjrkrxmembersexpecteds r)!test_symlink_in_extension_dependsz1TestRegressions.test_symlink_in_extension_dependssz ;;HhO %H 6X 2H?R4RSKI)=>  'Hw& &&  'r8c|jd\}}}|r||z n|}dddiitdt|ddddd S) Nz $tmp_path$/rarbrrcrdrerfrg)r$rr0)rjrkheadr(tails r),files_for_external_path_in_extension_dependsz (D4' '' (r8N) rrrr staticmethodrlr[rMrNruryr{rr8r)r_r_hs   4 [[K ' '  : [[P((r8r_cP|j|t5tddgdddt|dz j d}t j t|5}t|jcdddS#1swYgxYw#1swYyxYw)z@Given a project directory, run the sdist and return its contentsrer Nrz*.tar.gz) chdirr*rnextglobtarfilerCr0setgetnames)rrriarchivetars r)rqrqsg )*wi()Gf$**:67G c'l ##s3<<>"## ))##sB-BBB%ctj|5}|j}dddDcgc] }d|vs| }}t|dk(s Jd|y#1swY6xYwcc}w)Nz.toxrz not empty )rrCrr)setuptools_sdistrrxr tox_filess r)&test_sanity_check_setuptools_own_sdistrsn & '3 #(:$6T>:I: y>Q 8*YK 88  ;sA A(A(A%)Cr contextlibr%rr2rIr"rrJr<inspectrrunittestr jaraco.pathrpr[rSrrsetuptools._importlibr setuptools.command.egg_infor setuptools.command.sdistr setuptools.distr setuptools.extensionr setuptools.testsrtextr distutilsdistutils.corerr6ryrrmrrrrncontextmanagerr*r7r@rGrQrMxfailrQrTrP __package__ startswithrLrVr_rar]r_rqrrr8r)rs    <*6*(**$ !G9-RWW\\#w789:        WW\\, . / WW\\, . /  %% (9(99 88)  $*;;#4#4M 6$5$ ;;%%+ (&%kk00((66 <1  O O d$*\(\(~#9r8