W; *UddlmZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z ddlmZddlmZmZmZddlmZmZejeZedd Zed d d Zdaded<e ddZGddZda ded<e d dZ!GddZ"e"Z#Gdd Z$Gdde$Z%dS)!) annotationsN) Generator) ExitStackcontextmanager)Path)AnyCallableTypeVar)enumrmtree_T TempDirectory)boundz build-envzephem-wheel-cachez req-build) BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILDzExitStack | None_tempdir_managerreturnGenerator[None, None, None]c#Kt5}t|c}a dV|an#|awxYw ddddS#1swxYwYdSN)rr)stackold_tempdir_managers n/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.pyglobal_tempdir_managerr%s 30@%-- 3 EEE2  2  2 2 2 2  333333333333333333s 9$9(9==c*eZdZdZd dZd d Zdd Zd S)TempDirectoryTypeRegistryzManages temp directory behaviorrNoneci|_dSr_should_deleteselfs r__init__z"TempDirectoryTypeRegistry.__init__3s/1kindstrvalueboolc||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. Nr )r#r&r(s r set_deletez$TempDirectoryTypeRegistry.set_delete6s%*D!!!r%c8|j|dS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)r!get)r#r&s r get_deletez$TempDirectoryTypeRegistry.get_delete<s"&&tT222r%Nrr)r&r'r(r)rr)r&r'rr))__name__ __module__ __qualname____doc__r$r+r.r%rrr0sV))2222**** 333333r%rz TempDirectoryTypeRegistry | None_tempdir_registry0Generator[TempDirectoryTypeRegistry, None, None]c#ZKt}ta tV|adS#|awxYw)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)r5r)old_tempdir_registrys rtempdir_registryr9FsJ -1331000000s &*ceZdZdS)_DefaultN)r0r1r2r4r%rr;r;TsDr%r;cpeZdZdZdedddfdfd ZeddZddZd dZ d!dZ d"dZ d#dZ xZ S)$raMHelper class that owns and cleans up a temporary directory. This class can be used as a context manager or as an OO representation of a temporary directory. Attributes: path Location to the created temporary directory delete Whether the directory should be deleted when exiting (when used as a contextmanager) Methods: cleanup() Deletes the temporary directory When used as a context manager, if the delete attribute is True, on exiting the context the temporary directory is deleted. NtempFTpath str | Nonedeletebool | None | _Defaultr&r'globally_managedr)ignore_cleanup_errorsc*t|tur|d}nd}|||}||_d|_||_||_||_|r%tJt |dSdS)NF) superr$_default_create_path_deletedr@r&rCr enter_context)r#r>r@r&rBrC __class__s rr$zTempDirectory.__init__ps  X   <<<%%D    %:"  1#///  * *4 0 0 0 0 0 1 1r%rcB|jrJd|j|jS)Nz"Attempted to access deleted path: )rIrHr"s rr>zTempDirectory.paths+=SS"Stz"S"SSS zr%c2d|jjd|jdS)N< >)rKr0r>r"s r__repr__zTempDirectory.__repr__s";4>*;;TY;;;;r%r#r c|Srr4r"s r __enter__zTempDirectory.__enter__s r%excrr(tbrc|j|j}n)tr t|j}nd}|r|dSdS)NT)r@r5r.r&cleanup)r#rTr(rUr@s r__exit__zTempDirectory.__exit__sZ ; "[FF  &11$)<realpathtempfilemkdtemploggerdebug)r#r&r>s rrGzTempDirectory._createsI w 0t G G GHH 6=== r%cpd|_tj|jsdSgdfd }|jrd t |jd n&#t$rt |j|YnwxYwr"t d|jdSdSt |jdS)z6Remove the temporary directory created and reset stateTNfuncCallable[..., Any]r>rexc_val BaseExceptionrrcdtjt||}|}|t jt jt jfvrt d||n!t d|j | |dS)z/Log a warning for a `rmtree` error and continue z2Failed to remove a temporary file '%s' due to %s. z%s failed with %s.N) join tracebackformat_exception_onlytyperstripr_unlinkremovermdirrcrdr2append)rfr>rh formatted_excerrorss ronerrorz&TempDirectory.cleanup..onerrors !II/W wGGM*0022M 29bh777 I!  143DmTTT MM' " " " " "r%F) ignore_errors)onexcz[Failed to remove contents in a temporary directory '%s'. You can safely remove it manually.)rfrgr>rrhrirr) rIr_r>existsrHrCr OSErrorrcwarning)r#rwrvs @rrWzTempDirectory.cleanups w~~dj))  F&( # # # # # #(  %  2tz77777 2 2 2tz111111 2 9J   4:     sA A98A9) r>r?r@rAr&r'rBr)rCr))rr')r#r rr )rTrr(rrUrrrr&r'rr'r/)r0r1r2r3rFr$propertyr>rQrSrXrGrW __classcell__rKs@rrr[s, )1!&&* !1!1!1!1!1!1!1FX<<<<    ********r%cJeZdZdZdZddfd Zedd ZddZxZ S)AdjacentTempDirectoryaHelper class that creates a temporary directory adjacent to a real one. Attributes: original The original directory to create a temp directory for. path After calling create() or entering, contains the full path to the temporary directory. delete Whether the directory should be deleted when exiting (when used as a contextmanager) z-~.=%0123456789Noriginalr'r@ bool | Nonerrc|d|_t|dS)Nz/\)r@)rprrEr$)r#rr@rKs rr$zAdjacentTempDirectory.__init__s7 ..  '''''r%nameGenerator[str, None, None]c#Ktdt|D]O}tj|j|dz D]/}dd|z||dz}||kr|V0Ptt|jD]D}tj|j|D]'}dd|z|z}||kr|V(EdS)a Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions of package). ~N)rangelen itertoolscombinations_with_replacement LEADING_CHARSrl)clsri candidatenew_names r_generate_namesz%AdjacentTempDirectory._generate_namessq#d))$$ # #A&D!1q5 # # !3!33d122h>t##"NNN  #s3,--.. # #A&D!1 # # !3!33d:t##"NNN  # # #r%r&c*tj|j\}}||D]}tj||} tj|tj|}nc#t$r }|j tj krYd}~}d}~wwxYwtjtj d|d}td||S)NrZr[r\r^)r_r>splitrrrlmkdirr`r{errnoEEXISTrarbrcrd)r#r&rootrrr>exs rrGzAdjacentTempDirectory._createsW]]4=11 d--d33 M MI7<<i00D  w''--    8u|++,++++ 7##H$4N4NNN$K$K$KLLD 6=== s B B?B::B?r)rr'r@rrr)rr'rrr}) r0r1r2r3rr$ classmethodrrGrrs@rrrs  &&M(((((((###[#2r%r)rr)rr6)& __future__rrrloggingos.pathr_rarmcollections.abcr contextlibrrpathlibrtypingrr r pip._internal.utils.miscr r getLoggerr0rcr tempdir_kindsr__annotations__rrr5r9r;rFrrr4r%rrsY""""""" %%%%%%00000000 21111111  8 $ $ WT))) ) &*))))333333333333&7;:::: 1 1 1 1         8::BBBBBBBBJFFFFFMFFFFFr%