+
    VBi'                         R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHtHtHt ^ RIHtHt ^ RIHt ^ RIHtHtHtHtHt ]'       d	   ^ RIHtHt  ! R R	4      t ! R
 R]4      tR# )z:Handles all file writing and post-installation processing.N)Path)TYPE_CHECKINGBinaryIO
CollectionDictIterableOptionalTupleUnion)HashRecordEntry)Script)Schemeconstruct_record_filecopyfileobj_with_hashingfix_shebangmake_file_executable)LauncherKindScriptSectionc                   Z   a  ] tR t^ t o RtV 3R lR ltV 3R lR ltV 3R lR ltRtV t	R	# )
WheelDestinationzHandles writing the unpacked files, script generation and ``RECORD`` generation.

Subclasses provide the concrete script generation logic, as well as the RECORD file
(re)writing.
c          
      6   < V ^8  d   QhRS[ RS[ RS[ RRRS[/#    namemoduleattrsectionr   returnstrr   )format__classdict__s   ";/usr/lib/python3.14/site-packages/installer/destinations.py__annotate__WheelDestination.__annotate__'   s5     " ""!$",/":I"	"    c                    \         h)a  Write a script in the correct location to invoke given entry point.

:param name: name of the script
:param module: module path, to load the entry point from
:param attr: final attribute access, for the entry point
:param section: Denotes the "entry point section" where this was specified.
    Valid values are ``"gui"`` and ``"console"``.
:type section: str

Example usage/behaviour::

    >>> dest.write_script("pip", "pip._internal.cli", "main", "console")

NotImplementedError)selfr   r   r   r   s   &&&&&r#   write_scriptWheelDestination.write_script'   s
    " "!r&   c          
      L   < V ^8  d   QhRS[ RS[S[R3,          RS[RS[RS[/# r   schemepathzos.PathLike[str]streamis_executabler   r   r
   r    r   boolr   )r!   r"   s   "r#   r$   r%   :   sH     " "" C++," 	"
 " 
"r&   c                    \         h)a  Write a file to correct ``path`` within the ``scheme``.

:param scheme: scheme to write the file in (like "purelib", "platlib" etc).
:param path: path within that scheme
:param stream: contents of the file
:param is_executable: whether the file should be made executable

The stream would be closed by the caller, after this call.

Example usage/behaviour::

    >>> with open("__init__.py") as stream:
    ...     dest.write_file("purelib", "pkg/__init__.py", stream)

r(   )r*   r/   r0   r1   r2   s   &&&&&r#   
write_fileWheelDestination.write_file:   s
    , "!r&   c          	      V   < V ^8  d   QhRS[ RS[RS[S[S[ S[3,          ,          RR/# r   r/   record_file_pathrecordsr   Nr   r    r   r	   r   )r!   r"   s   "r#   r$   r%   R   sB     " "" " % 345	"
 
"r&   c                    \         h)ae  Finalize installation, after all the files are written.

Handles (re)writing of the ``RECORD`` file.

:param scheme: scheme to write the ``RECORD`` file in
:param record_file_path: path of the ``RECORD`` file with that scheme
:param records: entries to write to the ``RECORD`` file

Example usage/behaviour::

    >>> dest.finalize_installation("purelib")

r(   )r*   r/   r:   r;   s   &&&&r#   finalize_installation&WheelDestination.finalize_installationR   s
    & "!r&    N)
__name__
__module____qualname____firstlineno____doc__r+   r6   r>   __static_attributes____classdictcell__r"   s   @r#   r   r       s(     " "&" "0" "r&   r   c                      a  ] tR t^ht o RtRV 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltRtV tR# )SchemeDictionaryDestinationz>Destination, based on a mapping of {scheme: file-system-path}.Nc                v   < V ^8  d   QhRS[ S[S[3,          RS[RRRS[RS[S[,          RS[S[,          RR	/# )
r   scheme_dictinterpreterscript_kindr   hash_algorithmbytecode_optimization_levelsdestdirr   N)r   r    r   intr   )r!   r"   s   "r#   r$   (SchemeDictionaryDestination.__annotate__k   sa      #s(^  $	
  '1o # 
r&   c                N    Wn         W n        W0n        W@n        WPn        W`n        R# )a0  Construct a ``SchemeDictionaryDestination`` object.

:param scheme_dict: a mapping of {scheme: file-system-path}
:param interpreter: the interpreter to use for generating scripts
:param script_kind: the "kind" of launcher script to use
:param hash_algorithm: the hashing algorithm to use, which is a member
    of :any:`hashlib.algorithms_available` (ideally from
    :any:`hashlib.algorithms_guaranteed`).
:param bytecode_optimization_levels: Compile cached bytecode for
    installed .py files with these optimization levels. The bytecode
    is specific to the minor version of Python (e.g. 3.10) used to
    generate it.
:param destdir: A staging directory in which to write all files. This
    is expected to be the filesystem root at runtime, so embedded paths
    will be written as though this was the root.
N)rL   rM   rN   rO   rP   rQ   )r*   rL   rM   rN   rO   rP   rQ   s   &&&&&&&r#   __init__$SchemeDictionaryDestination.__init__k   s'    2 '&&,,H)r&   c                ,   < V ^8  d   QhRS[ RS[RS[/# )r   r/   r0   r   )r   r    )r!   r"   s   "r#   r$   rS      s"       s s r&   c                $   \         P                  P                  V P                  V,          V4      pV P                  eQ   \        V4      pVP                  VP                  4      p\         P                  P                  V P                  V4      # V# )N)osr0   joinrL   rQ   r   relative_toanchor)r*   r/   r0   file	file_pathrel_paths   &&&   r#   _path_with_destdir.SchemeDictionaryDestination._path_with_destdir   sh    ww||D,,V4d;<<#T
I ,,Y-=-=>H77<<h77r&   c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# )r   r/   r0   r1   r2   r   )r   r    r   r4   r   )r!   r"   s   "r#   r$   rS      sD      I  I I  I 	 I
  I 
 Ir&   c                :   V P                  W4      p\        P                  P                  V4      '       d   RV 2p\	        V4      h\        P                  P                  V4      p\        P                  P                  V4      '       g   \        P                  ! V4       \        VR4      ;_uu_ 4       p\        W8V P                  4      w  rRRR4       V'       d   \        V4       \        V\        V P                  X	4      X
4      #   + '       g   i     LD; i)a  Write contents of ``stream`` to the correct location on the filesystem.

:param scheme: scheme to write the file in (like "purelib", "platlib" etc).
:param path: path within that scheme
:param stream: contents of the file
:param is_executable: whether the file should be made executable

- Ensures that an existing file is not being overwritten.
- Hashes the written content, to determine the entry in the ``RECORD`` file.
zFile already exists: wbN)r`   rY   r0   existsFileExistsErrordirnamemakedirsopenr   rO   r   r   r   )r*   r/   r0   r1   r2   target_pathmessageparent_folderfhash_sizes   &&&&&      r#   write_to_fs'SchemeDictionaryDestination.write_to_fs   s    " --f;77>>+&&-k];G!'**4ww~~m,,KK&+t$$26d>Q>QRKE %  -4d&9&95!A4HH %$s   5D

D	c          
      L   < V ^8  d   QhRS[ RS[S[R3,          RS[RS[RS[/# r.   r3   )r!   r"   s   "r#   r$   rS      sO     F FF C++,F 	F
 F 
Fr&   c                    \         P                  ! V4      pVR8X  d;   \        W0P                  4      ;_uu_ 4       pV P	                  WWd4      uuRRR4       # V P	                  WW44      #   + '       g   i     L"; i)a  Write a file to correct ``path`` within the ``scheme``.

:param scheme: scheme to write the file in (like "purelib", "platlib" etc).
:param path: path within that scheme
:param stream: contents of the file
:param is_executable: whether the file should be made executable

- Changes the shebang for files in the "scripts" scheme.
- Uses :py:meth:`SchemeDictionaryDestination.write_to_fs` for the
  filesystem interaction.
scriptsN)rY   fspathr   rM   rp   )r*   r/   r0   r1   r2   path_stream_with_different_shebangs   &&&&&  r#   r6   &SchemeDictionaryDestination.write_file   sg    $ 		$YV%5%566:W''#@ 76
 vEE 76s   A**A:	c          
      6   < V ^8  d   QhRS[ RS[ RS[ RRRS[/# r   r   )r!   r"   s   "r#   r$   rS      s5      !$,/:I	r&   c           	        \        WW44      pVP                  V P                  V P                  4      w  rg\        P
                  ! V4      ;_uu_ 4       pV P                  \        R4      WhRR7      p	V P                  \        R4      V4      p
\        P                  ! V
4      P                  pWR,          ^,	          ,          p\        P                  ! W4       V	uuRRR4       #   + '       g   i     R# ; i)a   Write a script to invoke an entrypoint.

:param name: name of the script
:param module: module path, to load the entry point from
:param attr: final attribute access, for the entry point
:param section: Denotes the "entry point section" where this was specified.
    Valid values are ``"gui"`` and ``"console"``.
:type section: str

- Generates a launcher using :any:`Script.generate`.
- Writes to the "scripts" scheme.
- Uses :py:meth:`SchemeDictionaryDestination.write_to_fs` for the
  filesystem interaction.
rt   Tr2   i$  N)r   generaterM   rN   ioBytesIOrp   r   r`   rY   statst_modechmod)r*   r   r   r   r   scriptscript_namedatar1   entryr0   modes   &&&&&       r#   r+   (SchemeDictionaryDestination.write_script   s    " d4"OOD,<,<d>N>NOZZ$$y!;d % E **6)+<kJD774=((DE\a''DHHT  s   BC$$C5	c                *   < V ^8  d   QhRS[ RS[RR/# )r   r/   recordr   N)r   r   )r!   r"   s   "r#   r$   rS      s"         r&   c                V   VR9  d   R# V P                  WP                  4      p\        P                  P                  \        P                  P	                  V P
                  V,          VP                  4      4      pV P                   F  p\        P                  ! W5^VR7       K  	  R# )z'Compile bytecode for a single .py file.N)optimizequietddir)purelibplatlib)	r`   r0   rY   rg   rZ   rL   rP   
compileallcompile_file)r*   r/   r   rj   dir_path_to_embedlevels   &&&   r#   _compile_bytecode-SchemeDictionaryDestination._compile_bytecode   s~    //--fkkBGGOOGGLL))&16;;?
 66E##1;L 7r&   c          	      V   < V ^8  d   QhRS[ RS[RS[S[S[ S[3,          ,          RR/# r9   r<   )r!   r"   s   "r#   r$   rS      sB     3 33 3 % 345	3
 
3r&   c           	        a a R VV 3R llp\        V4      p\        WT4      ;_uu_ 4       pS P                  SW&RR7       RRR4       V F  w  opS P                  SV4       K  	  R#   + '       g   i     L0; i)a  Finalize installation, by writing the ``RECORD`` file & compiling bytecode.

:param scheme: scheme to write the ``RECORD`` file in
:param record_file_path: path of the ``RECORD`` file with that scheme
:param records: entries to write to the ``RECORD`` file
c                F    V ^8  d   QhR\         R\        \         ,          /# )r   file_schemer   )r    r   )r!   s   "r#   r$   GSchemeDictionaryDestination.finalize_installation.<locals>.__annotate__  s     	 	3 	8C= 	r&   c                    < V S8X  d   R # \         P                  P                  SP                  V ,          SP                  S,          R7      pVR,           # )N)start/)rY   r0   relpathrL   )r   r0   r/   r*   s   & r#   prefix_for_schemeLSchemeDictionaryDestination.finalize_installation.<locals>.prefix_for_scheme  sM    f$77??  -&&v. # D #:r&   Fr{   N)listr   rp   r   )r*   r/   r:   r;   r   record_listrecord_streamr   s   ff&&    r#   r>   1SchemeDictionaryDestination.finalize_installation   sp    	 	 7m";BBm(u   C
 *NFF""662 * CBs   A((A8	)rP   rQ   rO   rM   rL   rN   )sha256r@   N)rA   rB   rC   rD   rE   rU   r`   rp   r6   r+   r   r>   rF   rG   rH   s   @r#   rJ   rJ   h   sU     H @  I  IDF F8 @ 3 3r&   rJ   )rE   r   r}   rY   pathlibr   typingr   r   r   r   r   r   r	   r
   installer.recordsr   r   installer.scriptsr   installer.utilsr   r   r   r   r   r   r   r   rJ   r@   r&   r#   <module>r      sY    @  	 	 	 	 	 0 $  =E" E"Pt3"2 t3r&   