Ë ƒ:”Ž  D…ãóÊ—dZddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZddlmZmZddlmZddlmZmZmZmZmZerddlmZmZGd „d «ZGd „d e«Zy) 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—eZdZdZdedededddef d„Zd ed eed fd e d e def d„Z d edede e eefddfd„Zy)ÚWheelDestinationz¿Handles writing the unpacked files, script generation and ``RECORD`` generation. Subclasses provide the concrete script generation logic, as well as the RECORD file (re)writing. ÚnameÚmoduleÚattrÚsectionrÚreturncó—t‚)aWrite 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)Úselfrrrrs ú;/usr/lib/python3.12/site-packages/installer/destinations.pyÚ write_scriptzWheelDestination.write_script's €ô""Ð!óÚschemeÚpathúos.PathLike[str]ÚstreamÚ is_executablecó—t‚)aWrite 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$r%r'r(s r!Ú write_filezWheelDestination.write_file:s €ô,"Ð!r#Úrecord_file_pathÚrecordsNcó—t‚)a�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_installationz&WheelDestination.finalize_installationRs €ô&"Ð!r#)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ústrr r"rr rÚboolr*rr r.©r#r!rr s®„ñð "Øð"Ø!$ð"Ø,/ð"Ø:Ið"à ó"ð&"àð"ð�CÐ+Ð+Ñ,ð"ðð "ð ð "ð ó "ð0"àð"ðð"ð˜% ¨ Ð 3Ñ4Ñ5ð "ð ô "r#rcó—eZdZdZ ddeeefdedddedeed eed dfd „Z d e d ed efd„Z d e d ede de d ef d„Zd e d eedfde de d ef d„Zdedededdd ef d„Zd e ded dfd„Zd e dedeee efd dfd„Zy) ÚSchemeDictionaryDestinationz>Destination, based on a mapping of {scheme: file-system-path}.NÚ scheme_dictÚ interpreterÚ script_kindrÚhash_algorithmÚbytecode_optimization_levelsÚdestdirrcóX—||_||_||_||_||_||_y)a 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)r8r9r:r;r<r=)r r8r9r:r;r<r=s r!Ú__init__z$SchemeDictionaryDestination.__init__ks3€ð2'ˆÔØ&ˆÔØ&ˆÔØ,ˆÔØ,HˆÔ)؈� r#r$r%có—tjj|j||«}|j�Pt |«}|j |j«}tjj|j|«S|S)N)Úosr%Újoinr8r=rÚ relative_toÚanchor)r r$r%ÚfileÚ file_pathÚrel_paths r!Ú_path_with_destdirz.SchemeDictionaryDestination._path_with_destdir‹sh€Ü�w‰w�|‰|˜D×,Ñ,¨VÑ4°dÓ;ˆØ �<‰<Ð #ܘT› ˆIØ ×,Ñ,¨Y×-=Ñ-=Ó>ˆHÜ—7‘7—<‘< § ¡ ¨hÓ7Ð 7؈ r#r'r(cóü—|j||«}tjj|«rd|›�}t |«‚tjj |«}tjj|«stj |«t|d«5}t|||j«\} } ddd«|r t|«t|t|j « «S#1swYŒ7xYw)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. zFile already exists: ÚwbN) rHrAr%ÚexistsÚFileExistsErrorÚdirnameÚmakedirsÚopenrr;rr r ) r r$r%r'r(Ú target_pathÚmessageÚ parent_folderÚfÚhash_Úsizes r!Ú write_to_fsz'SchemeDictionaryDestination.write_to_fs“sÆ€ð"×-Ñ-¨f°dÓ;ˆ Ü �7‰7�>‰>˜+Ô &Ø-¨k¨]Ð;ˆGÜ! 'Ó*Ð *䟙Ÿ™¨ Ó4ˆ Ü�w‰w�~‰~˜mÔ,Ü �K‰K˜ Ô &ä �+˜tÔ $¨Ü2°6¸1¸d×>QÑ>QÓR‰KˆE�4÷%ñ Ü  Ô -ä˜4¤ d×&9Ñ&9¸5Ó!AÀ4ÓHÐH÷ %Ð $ús Â!C2Ã2C;r&cóÞ—tj|«}|dk(r4t||j«5}|j ||||«cddd«S|j ||||«S#1swYŒxYw)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)rAÚfspathrr9rV)r r$r%r'r(Úpath_Ústream_with_different_shebangs r!r*z&SchemeDictionaryDestination.write_fileµsn€ô$— ‘ ˜$“ˆà �YÒ Ü˜V T×%5Ñ%5Ô6Ð:WØ×'Ñ'ؘEÐ#@À-ó÷7Ñ6ð ×Ñ ¨¨v°}ÓEÐE÷ 7Ð6ús ±A#Á#A,rrrrrcó¼—t||||«}|j|j|j«\}}t j |«5}|j td«||d¬«} |jtd«|«} tj| «j} | | dzdz z} tj| | «| cddd«S#1swYyxYw)aXWrite 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. rXT©r(i$éN) rÚgenerater9r:ÚioÚBytesIOrVrrHrAÚstatÚst_modeÚchmod) r rrrrÚscriptÚ script_nameÚdatar'Úentryr%Úmodes r!r"z(SchemeDictionaryDestination.write_scriptÑs€ô"˜˜f d¨GÓ4ˆØ"ŸO™O¨D×,<Ñ,<¸d×>NÑ>NÓOш �Tä �Z‰Z˜Ô  Ø×$Ñ$Ü�yÓ! ;°Àdð%óˆEð×*Ñ*¬6°)Ó+<¸kÓJˆDÜ—7‘7˜4“=×(Ñ(ˆDØ �T˜E‘\ aÑ'Ñ 'ˆDÜ �H‰H�T˜4Ô à÷× Ò ús Á A;CÃCÚrecordcóB—|dvry|j||j«}tjjtjj |j ||j««}|j D]}tj||d|¬«Œy)z'Compile bytecode for a single .py file.)ÚpurelibÚplatlibNé)ÚoptimizeÚquietÚddir) rHr%rArMrBr8r<Ú compileallÚ compile_file)r r$rjrPÚdir_path_to_embedÚlevels r!Ú_compile_bytecodez-SchemeDictionaryDestination._compile_bytecodeñs‚€à Ð/Ñ /Ø à×-Ñ-¨f°f·k±kÓBˆ ÜŸG™GŸO™OÜ �G‰G�L‰L˜×)Ñ)¨&Ñ1°6·;±;Ó ?ó Ðð×6Ô6ˆEÜ × #Ñ #Ø e°1Ð;Lö ñ7r#r+r,cóö‡‡—dtdttfˆˆfd„ }t|«}t||«5}‰j ‰||d¬«ddd«|D]\Š}‰j ‰|«Œy#1swYŒ&xYw)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 Ú file_schemercó�•—|‰k(rytjj‰j|‰j‰¬«}|dzS)N)ÚstartÚ/)rAr%Úrelpathr8)rxr%r$r s €€r!Úprefix_for_schemezLSchemeDictionaryDestination.finalize_installation..prefix_for_scheme sMø€Ø˜fÒ$ØÜ—7‘7—?‘?Ø× Ñ  Ñ-Ø×&Ñ& vÑ.ð#óˆDð˜#‘:Ð r#Fr]N)r3r ÚlistrrVrv)r r$r+r,r}Ú record_listÚ record_streamrjs`` r!r.z1SchemeDictionaryDestination.finalize_installationÿsù€ð ¬3ð ´8¼C±=ö ô˜7“mˆ Ü " ;Ð0AÔ BÀmØ × Ñ ØÐ(¨-Àuð ô ÷Có *‰NˆF�FØ × "Ñ " 6¨6Õ 2ñ*÷ CÐ Bús ´A/Á/A8)Úsha256r5N)r/r0r1r2rr3rÚintr r?rrHrr4r rVr r*r"rvrr r.r5r#r!r7r7hsˆ„ÙHð'Ø8:Ø!%ñà˜#˜s˜(‘^ðððð$ð ð ð ð '1°¡oð ð˜#‘ðð óð@¨ð°sð¸sóð Iàð Iðð Iðð Ið ð Ið ó IðDFàðFð�CÐ+Ð+Ñ,ðFðð Fð ð Fð ó Fð8ØðØ!$ðØ,/ðØ:Iðà óð@ ¨ð ¸ ð Èó ð3àð3ðð3ð˜% ¨ Ð 3Ñ4Ñ5ð 3ð ô 3r#r7)r2rrr`rAÚpathlibrÚtypingrrrrrr r r Úinstaller.recordsr r Úinstaller.scriptsrÚinstaller.utilsrrrrrrrrr7r5r#r!ÚrˆsYðÙ@ãÛ Û Ý÷ ÷ ó ÷0Ý$÷õñß=÷E"ñE"ôPt3Ð"2õt3r#