o
    b                     @  s   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlZddl	m
Z
 ddl	mZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ erVddl	mZ ejfd(ddZe  d)ddZd*ddZd+d,d$d%Zd-d&d'ZdS ).    )annotationsN)Any)Callable)TYPE_CHECKING   )_get_version)_version_missing)iter_entry_points)read_dist_name_from_setup_cfg)Configuration)do)trace)_types_versionstrreturnNonec                 C  s4   t | dd dk rttd|  d d S d S )N.r   -   z
ERROR: setuptools==aq   is used in combination with setuptools_scm>=6.x

Your build configuration is incomplete and previously worked by accident!
setuptools_scm requires setuptools>=45


This happens as setuptools is unable to replace itself when a activated build dependency
requires a more recent setuptools version
(it does not respect "setuptools>X" in setup_requires).


setuptools>=31 is required for setup.cfg metadata support
setuptools>=42 is required for pyproject.toml configuration support

Suggested workarounds if applicable:
 - preinstalling build dependencies like setuptools_scm before running setup.py
 - installing setuptools_scm using the system package manager to ensure consistency
 - migrating from the deprecated setup_requires mechanism to pep517/518
   and using a pyproject.toml to declare build dependencies
   which are reliably pre-installed before running the build tools
)intsplitwarningswarnRuntimeWarning)r    r   >usr/lib/python3.10/site-packages/setuptools_scm/integration.py_warn_on_old_setuptools   s   r   distsetuptools.Distributionconfigr   c                 C  s(   t |}|d u rt| d S || j_d S )N)r   r   metadataversion)r   r   maybe_versionr   r   r   _assign_version:   s   r#   keywordvalue4bool | dict[str, Any] | Callable[[], dict[str, Any]]c                 C  sz   |sd S |du ri }nt |r| }d|vsJ dtdt| j | jj}|d u r-t }tdd|i|}t| | d S )NT	dist_namez4dist_name may not be specified in the setup keyword zversion keywordr   )callabler   varsr    name_read_dist_name_from_setup_cfgr   r#   )r   r$   r%   r'   r   r   r   r   version_keywordC   s$   
r,    path_t.PathT	list[str]c                 C  sP   t dD ]!}| }t|trt| | pd }n|| }|r%|  S qg S )Nzsetuptools_scm.files_commandr   )r	   load
isinstancer   r   
splitlines)r.   epcommandresr   r   r   
find_files]   s   
r7   c              
   C  s   t dt| j | jj}|d u rt }tjdsd S |dkr!d S ztj	|d}W n t
y@ } zt | W Y d }~d S d }~ww t| | d S )Nzfinalize hookzpyproject.tomlsetuptools_scm)r'   )r   r)   r    r*   r+   osr.   isfiler   	from_fileLookupErrorr#   )r   r'   r   er   r   r   infer_versionj   s$   r>   )r   r   r   r   )r   r   r   r   r   r   )r   r   r$   r   r%   r&   r   r   )r-   )r.   r/   r   r0   )r   r   r   r   )
__future__r   r9   r   typingr   r   r   
setuptoolsr-   r   r   _entrypointsr	   Z_integration.setuptoolsr
   r+   r   r   utilsr   r   r   Z_t__version__r   r#   r,   r7   r>   r   r   r   r   <module>   s,    

	