;if ddlZddlZddlZddlZddlZddlZddlZddlZddlZej ej  ddl Z n #e $rdZ YnwxYwddlZddlmZddlmZddlmZmZmZddlmZddlmZddlmZddlmZd Zhd Z ej!"d d d kZ#d Z$ej%dddZ&dZ'dZ(dZ)dZ*dZ+dZ,ej-dZ.ej-dZ/ej-dZ0GddZ1ej-ddZ2ej-dd g!d"Z3ej-d#Z4ej-d$e1fd%Z5dS)&N)__main__) configure) is_cygwin is_darwinis_win)initialize_modgraph)pkg_archive_contents)gen_sourcefile)winutils>linuxwin32darwinPYI_BUILDER_CLEANUP1ctd|D}tj}|r||vrt jd|dSdSdS)aR Markers to skip tests based on the current platform. https://pytest.org/en/stable/example/markers.html#marking-platform-specific-tests-with-pytest Available markers: see setup.cfg [tool:pytest] markers - @pytest.mark.darwin (macOS) - @pytest.mark.linux (GNU/Linux) - @pytest.mark.win32 (Windows) c3$K|] }|jV dSN)name).0marks NC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\PyInstaller/utils/conftest.py z'pytest_runtest_setup..As$5`5`Ddi5`5`5`5`5`5`zdoes not run on N)SUPPORTED_OSES intersection iter_markerssysplatformpytestskip)itemsupported_platformsplats rpytest_runtest_setupr%7s|)555`5`DL]L]L_L_5`5`5``` >> -t--.....//>>rT)tryfirst hookwrapperc#lKdV}|}t|d|j|dS)Nrep_) get_resultsetattrwhen)r"calloutcomereps rpytest_runtest_makereportr0GsGeeG     C D###S)))))rc>|jjSr)pathresolveparentrequests r _get_base_dirr7Rs <   ! ! ((rc&t|dz S)Nscriptsr7r5s r_get_script_dirr;W  ! !I --rc&t|dz S)Nmodulesr:r5s r_get_modules_dirr?\r<rc&t|dz S)Nlogsr:r5s r _get_logs_dirrBa  ! !F **rc&t|dz S)Ndatar:r5s r _get_data_dirrFfrCrc&t|dz S)Nspecsr:r5s r _get_spec_dirrIks  ! !G ++rc t|S)z@ Return the directory where the test spec-files reside. )rIr5s rspec_dirrKos  ! !!rc t|S)z= Return the directory where the test scripts reside. )r;r5s r script_dirrMws 7 # ##rc|jjdd}t||z }|dz }tj|||S)NrE)function__name__rFshutilcopytree)r6tmp_path test_namesource_data_dir tmp_data_dirs rdata_dirrXsN )!""-I$G,,y8Of$L OO\222 rcTeZdZdZdZdZdZ ddZdZd Z d Z d Z d Z d Z dS) AppBuilderct||_||_||_||_|dz |_|dz |_d|_dS)NdistbuildF) _tmp_path_request_mode _spec_dir _dist_dir _build_dir_is_spec)selfrTr6 bundle_modes r__init__zAppBuilder.__init__sA!   !!F*"W, rcdd}t|j|z }d|_|j|g|Ri|S)zU Test a Python script that is referenced in the supplied .spec file. T)rIr_rd test_script)respecfileargskwargs__tracebackhide__s r test_speczAppBuilder.test_specsH! //(: t:4:::6:::rcd}t|j||d}|d=|j|g|Ri|S)a  Test a Python script given as source code. The source will be written into a file named like the test-function. This file will then be passed to `test_script`. If you need other related file, e.g., as `.toc`-file for testing the content, put it at at the normal place. Just mind to take the basnename from the test-function's name. :param script: Source code to create executable from. This will be saved into a temporary file which is then passed on to `test_script`. :param test_id: Test-id for parametrized tests. If given, it will be appended to the script filename, separated by two underscores. All other arguments are passed straight on to `test_script`. Ttest_id)r r^ setdefaultri)resourcerkrlrm scriptfiles r test_sourcezAppBuilder.test_sourcesV !#DNFFz0AppBuilder._find_executables..(s777V 777rz.appContentsMacOS) rrbrrappendglobrr2isfile) rerr onedir_pt onefile_ptpatterns app_bundle_ptpatternprogs rrzAppBuilder._find_executabless-455 $.//          877h777H  +D > Kg UX\ \]]M OOM * * * & &G '** & &7>>$''&KK%%% & rctjtj}d|d<|d=tr3tjtj|d<tr$tjddg|d<tr$tjgd|d<|}|rt|j }tj |}tj|ddtj |g|d<nftj |}tj tjtj |}|g|z}||||||S)z} Run executable created by PyInstaller. :param args: CLI options to pass to the created executable. PATHz/usr/local/bin/usr/bin)rz/binz /usr/sbinz/sbin)copydeepcopyrenvironrpathsepjoinr get_system_pathrrrr^r2rrdirnamecurdir_run_executable_) rerrkrrprog_envexe_pathprog_cwd prog_names rrzAppBuilder._run_executable5s{=,, V   K!zx/G/I/IJJHV   O!z0@*/MNNHV   [ "z/Y/Y/YZZHV   H4>**H((..I!z VR0H0H"'//Z^J_J_/`aaHV  wt,,H RY0@0@0F0FGGI{T!$$T8XxQQQrc t tjn tj}|dd|d||||||}dx}} |r|nt} || \}} |j} |dd| dnM#t tjntjtjf$r|r|dd|d d } n|dd | d d } t |dd||d\}} |ddnz#tj$r |dd| |d \}} |ddn+#tj$r|ddYnwxYwYnwxYw|ddt| dD]k} tj tj5|dd| jd| dddn #1swxYwYl |dd|jd|d\}} |ddn#tjtjf$r|ddtj tj5| dddn #1swxYwY |d \}} |ddn7#tjtjf$r|ddYnwxYwYnwxYwYnwxYw|dd| | S)NzRUN-EXEzRunning z, args: ) executableenvcwd)timeoutz+Process exited on its own with return code rz%Process reached expected run-time of z seconds.rz+Timeout while running executable (timeout: z seconds)!z/Stopping the process using Popen.terminate()...rOzProcess stopped.z*Stopping the process using Popen.kill()...z6Failed to stop the process (or its child process(es))!zStopping child processes...T) recursivezStopping child process z...zWaiting for main process (z ) to stop...zProcess stopped on its own.zDone! Return code: )r subprocessPopenr| _EXE_TIMEOUT communicate returncodeTimeoutExpired terminatekilllistchildren contextlibsuppress NoSuchProcesspid TimeoutExpire) rerkrrrrpopen_implementationprocessrxryrr child_processs rrzAppBuilder._run_executable_`s)39>z//v| i)PH)P)P)P)PQQQ&&thT\]]] C s!(:gglG$000AANFF(G  ! !)-e[b-e-e-e f f f f.4n ))6CXZdZsBt> s> s> s %%i1kY`1k1k1klll%%i1r_f1r1r1rsss~s)))5fggg%%'''%,%8%8%8%C%CNFF)))5GHHHH!0 s s s s--i9efff *1)<) s@ i)Hw)H)HIIIsABA1O! AE$"O!$G=4AG G=%G63G=5G66G=9O!<G==AO!4J O!J O! J !O!&AK54O!5AOM% O%M) )O,M) -O1/N! O!1OOOOO!OO! O!cX|jr-dt|jdt|jddg}ndddt|jdt|jdt|jdtt |jddg }|jd kr|d n |jd kr|d |j g||}tj }t|j |d <tj||d}|dkS)z Run building of test script. :param args: additional CLI options for PyInstaller. Return True if build succeeded False otherwise. z --distpathz --workpathz --log-levelINFOz--debug=bootloaderz--noupxz --specpathz--pathonedirz--onedironefilez --onefilecachedirr)rdrrbrcrar?r_r`rrr get_configr^pyi_mainrun)rerk default_argsr PYI_CONFIGrs rrzAppBuilder._test_buildings3 = 1c$.11c$/22vLL%c$.11c$.11c$/22#.t}==>>vLzX%%##J////y((##K000K6,66)++ !$T^!4!4 : Xz***!|rc  |ddt|t|}t|dd5}t |}dddn #1swxYwY|g}|D]h}|D]5}tj||r|dd|d|n/6| ||dd |i| S) z{ Compare log files (now used mostly by multipackage test_name). :return: True if .toc files match z EXAMINE-EXEzMatching against TOC log: rzutf-8)encodingNz Entry found: z --> zEntry MISSING: ) r|rr openevalreadsortrematchr) rerr fname_listf pattern_listmissingrfnames rrzAppBuilder._examine_executableso m-Z#g,,-Z-Z[[[)#.. '3 1 1 1 *Q>>L * * * * * * * * * * * * * * * # T TG# T T8GU++))-9b9b9bY^9b9bcccE w'''%%m5Rw5R5RSSS{s"A66A:=A:)NNNNF)rQ __module__ __qualname__rgrnrtr|rirrrrrrrrrrZrZs;;;===,GGG`e,M,M,M,M\UUU4###J)R)R)RVTTTl)))VrrZsession)scopeclddlm}|j|jt dS)Nr)PyInstaller.loglogloggersetLevelDEBUGr)loggings r pyi_modgraphrs@&%%%%% NGM***rrr)paramsc#K|dtjd|d|||ddgit |||jVtrN|j j j r?|j j j r0| rtj|ddSdSdSdSdSNrzPyInstaller.config.CONFpathexT) ignore_errors)setenvrrsyspath_prependchdirr+rZparam_PYI_BUILDER_CLEANUPnode rep_setuppassedrep_callrrRrmtree)rT monkeypatchr6rs r pyi_builderrsvrz&1222%%%h1Hb>BBB Xw 6 66668 6 =8',BWB^8 ??   8 M($ 7 7 7 7 7 7888888 8 8rc#K|dtjd|||d|ddgit ||dVtrN|jj j r?|jj j r0| rtj|ddSdSdSdSdSr)rrrrrr+rZrrrrrrrRr)rTr6rrs rpyi_builder_specr svrz&1222h%%%1Hb>BBB Xw - ----8 6 =8',BWB^8 ??   8 M($ 7 7 7 7 7 7888888 8 8rrc#&Kd}||_|VdS)z=A pyi_builder equivalent for testing --windowed applications.cBtj|g||||jS)N)rrr)rrr)rkrrrrs rrz.pyi_windowed_builder.._run_executable_9s'~x/$/X8U\]]]hhrN)r)rrs rpyi_windowed_builderr 1s4iii$4K r)6rrrrrrrRrr getLogger addHandler NullHandlerrModuleNotFoundErrorr PyInstallerrrrPyInstaller.compatrrrPyInstaller.depend.analysisrPyInstaller.archive.readersr PyInstaller.utils.testsr PyInstaller.utils.win32r rrrrrr%hookimplr0r7r;r?rBrFrIfixturerKrMrXrZrrr r rrrrsK   2w244555MMMM FFF ,,,,,,!!!!!!;;;;;;;;;;;;;;;;<<<<<<222222,,,,,, ---z~~&;SAASH / / / $D111**21*))) ... ... +++ +++ ,,,"""$$$,aaaaaaaaL i   ! ),---88.-8(888& j      sAA$#A$