o
    (c                     @   s~   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ ddlmZ dd	lmZ G d
d deeZdS )    )ABCabstractmethod)log)Command)DistutilsPlatformError)ListOptional)Distribution   )RustExtensionget_rust_versionc                   @   sV   e Zd ZU dZeed< eed< dddZddd	Zdd
dZ	e
deddfddZdS )RustCommandzEAbstract base class for commands which interact with Rust Extensions.distributionverbosereturnNc                 C   s
   g | _ d S N)
extensions)self r   ;usr/lib/python3.10/site-packages/setuptools_rust/command.pyinitialize_options   s   
zRustCommand.initialize_optionsc                 C   s~   t | jdd }|d u rd S t|tst|}td| dt|D ]\}}t|ts9t|}td| d| q"|| _d S )NZrust_extensionszUexpected list of RustExtension objects for rust_extensions argument to setup(), got ``zLexpected RustExtension object for rust_extensions argument to setup(), got `z` at position )	getattrr   
isinstancelisttype
ValueError	enumerater   r   )r   r   tyi	extensionr   r   r   finalize_options   s0   


zRustCommand.finalize_optionsc                 C   s`  | j std|   d S tdd | j D }z,t }|d u rBttdd dd | j D d d}td|d ur>d	| d
 d W n ty_ } z|sN t	t
| W Y d }~d S d }~ww | j D ]J}z| }|d ur|||vr|td| d| | | W qc ty } z|js |  }t	| d|j d t	t
| W Y d }~qcd }~ww d S )Nz%s: no rust_extensions definedc                 s   s    | ]}|j V  qd S r   )optional.0extr   r   r   	<genexpr>7   s    z"RustCommand.run.<locals>.<genexpr>c                 S   s   | d uS r   r   )versionr   r   r   <lambda>=   s    z!RustCommand.run.<locals>.<lambda>c                 s   s    | ]}|  V  qd S r   r   r$   r   r   r   r'   >   s    )defaultaq  can't find Rust compiler

If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

To update pip, run:

    pip install --upgrade pip

and then retry package installation.

If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.z

This package requires Rust . zRust z& does not match extension requirement z: optional Rust extension z failed)r   r   infoget_command_nameallr   maxfilterr   printstrrun_for_extension	Exceptionr#   name)r   Zall_optionalr(   min_versioner&   Zrust_versioncommand_namer   r   r   run2   s`   

zRustCommand.runr!   c                 C   s   d S r   r   )r   r!   r   r   r   r4   n   s   zRustCommand.run_for_extension)r   N)__name__
__module____qualname____doc__r	   __annotations__intr   r"   r:   r   r   r4   r   r   r   r   r      s   
 


<r   N)abcr   r   	distutilsr   distutils.cmdr   distutils.errorsr   typingr   r   setuptools.distr	   r!   r   Z
rustc_infor   r   r   r   r   r   <module>   s    