+
    ,j0                        ^ RI Ht ^ RIt^ RIHtHtHtHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ] ! R
 R]4      4       tRR R lltR# )    )annotationsN)ListOptionalProtocolruntime_checkable)	MatchSpec)Client)Platform)PrefixRecord)RepoDataRecord)
py_installc                      ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR(tR)# )*InstallerReporterun  
Protocol for custom installation progress reporters.

Implement this protocol (by subclassing or structurally) and override the
methods we care about to receive progress callbacks during package
installation. All methods have no-op defaults so we only need to implement
the ones relevant to our use case.

Methods that return an ``int`` act as opaque tokens: the value we return
will be passed back to the corresponding ``*_complete`` callback so we can
correlate start/finish events.

Example
-------
```python
from rattler.install import InstallerReporter

class MyReporter:  # no need to inherit — structural subtyping is sufficient
    def on_transaction_start(self, total_operations: int) -> None:
        print(f"Starting installation of {total_operations} operations")

    def on_download_progress(
        self,
        download_idx: int,
        progress: int,
        total: int | None,
    ) -> None:
        pct = f"{progress}/{total}" if total else str(progress)
        print(f"  downloading [{download_idx}]: {pct} bytes")

    def on_transaction_complete(self) -> None:
        print("Installation complete!")
```
c                    V ^8  d   QhRRRR/# )   total_operationsintreturnNone )formats   "9lib/python3.14/site-packages/rattler/install/installer.py__annotate__InstallerReporter.__annotate__3   s      S T     c                    R# )zCalled once when the installation transaction begins.

Parameters
----------
total_operations:
    The total number of install/unlink operations in this transaction.
Nr   )selfr   s   &&r   on_transaction_start&InstallerReporter.on_transaction_start3       r   c                    V ^8  d   QhRRRR/# r   	operationr   r   r   r   )r   s   "r   r   r   <   s        r   c                    R# )zCalled when a single transaction operation starts.

Parameters
----------
operation:
    Index of the operation within the transaction.
Nr   r   r#   s   &&r   on_transaction_operation_start0InstallerReporter.on_transaction_operation_start<   r    r   c               $    V ^8  d   QhRRRRRR/# r   r#   r   package_namestrr   r   )r   s   "r   r   r   E   s!       C C r   c                    ^ # )a5  Called when rattler begins populating the local cache for a package.

Parameters
----------
operation:
    Index of the operation within the transaction.
package_name:
    Normalised name of the package being cached.

Returns
-------
int
    An opaque token passed back to :meth:`on_populate_cache_complete`.
r   r   r#   r*   s   &&&r   on_populate_cache_start)InstallerReporter.on_populate_cache_startE        r   c                    V ^8  d   QhRRRR/# r   cache_entryr   r   r   )r   s   "r   r   r   V   s      S S r   c                    ^ # )zCalled when cache-entry validation begins.

Parameters
----------
cache_entry:
    Token returned by :meth:`on_populate_cache_start`.

Returns
-------
int
    An opaque token passed back to :meth:`on_validate_complete`.
r   r   r3   s   &&r   on_validate_start#InstallerReporter.on_validate_startV   s     r   c                    V ^8  d   QhRRRR/# )r   validate_idxr   r   r   r   )r   s   "r   r   r   e   s        r   c                    R# )zCalled when cache-entry validation finishes.

Parameters
----------
validate_idx:
    Token returned by :meth:`on_validate_start`.
Nr   )r   r9   s   &&r   on_validate_complete&InstallerReporter.on_validate_completee   r    r   c                    V ^8  d   QhRRRR/# r2   r   )r   s   "r   r   r   n   s      S S r   c                    ^ # )a   Called just before a package download begins.

Parameters
----------
cache_entry:
    Token returned by :meth:`on_populate_cache_start`.

Returns
-------
int
    An opaque token passed to :meth:`on_download_progress` and
    :meth:`on_download_completed`.
r   r5   s   &&r   on_download_start#InstallerReporter.on_download_startn   s     r   c               (    V ^8  d   QhRRRRRRRR/# )r   download_idxr   progresstotalzOptional[int]r   r   r   )r   s   "r   r   r   ~   s)        M ^b r   c                    R# )zCalled periodically with download byte progress.

Parameters
----------
download_idx:
    Token returned by :meth:`on_download_start`.
progress:
    Bytes downloaded so far.
total:
    Total expected bytes, or ``None`` if unknown.
