zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
U
H=®dº ã@s&ddlmZddlZddlZddlZddlZddlZddlm    Z    ddl
m Z ddl m Z ddlmZmZddlmZer¤ddlmZmZmZmZmZmZed    d
d Ze e¡Zed d ddZdae    dd„ƒZ Gdd„de!ƒZ"da#e    dd„ƒZ$Gdd„de!ƒZ%e%ƒZ&Gdd
„d
e!ƒZ'Gdd„de'ƒZ(dS)é)Úabsolute_importN)Úcontextmanager)Ú    ExitStack)Ú ensure_text)ÚenumÚrmtree)ÚMYPY_CHECK_RUNNING)ÚAnyÚDictÚIteratorÚOptionalÚTypeVarÚUnionÚ_TÚ TempDirectory)Úboundz    build-envzephem-wheel-cachez    req-build)Ú    BUILD_ENVÚEPHEM_WHEEL_CACHEÚ    REQ_BUILDc    cs2tƒ"}t|}az
dVW5|aXW5QRXdS©N)rÚ_tempdir_manager)ÚstackÚold_tempdir_manager©rúSD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/utils/temp_dir.pyÚglobal_tempdir_manager%s
 
 
rc@s(eZdZdZdd„Zdd„Zdd„ZdS)    ÚTempDirectoryTypeRegistryz$Manages temp directory behavior
    cCs
i|_dSr©Ú_should_delete©ÚselfrrrÚ__init__5sz"TempDirectoryTypeRegistry.__init__cCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be
        auto-deleted.
        Nr)r ÚkindÚvaluerrrÚ
set_delete9sz$TempDirectoryTypeRegistry.set_deletecCs|j |d¡S)z^Get configured auto-delete flag for a given TempDirectory type,
        default True.
        T)rÚget)r r"rrrÚ
get_delete@sz$TempDirectoryTypeRegistry.get_deleteN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r!r$r&rrrrr1srccs t}tƒaz
tVW5|aXdS)zuProvides a scoped global tempdir registry that can be used to dictate
    whether directories should be deleted.
    N)Ú_tempdir_registryr)Úold_tempdir_registryrrrÚtempdir_registryKs
 
r-c@s eZdZdS)Ú_DefaultN)r'r(r)rrrrr.Zsr.cs^eZdZdZdeddf‡fdd„    Zedd„ƒZd    d
„Zd d „Z    d d„Z
dd„Z dd„Z ‡Z 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.
    NÚtempFcsptt|ƒ ¡|tkr(|dk    r$d}nd}|dkr:| |¡}||_d|_||_||_|rlt    dk    sbt
‚t      |¡dS)NF) Úsuperrr!Ú_defaultÚ_createÚ_pathÚ_deletedÚdeleter"rÚAssertionErrorÚ enter_context)r Úpathr5r"Úglobally_managed©Ú    __class__rrr!vs
 zTempDirectory.__init__cCs|jrtd |j¡ƒ‚|jS)Nz$Attempted to access deleted path: {})r4r6Úformatr3rrrrr8•s
ÿzTempDirectory.pathcCsd |jj|j¡S)Nz    <{} {!r}>)r<r;r'r8rrrrÚ__repr__szTempDirectory.__repr__cCs|SrrrrrrÚ    __enter__¡szTempDirectory.__enter__cCs8|jdk    r|j}ntr$t |j¡}nd}|r4| ¡dS)NT)r5r+r&r"Úcleanup)r Úexcr#Útbr5rrrÚ__exit__¥s
zTempDirectory.__exit__cCs*tj tjd |¡d¡}t d|¡|S)zECreate a temporary directory and store its path in self.path
        úpip-{}-©ÚprefixúCreated temporary directory: %s)Úosr8ÚrealpathÚtempfileÚmkdtempr<ÚloggerÚdebug)r r"r8rrrr2±s
ÿ zTempDirectory._createcCs&d|_tj |j¡r"tt|jƒƒdS)z?Remove the temporary directory created and reset state
        TN)r4rGr8Úexistsr3rrrrrrr?¿szTempDirectory.cleanup)r'r(r)r*r1r!Úpropertyr8r=r>rBr2r?Ú __classcell__rrr:rrasû
 cs:eZdZdZdZd
‡fdd„    Zedd„ƒZdd    „Z‡Z    S) ÚAdjacentTempDirectoryaªHelper 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-~.=%0123456789Ncs"| d¡|_tt|ƒj|ddS)Nz/\)r5)ÚrstripÚoriginalr0rPr!)r rRr5r:rrr!ßs zAdjacentTempDirectory.__init__ccs tdt|ƒƒD]D}t |j|d¡D],}dd |¡||d…}||kr$|Vq$qtt|jƒƒD]8}t |j|¡D]$}dd |¡|}||krt|VqtqbdS)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)ÚrangeÚlenÚ    itertoolsÚcombinations_with_replacementÚ LEADING_CHARSÚjoin)ÚclsÚnameÚiÚ    candidateÚnew_namerrrÚ_generate_namesäs 
ÿ
ÿz%AdjacentTempDirectory._generate_namesc Csªtj |j¡\}}| |¡D]b}tj ||¡}zt |¡Wn0tk
rl}z|jtj    kr\‚W5d}~XYqXtj 
|¡}qšqtj 
t j d  |¡d¡}t d|¡|S)NrCrDrF)rGr8ÚsplitrRrar[ÚmkdirÚOSErrorÚerrnoÚEEXISTrHrIrJr<rKrL)r r"Úrootr]r_r8Úexrrrr2ýs  ÿ zAdjacentTempDirectory._create)N)
r'r(r)r*rZr!Ú classmethodrar2rOrrr:rrPÊs 
rP))Ú
__future__rrerXÚloggingÚos.pathrGrIÚ
contextlibrÚpip._vendor.contextlib2rZpip._vendor.sixrÚpip._internal.utils.miscrrÚpip._internal.utils.typingrÚtypingr    r
r r r rrÚ    getLoggerr'rKÚ tempdir_kindsrrÚobjectrr+r-r.r1rrPrrrrÚ<module>s<       
ý
 
i