
    dfnb                     X   d Z ddlZddl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	m
Z
mZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZ ddl m!Z! ddl"m#Z# e
rddl$m%Z% ddl&m'Z' ee(ejR                  f   Z*ededef   f   Z+	 ede+f   Z, eded         Z-	 	 d2de*de.fdZ/ddde*ddfdZ0	 	 d3ddde*dee*   de1ded   f
dZ2de-de(fd Z3d!ed   de.fd"Z4	 d4d#dd$e,ded%   fd&Z5d'e(d(e(d)e6fd*Z7 G d+ d,ee-         Z8 G d- d.e8d/         Z9 G d0 d1e8d         Z:y)5ze
Load setuptools configuration from ``setup.cfg`` files.

**API will be made private in the future**
    N)defaultdict)partialwraps)TYPE_CHECKINGCallableAnyDictGenericIterableListOptionalTupleTypeVarUnion)DistutilsOptionErrorDistutilsFileError)RequirementInvalidRequirement)VersionInvalidVersion)SpecifierSet)SetuptoolsDeprecationWarning   )expandDistribution)DistributionMetadatastrTarget)r   r   )boundfilepathreturnc                 v    ddl m}  |       }|r|j                         ng }t        || ||      }t	        |      S )a,  Read given configuration file and returns options from it as a dict.

    :param str|unicode filepath: Path to configuration file
        to get options from.

    :param bool find_others: Whether to search for other configuration files
        which could be on in various places.

    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.

    :rtype: dict
    r   r   )setuptools.distr   find_config_files_applyconfiguration_to_dict)r"   find_othersignore_option_errorsr   dist	filenameshandlerss          S/home/api-vastappli/venv/lib/python3.12/site-packages/setuptools/config/setupcfg.pyread_configurationr/   (   s<    ( ->D,7&&(RIdHi1EFH **    r+   r   c                 >    t        | |       | j                          | S )z`Apply the configuration from a ``setup.cfg`` file into an existing
    distribution object.
    )r'   _finalize_requires)r+   r"   s     r.   apply_configurationr3   D   s     4Kr0   other_filesr*   )ConfigHandler.c                    ddl m} t        j                  j	                  |      }t        j                  j                  |      st        d|z        t        j                         }t        j                  t        j                  j                  |             g ||}	 |j                  | |       t        | | j                  |      }| j                          t        j                  |       |S # t        j                  |       w xY w)zHRead configuration from ``filepath`` and applies to the ``dist`` object.r   )_Distributionz%Configuration file %s does not exist.)r,   )r*   )r%   r7   ospathabspathisfiler   getcwdchdirdirnameparse_config_filesparse_configurationcommand_options_finalize_license_files)r+   r"   r4   r*   r7   current_directoryr,   r-   s           r.   r'   r'   M   s     .wwx(H77>>(# !H8!STT		HHRWW__X&'(+(x(I$(((C&$&&=Q
 	$$&
"#O 	"#s    ;C2 2D	
target_objkeyc                      dj                   di t               }t        j                  t        | |      }t	        | ||      } |       S )z
    Given a target object and option key, get that option from
    the target object, either through a get_{key} method or
    from an attribute directly.
    z	get_{key} )formatlocals	functoolsr   getattr)rD   rE   getter_nameby_attributegetters        r.   _get_optionrO   j   sD     %+$$0vx0K$$Wj#>LZl;F8Or0   r-   c                     t        t              }| D ];  }|j                  D ]*  }t        |j                  |      }|||j
                     |<   , = |S )zReturns configuration data gathered by given handlers as a dict.

    :param list[ConfigHandler] handlers: Handlers list,
        usually from parse_configuration()

    :rtype: dict
    )r   dictset_optionsrO   rD   section_prefix)r-   config_dicthandleroptionvalues        r.   r(   r(   v   se     $D)K @)) 	@F 2 2F;E:?K../7	@@
 r0   distributionrA   )ConfigMetadataHandlerConfigOptionsHandlerc           	      V   t        j                  |       5 }t        | |||      }|j                          | j                  s|j                  | _        t        | j                  |||| j                  | j                        }|j                          ddd       ||fS # 1 sw Y   fS xY w)a  Performs additional parsing of configuration options
    for a distribution.

    Returns a list of used option handlers.

    :param Distribution distribution:
    :param dict command_options:
    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.
    :rtype: list
    N)r   EnsurePackagesDiscoveredrZ   parsepackage_dirrY   metadatasrc_root)rX   rA   r*   ensure_discoveredoptionsmetas         r.   r@   r@      s    $ 
	(	(	6 :K& 	
 	'''.':':L$$!! $$!!
 	

), =-, =s   A:BB(label
orig_valueparsedc                 "   d|v st        |      dk7  ryt        j                  t              5  dj	                  |      }t        |      }|j                  &d|  d|d    d}t        j                  |t               ddd       y# 1 sw Y   yxY w)	am  Because users sometimes misinterpret this configuration:

    [options.extras_require]
    foo = bar;python_version<"4"

    It looks like one requirement with an environment marker
    but because there is no newline, it's parsed as two requirements
    with a semicolon as separator.

    Therefore, if:
        * input string does not contain a newline AND
        * parsed result contains two requirements AND
        * parsing of the two parts from the result ("<first>;<second>")
        leads in a valid Requirement with a valid marker
    a UserWarning is shown to inform the user about the possible problem.
    
   N;z#One of the parsed requirements in `z*` looks like a valid environment marker: 'r   z}'
Make sure that the config is correct and check https://setuptools.pypa.io/en/latest/userguide/declarative_config.html#opt-2)
len
contextlibsuppressr   joinr   markerwarningswarnUserWarning)rd   re   rf   original_requirements_strreqmsgs         r.   %_warn_accidental_env_marker_misconfigrv      s    " zS[A-			/	0 
,$'HHV$4!34::!5eW =;;A!9+ F__  MM#{+
, 
, 
,s   ABBc                      e Zd ZU dZeed<   	 i Zeeef   ed<   	 dede	de
j                  fdZed        Zd	 Zedd
       Zed        Zed        Zed        Zedefd       ZdefdZed        Zed        Zedd       Zd Zd Zd Zy)r5   z1Handles metadata supplied in configuration files.rS   aliasesrD   rb   ra   c                    i }| j                   }|j                         D ]=  \  }}|j                  |      s|j                  |d      j	                  d      }|||<   ? || _        || _        || _        g | _        || _	        y )N .)
rS   items
startswithreplacestripr*   rD   sectionsrR   ra   )	selfrD   rb   r*   ra   r   rS   section_namesection_optionss	            r.   __init__zConfigHandler.__init__   s     '),,-4]]_ 	5)L/**>:'//CII#NL%4H\"	5 %9!$ &(!2r0   c                 F    t        d| j                  j                  z        ).Metadata item name to parser function mapping.z!%s must provide .parsers property)NotImplementedError	__class____name__)r   s    r.   parserszConfigHandler.parsers   s#     "/$..2I2II
 	
r0   c                    t               }| j                  }| j                  j                  ||      }t	        |||      }||u rt        |      |ry d}| j                  j                  |      }|r		  ||      }|ry t	        |d|z  d       }|t        |||       n ||       | j                  j                  |       y # t        $ r d}| j                  s Y aw xY w)NFTzset_%s)tuplerD   rx   getrK   KeyErrorr   	Exceptionr*   setattrrR   append)	r   option_namerW   unknownrD   current_valueskip_optionparsersetters	            r.   __setitem__zConfigHandler.__setitem__  s    '__
 ll&&{K@
KAG#;''!!+.u X%;TB>JU35M,  "00 1s   2C CCc                     t        |t              r|S d|v r|j                         }n|j                  |      }|D cg c]#  }|j	                         s|j	                         % c}S c c}w )zRepresents value as a list.

        Value is split either by separator (defaults to comma) or by lines.

        :param value:
        :param separator: List items separator character.
        :rtype: list
        rh   )
isinstancelist
splitlinessplitr   )clsrW   	separatorchunks       r.   _parse_listzConfigHandler._parse_list(  sX     eT"L5=$$&EKK	*E+0B%EKKMBBBs   A(A(c                     d}i }| j                  |      D ]K  }|j                  |      \  }}}||k7  rt        d|z        |j                         ||j                         <   M |S )zPRepresents value as a dict.

        :param value:
        :rtype: dict
        =z(Unable to parse option value to dict: %s)r   	partitionr   r   )r   rW   r   resultlinerE   sepvals           r.   _parse_dictzConfigHandler._parse_dict<  sv     	OOE* 	.D NN95MCci*>F  #&))+F399;	. r0   c                 *    |j                         }|dv S )zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )1trueyes)lowerr   rW   s     r.   _parse_boolzConfigHandler._parse_boolO  s     ,,,r0   c                     fd}|S )zReturns a parser function to make sure field inputs
        are not files.

        Parses a value after getting the key so error messages are
        more informative.

        :param key:
        :rtype: callable
        c                 b    d}| j                  |      rt        dj                              | S )Nfile:zCOnly strings are accepted for the {0} field, files are not accepted)r}   
ValueErrorrH   )rW   exclude_directiverE   s     r.   r   z3ConfigHandler._exclude_files_parser.<locals>.parsere  s:     ' 12 --3VC[  Lr0   rG   )r   rE   r   s    ` r.   _exclude_files_parserz#ConfigHandler._exclude_files_parserY  s    	 r0   root_dirc                     d}t        |t              s|S |j                  |      s|S |t        |      d }d |j	                  d      D        }t        j                  ||      S )aO  Represents value as a string, allowing including text
        from nearest files using `file:` directive.

        Directive is sandboxed and won't reach anything outside
        directory with setup.py.

        Examples:
            file: README.rst, CHANGELOG.md, src/file.txt

        :param str value:
        :rtype: str
        r   Nc              3   <   K   | ]  }|j                           y wN)r   ).0r9   s     r.   	<genexpr>z,ConfigHandler._parse_file.<locals>.<genexpr>  s     >dTZZ\>s   ,)r   r   r}   rk   r   r   
read_files)r   rW   r   include_directivespec	filepathss         r.   _parse_filezConfigHandler._parse_filep  se     $%%L 12LS*+-.>djjo>	  H55r0   c                     d}|j                  |      s|S |j                  |d      }|j                  | j                  j                         t        j                  |||      S )zRepresents value as a module attribute.

        Examples:
            attr: package.attr
            attr: package.module.attr

        :param str value:
        :rtype: str
        zattr:rz   )r}   r~   updatera   r^   r   	read_attr)r   rW   r^   r   attr_directive	attr_descs         r.   _parse_attrzConfigHandler._parse_attr  s]     !/LMM."5	 	411==>	;AAr0   c                     fd}|S )zReturns parser function to represents value as a list.

        Parses a value applying given methods one after another.

        :param parse_methods:
        :rtype: callable
        c                 *    | }D ]
  } ||      } |S r   rG   )rW   rf   methodparse_methodss      r.   r]   z1ConfigHandler._get_parser_compound.<locals>.parse  s'    F' (( Mr0   rG   )r   r   r]   s    ` r.   _get_parser_compoundz"ConfigHandler._get_parser_compound  s    	 r0   c                 X    i }|j                         D ]  \  }\  }} |||      ||<    |S )a  Parses section options into a dictionary.

        Applies a given parser to each option in a section.

        :param dict section_options:
        :param callable values_parser: function with 2 args corresponding to key, value
        :rtype: dict
        )r|   )r   r   values_parserrW   rE   _r   s          r.   _parse_section_to_dict_with_keyz-ConfigHandler._parse_section_to_dict_with_key  s>     ,224 	1MC!S&sC0E#J	1r0   Nc                 <    rfdnd }| j                  ||      S )a   Parses section options into a dictionary.

        Optionally applies a given parser to each value.

        :param dict section_options:
        :param callable values_parser: function with 1 arg corresponding to option value
        :rtype: dict
        c                      |      S r   rG   )r   vr   s     r.   <lambda>z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>  s    }Q/ r0   c                     |S r   rG   )r   r   s     r.   r   z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>  s    UV r0   r   )r   r   r   r   s     ` r.   _parse_section_to_dictz$ConfigHandler._parse_section_to_dict  s#     5B/22?FKKr0   c                     |j                         D ]/  \  }\  }}t        j                  t              5  || |<   ddd       1 y# 1 sw Y   <xY w)zQParses configuration file section.

        :param dict section_options:
        N)r|   rl   rm   r   )r   r   namer   rW   s        r.   parse_sectionzConfigHandler.parse_section  sV    
 #2"7"7"9 	#T:Au$$X. #"T
# #	## #s   AA	c                     | j                   j                         D ]T  \  }}d}|rd|z  }t        | d|z  j                  dd      d      }|t	        d| j
                  d|d       ||       V y)	zTParses configuration file items from one
        or more related sections.

        rz   z_%szparse_section%sr{   __Nz*Unsupported distribution option section: [])r   r|   rK   r~   r   rS   )r   r   r   method_postfixsection_parser_methods        r.   r]   zConfigHandler.parse  s    
 .2]]-@-@-B 	3)L/N!&!58?"^3<<S$G	9! %,***L: 
 "/2'	3r0   c                 6    t              fd       }|S )zthis function will wrap around parameters that are deprecated

        :param msg: deprecation message
        :param warning_class: class of warning exception to be raised
        :param func: function to be wrapped around
        c                  @    t        j                          | i |S r   )rp   rq   )argskwargsfuncru   warning_classs     r.   config_handlerz@ConfigHandler._deprecated_config_handler.<locals>.config_handler  s!    MM#}-(((r0   r   )r   r   ru   r   r   s    ``` r.   _deprecated_config_handlerz(ConfigHandler._deprecated_config_handler  s#     
t	) 
	) r0   )r   r   )r   
__module____qualname____doc__r   __annotations__rx   r
   r    AllCommandOptionsr   r\   r   propertyr   r   classmethodr   r   r   r   _Pathr   r   r   r   r   r   r]   r   rG   r0   r.   r5   r5      s2   ;
 !GT#s(^ 33 #3
 "::3. 
 
$-L C C&  $ - -  , 6% 6 62B B(  &   
L 
L#34r0   r5   c                        e Zd ZdZdddddZdZ	 dej                  fd	d
dede	de
j                  dee   def fdZed        Zd Z xZS )rY   r_   urldescriptionclassifiers	platforms)	home_pagesummary
classifierplatformFNrD   r   rb   r*   ra   r^   r   c                 F    t         |   ||||       || _        || _        y r   )superr   r^   r   )r   rD   rb   r*   ra   r^   r   r   s          r.   r   zConfigMetadataHandler.__init__  s)     	W.BDUV& r0   c                 L   | j                   }t        | j                  | j                        }| j                  }| j
                  }|||| j                  |dt              || j                  ||       |d      | j                   |d      dt              |||| j                  |dS )r   r   z[The requires parameter is deprecated, please use install_requires for runtime dependencies.licenselicense_filezDThe license_file parameter is deprecated, use license_files instead.)r   keywordsprovidesrequires	obsoletesr   r   r   license_filesr   long_descriptionversionproject_urls)
r   r   r   r   r   r   r   r   r   _parse_version)r   
parse_list
parse_file
parse_dictexclude_files_parsers        r.   r   zConfigMetadataHandler.parsers   s     %%
T--F
%%
#99 $""77=,	 $44ZL+I6 ;;$^4-,	 (% ***&/
 	
r0   c           	      X   | j                  || j                        }||k7  r|j                         }	 t        |       |S t        j                  | j                  || j                  | j                              S # t        $ r& d}t         |j                  di t                     w xY w)zSParses `version` option value.

        :param value:
        :rtype: str

        zCVersion loaded from {value} does not comply with PEP 440: {version}rG   )r   r   r   r   r   r   rH   rI   r   r  r   r^   )r   rW   r  tmpls       r.   r  z$ConfigMetadataHandler._parse_versionB  s     ""5$--8emmoGD  N~~d..ud6F6FVWW " D5  +;4;;+B+BCCDs   A: :/B))r   r   r   rS   rx   strict_moder8   curdirr   boolr   r\   r   rQ   r   r   r   r   r  __classcell__r   s   @r.   rY   rY     s    N  #	G K '+))!*! #! #	!
 "::! d^! ! 
 
BXr0   rY   r   c                        e Zd ZdZdddededej                  f fdZe	d        Z
d Zd	ed
efdZed        Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )rZ   rb   rD   r   r*   ra   c                 Z    t         |   ||||       |j                  | _        i | _        y r   )r   r   r`   r   r^   )r   rD   rb   r*   ra   r   s        r.   r   zConfigOptionsHandler.__init__a  s/     	W.BDUV"+++-r0   c                 (    | j                  |d      S )Nrj   )r   )r   r   s     r.   _parse_list_semicolonz*ConfigOptionsHandler._parse_list_semicolonl  s    u44r0   c                 <    | j                  || j                        S )Nr   )r   r   )r   rW   s     r.   _parse_file_in_rootz(ConfigOptionsHandler._parse_file_in_rootp  s    >>r0   rd   rW   c                     | j                  | j                  |            }t        |||       |D cg c]  }|j                  d      r| c}S c c}w )N#)r  r  rv   r}   )r   rd   rW   rf   r   s        r.   _parse_requirements_listz-ConfigOptionsHandler._parse_requirements_lists  sJ    ++D,D,DU,KL-eUFC "(Dts/CDDDs   A	Ac                 0   | j                   }| j                  }| j                  }| j                  }||||||| j	                  |dt
              t        | j                  d      | j                  | j                  | j                  | j                  |t        |dS )r   zeThe namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).install_requires)zip_safeinclude_package_datar^   scriptseager_resourcesdependency_linksnamespace_packagesr  setup_requirestests_requirepackagesentry_points
py_modulespython_requirescmdclass)r   r   r   _parse_cmdclassr   r   r   r  r  _parse_packagesr  r   )r   r	  
parse_boolr  parse_cmdclasss        r.   r   zConfigOptionsHandler.parsers{  s     %%
%%
%%
-- #$.%!) *"&"A"AH,	# !(--/A! #88!77,, 44$+&-
 	
r0   c                     | j                   j                  }t        j                  | j	                  |      || j
                        S r   )ra   r^   r   r+  r   r   )r   rW   r^   s      r.   r,  z$ConfigOptionsHandler._parse_cmdclass  s5    ,,88t//6T]]SSr0   c                 0   ddg}|j                         }||vr| j                  |      S | j                  | j                  j	                  di             }|j                  ||d   k(  | j                  | j                         t        j                  di |S )zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:zfind_namespace:zpackages.findr   )
namespacesr   fill_package_dirrG   )
r   r   parse_section_packages__findr   r   r   r   r^   r   find_packages)r   rW   find_directivestrimmed_valuefind_kwargss        r.   r-  z$ConfigOptionsHandler._parse_packages  s     #$56/##E** 77MMor2
 	%);;]]!-- 	 	
 ##2k22r0   c                     | j                  || j                        }g d}t        |j                         D cg c]  \  }}||v s|s||f c}}      }|j	                  d      }||d   |d<   |S c c}}w )zParses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        )whereincludeexcluder:  r   )r   r   rQ   r|   r   )r   r   section_data
valid_keyskr   r8  r:  s           r.   r4  z1ConfigOptionsHandler.parse_section_packages__find  s     22?DDTDTU4
 , 2 2 4N1ZAaVN
 (#(8K  Os   A4
A4
	A4
c                 F    | j                  || j                        }|| d<   y)z`Parses `entry_points` configuration file section.

        :param dict section_options:
        r(  N)r   r   r   r   rf   s      r.   parse_section_entry_pointsz/ConfigOptionsHandler.parse_section_entry_points  s&    
 ,,_d>N>NO%^r0   c                 d    | j                  || j                        }t        j                  |      S r   )r   r   r   canonic_package_data)r   r   package_datas      r.   _parse_package_dataz(ConfigOptionsHandler._parse_package_data  s+    22?DDTDTU**<88r0   c                 ,    | j                  |      | d<   y)z`Parses `package_data` configuration file section.

        :param dict section_options:
        rE  NrF  r   r   s     r.   parse_section_package_dataz/ConfigOptionsHandler.parse_section_package_data  s    
  $77H^r0   c                 ,    | j                  |      | d<   y)zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        exclude_package_dataNrH  rI  s     r.   "parse_section_exclude_package_dataz7ConfigOptionsHandler.parse_section_exclude_package_data  s    
 (,'?'?'P#$r0   c                 :      j                  | fd      }| d<   y)zbParses `extras_require` configuration file section.

        :param dict section_options:
        c                 0    j                  d|  d|      S )Nzextras_require[r   )r  )r?  r   r   s     r.   r   zCConfigOptionsHandler.parse_section_extras_require.<locals>.<lambda>  s    6617MqQ r0   extras_requireNr   rA  s   `  r.   parse_section_extras_requirez1ConfigOptionsHandler.parse_section_extras_require  s(    
 55Q

 "(r0   c                     | j                  || j                        }t        j                  || j                        | d<   y)z^Parses `data_files` configuration file section.

        :param dict section_options:
        
data_filesN)r   r   r   canonic_data_filesr   rA  s      r.   parse_section_data_filesz-ConfigOptionsHandler.parse_section_data_files  s7    
 ,,_d>N>NO#66vt}}M\r0   )r   r   r   rS   r   r  r   r\   r   r   r  r  r   r  r   r   r,  r-  r4  rB  rF  rJ  rM  rQ  rU  r  r  s   @r.   rZ   rZ   ]  s    N	."	. #	. #		.
 "::	. 5 5?Ec E# E 
 
@T32*&9IQ
(Nr0   rZ   )FF)rG   F)F);r   r8   rl   rJ   rp   collectionsr   r   r   typingr   r   r	   r
   r   r   r   r   r   r   r   distutils.errorsr   r   (setuptools.extern.packaging.requirementsr   r   #setuptools.extern.packaging.versionr   r   &setuptools.extern.packaging.specifiersr   setuptools._deprecation_warningr   rz   r   r%   r   distutils.distr   r   PathLiker   SingleCommandOptionsr   r    rQ   r/   r3   r  r'   rO   r(   r@   r   rv   r5   rY   rZ   rG   r0   r.   <module>r`     s  
 
    #  5 5 5 5 F T G ? H ,3c2;;E5#445 
  445 	'M!N	O
 ++ 
	+8n  .  $&!&
$)%   	:	F 	 	E*>$? D * ( (&( :;	(V, ,# ,t ,BkGFO k\	XXM*@A XXv]N=8 ]Nr0   