Nr   )r   rB   rC   rD   s   &&&&r   on_download_progress&InstallerReporter.on_download_progress~   r    r   c                    V ^8  d   QhRRRR/# )r   rB   r   r   r   r   )r   s   "r   r   r      s      # $ r   c                    R# )zwCalled when a download finishes.

Parameters
----------
download_idx:
    Token returned by :meth:`on_download_start`.
Nr   )r   rB   s   &&r   on_download_completed'InstallerReporter.on_download_completed   r    r   c                    V ^8  d   QhRRRR/# )r   r3   r   r   r   r   )r   s   "r   r   r      s      c d r   c                    R# )zCalled when the cache has been fully populated for a package.

Parameters
----------
cache_entry:
    Token returned by :meth:`on_populate_cache_start`.
Nr   r5   s   &&r   on_populate_cache_complete,InstallerReporter.on_populate_cache_complete   r    r   c               $    V ^8  d   QhRRRRRR/# r)   r   )r   s   "r   r   r      s!       C C r   c                    ^ # )a%  Called when rattler begins unlinking (removing) a package.

Parameters
----------
operation:
    Index of the operation within the transaction.
package_name:
    Normalised name of the package being unlinked.

Returns
-------
int
    An opaque token passed back to :meth:`on_unlink_complete`.
r   r-   s   &&&r   on_unlink_start!InstallerReporter.on_unlink_start   r0   r   c                    V ^8  d   QhRRRR/# r   indexr   r   r   r   )r   s   "r   r   r      s        r   c                    R# )z|Called when a package has been fully unlinked.

Parameters
----------
index:
    Token returned by :meth:`on_unlink_start`.
Nr   r   rV   s   &&r   on_unlink_complete$InstallerReporter.on_unlink_complete   r    r   c               $    V ^8  d   QhRRRRRR/# r)   r   )r   s   "r   r   r      s!      s # # r   c                    ^ # )a!  Called when rattler begins linking (installing) a package.

Parameters
----------
operation:
    Index of the operation within the transaction.
package_name:
    Normalised name of the package being linked.

Returns
-------
int
    An opaque token passed back to :meth:`on_link_complete`.
r   r-   s   &&&r   on_link_startInstallerReporter.on_link_start   r0   r   c                    V ^8  d   QhRRRR/# rU   r   )r   s   "r   r   r      s      c d r   c                    R# )zCalled when a package has been fully linked into the prefix.

Parameters
----------
index:
    Token returned by :meth:`on_link_start`.
Nr   rX   s   &&r   on_link_complete"InstallerReporter.on_link_complete   r    r   c                    V ^8  d   QhRRRR/# r"   r   )r   s   "r   r   r      s      3 4 r   c                    R# )zCalled when a single transaction operation finishes.

Parameters
----------
operation:
    Index of the operation within the transaction.
Nr   r%   s   &&r   !on_transaction_operation_complete3InstallerReporter.on_transaction_operation_complete   r    r   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r      s     D D Dr   c                    R# )z5Called once when the entire transaction has finished.Nr   )r   s   &r   on_transaction_complete)InstallerReporter.on_transaction_complete   r    r   c               $    V ^8  d   QhRRRRRR/# r   r*   r+   script_pathr   r   r   )r   s   "r   r   r      s!      s   r   c                    ^ # )a(  Called when a post-link script begins execution.

Parameters
----------
package_name:
    Name of the package whose post-link script is running.
script_path:
    Relative path to the script within the prefix.

Returns
-------
int
    An opaque token passed back to :meth:`on_post_link_complete`.
r   r   r*   rm   s   &&&r   on_post_link_start$InstallerReporter.on_post_link_start   r0   r   c               $    V ^8  d   QhRRRRRR/# r   rV   r   successboolr   r   r   )r   s   "r   r   r      s!     	 	3 	 	$ 	r   c                    R# )zCalled when a post-link script finishes.

Parameters
----------
index:
    Token returned by :meth:`on_post_link_start`.
success:
    ``True`` if the script exited successfully.
Nr   r   rV   rt   s   &&&r   on_post_link_complete'InstallerReporter.on_post_link_complete   r    r   c               $    V ^8  d   QhRRRRRR/# rl   r   )r   s   "r   r   r      s!       # # r   c                    ^ # )a+  Called when a pre-unlink script begins execution.

Parameters
----------
package_name:
    Name of the package whose pre-unlink script is running.
script_path:
    Relative path to the script within the prefix.

Returns
-------
int
    An opaque token passed back to :meth:`on_pre_unlink_complete`.
r   ro   s   &&&r   on_pre_unlink_start%InstallerReporter.on_pre_unlink_start   r0   r   c               $    V ^8  d   QhRRRRRR/# rs   r   )r   s   "r   r   r   
  s!     	 	C 	$ 	4 	r   c                    R# )zCalled when a pre-unlink script finishes.

Parameters
----------
index:
    Token returned by :meth:`on_pre_unlink_start`.
success:
    ``True`` if the script exited successfully.
Nr   rw   s   &&&r   on_pre_unlink_complete(InstallerReporter.on_pre_unlink_complete
  r    r   r   N)__name__
__module____qualname____firstlineno____doc__r   r&   r.   r6   r;   r?   rF   rJ   rN   rR   rY   r]   ra   re   ri   rp   rx   r|   r   __static_attributes__r   r   r   r   r      sm    !F" ""D"	"	 	r   r   c               L    V ^8  d   QhRRRRRRRRR	R
RR
RRRRRRRRRRRRRR/# )r   recordszList[RepoDataRecord]target_prefixzstr | os.PathLike[str]	cache_dirzOptional[os.PathLike[str]]installed_packageszOptional[List[PrefixRecord]]reinstall_packageszOptional[set[str]]ignored_packagesplatformzOptional[Platform]execute_link_scriptsru   show_progressclientzOptional[Client]requested_specszOptional[List[MatchSpec]]reporterzOptional[InstallerReporter]r   r   r   )r   s   "r   r   r     s     X X!X)X *X 5	X
 +X )X !X X X X /X *X 
Xr   c                   "   \        T \        V4      TTTTVe   VP                  MRV	e   V	P                  MRVVV
VR7      G Rj  xL
  R#  L5i)a_  
Create an environment by downloading and linking the `dependencies` in
the `target_prefix` directory.

!!! warning

    When `execute_link_scripts` is set to `True` the post-link and pre-unlink scripts of
    packages will be executed. These scripts are not sandboxed and can be used to execute
    arbitrary code. It is therefor discouraged to enable executing link scripts.

Example
-------
```python
>>> import asyncio
>>> from rattler import solve, install
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
>>>
>>> async def main():
...     # Solve an environment with python 3.9 for the current platform
...     records = await solve(sources=["conda-forge"], specs=["python 3.9.*"])
...
...     # Link the environment in a temporary directory (you can pass any kind of path here).
...     await install(records, target_prefix=temp_dir.name)
...
...     # That's it! The environment is now created.
...     # You will find Python under `f"{temp_dir.name}/bin/python"` or `f"{temp_dir.name}/python.exe"` on Windows.
>>> asyncio.run(main())

```

Arguments:
    records: A list of solved `RepoDataRecord`s.
    target_prefix: Path to the directory where the environment should
            be created.
    cache_dir: Path to directory where the dependencies will be
            downloaded and cached.
    installed_packages: A list of `PrefixRecord`s which are
            already installed in the `target_prefix`. This can be obtained by loading
            `PrefixRecord`s from `{target_prefix}/conda-meta/`.
            If `None` is specified then the `target_prefix` will be scanned for installed
            packages.
    reinstall_packages: A list of package names that should be reinstalled.
    ignored_packages: A list of package names that should be ignored (left untouched).
            These packages will not be removed, installed, or updated.
    platform: Target platform to create and link the
            environment. Defaults to current platform.
    execute_link_scripts: whether to execute the post-link and pre-unlink scripts
            that may be part of a package. Defaults to False.
    show_progress: If set to `True` a progress bar will be shown on the CLI.
            Ignored when `reporter` is provided.
    client: An authenticated client to use for downloading packages. If not specified a default
            client will be used.
    requested_specs: A list of `MatchSpec`s that were originally requested. These will be used
            to populate the `requested_specs` field in the generated `conda-meta/*.json` files.
            If `None`, the `requested_specs` field will remain empty.
    reporter: An optional :class:`InstallerReporter` instance that receives progress
            callbacks during installation. When provided, `show_progress` is ignored.
            Subclass :class:`InstallerReporter` and override the methods you need.
N)r   r   r   r   r   r   r   r   r   r   r   r   )r   r+   _inner_client)r   r   r   r   r   r   r   r   r   r   r   r   s   &&&&&&&&&&&&r   installr     sY     V -(--)$,$8d!'!3v~~1#'  s   AAAA)
NNNNNFTNNN)
__future__r   ostypingr   r   r   r   rattler.match_specr   rattler.networking.clientr	   rattler.platform.platformr
   rattler.prefix.prefix_recordr   rattler.repo_data.recordr   rattler.rattlerr   r   r   r   r   r   <module>r      sN    " 	 > > ( , . 5 3 & D D DNX Xr   