
    uYfd                     t   d 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mZ ddlmZ dd	lmZmZ dd
lmZ ddlmZmZ ddl m!Z! ddl"m#Z#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dedef   f   Z-	 ede-f   Z. eded         Z/	 d9dede0fdZ1dddeddfdZ2	 	 d:dddedee   de3ded   f
d Z4d!e/d"e5fd#Z6d$ed   de0fd%Z7	 d;d&dd'e.ded(   fd)Z8d*e5d+e5d,e9fd-Z: G d. d/ee/         Z; G d0 d1e;d2         Z< G d3 d4e;d         Z= G d5 d6e&      Z> G d7 d8e&      Z?y)<a<  
Load setuptools configuration from ``setup.cfg`` files.

**API will be made private in the future**

To read project metadata, consider using
``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).
For simple scenarios, you can also try parsing the file directly
with the help of ``configparser``.
    N)defaultdict)partialwraps)TYPE_CHECKINGCallableAnyDictGenericIterableListOptionalSetTupleTypeVarUnion   )StrPath)	FileErrorOptionError)default_environment)InvalidRequirementRequirement)SpecifierSet)InvalidVersionVersion)SetuptoolsDeprecationWarning   )expand)DistributionMetadataDistribution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          Z/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/setuptools/config/setupcfg.pyread_configurationr3   9   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     r2   apply_configurationr7   S   s     4Kr4   other_filesr.   )ConfigHandler.c                    ddl m} t        j                  j	                  |      }t        j                  j                  |      st        d| d      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 z does not exist.)r0   )r.   )r)   r;   ospathabspathisfiler   getcwdchdirdirnameparse_config_filesparse_configurationcommand_options_finalize_license_files)r/   r&   r8   r.   r;   current_directoryr0   r1   s           r2   r+   r+   \   s     .wwx(H77>>(#-hZ7GHII		HHRWW__X&'(+(x(I$(((C&$&&=Q
 	$$&
"#O 	"#s   !;C3 3D

target_objkeyc                 j    d| }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.
    get_)	functoolsr   getattr)rH   rI   getter_nameby_attributegetters        r2   _get_optionrQ   z   s8     ,K$$Wj#>LZl;F8Or4   r1   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_optionsrQ   rH   section_prefix)r1   config_dicthandleroptionvalues        r2   r,   r,      se     $D)K @)) 	@F 2 2F;E:?K../7	@@
 r4   distributionrE   )ConfigMetadataHandlerConfigOptionsHandlerc           	         t        j                  |       5 }t        | |||      }|j                          | j                  s|j                  | _        t        | j                  |||| j                  | j                        }|j                          | 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   EnsurePackagesDiscoveredr\   parsepackage_dirr[   metadatasrc_root_referenced_filesupdate)rZ   rE   r.   ensure_discoveredoptionsmetas         r2   rD   rD      s    $ 
	(	(	6 
:K& 	
 	'''.':':L$$!! $$!!
 	

&&--%%t'='=	
+
2 =3
2 =s   B*CClabel
orig_valueparsedc                 l   d|v st              dk7  ryt               j                         }	 t        d         }|j                  |v rt
        j                  | d          yy# t        $ rD}t        fd|D              r&t
        j                  | d         }t        |      |Y d}~yd}~ww 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.
    
r   Nr   )fieldreqc              3   F   K   | ]  }d    j                  |        yw)r   N)
startswith).0markerrj   s     r2   	<genexpr>z8_warn_accidental_env_marker_misconfig.<locals>.<genexpr>   s      Bvay##F+Bs   !)
len
marker_envkeysr   name_AmbiguousMarkeremitr   anymessage)rh   ri   rj   markersrn   exmsgs     `    r2   %_warn_accidental_env_marker_misconfigr      s    " zS[A-l!G2&)$88w!!6!9!=  2B'BB"**F1I*FC$S)r1 C2s   6A& &	B3/:B..B3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e	fd       Zed	        Zd
 Zedd       Zed        Zed        Zed        ZdefdZdefdZed        Zed        Zedd       Zd ZddZd Zy)r9   z1Handles metadata supplied in configuration files.rU   aliasesrH   rf   re   c                     || _         || _        t        | j                  |            | _        g | _        || _        t               | _        y N)	r.   rH   rS   _section_optionssectionsrT   re   setrc   )selfrH   rf   r.   re   s        r2   __init__zConfigHandler.__init__   sI     %9!$T227;<&(!2+.5	r4   c              #      K   |j                         D ]<  \  }}|j                  | j                        \  }}}|r(|j                  d      |f > y w)N.)items	partitionrU   lstrip)clsrf   	full_namerY   preseprw   s          r2   r   zConfigHandler._section_options  sV      ' 	*Iu&001C1CDNCd++c"E))		*s   AA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    r2   parserszConfigHandler.parsers  s#     "/$..2I2II
 	
r4   c                    | j                   }| j                  j                  ||      }	 t        ||      }|ry 	  | j                  j                  |d       |      }t        j                  |j                  |      }t        |d|z  |      } ||       | j                  j                  |       y # t        $ r}t        |      |d }~ww xY w# t        f| j                  z  $ r Y y w xY w)Nc                     | S r    )xs    r2   <lambda>z+ConfigHandler.__setitem__.<locals>.<lambda>&  s    Q r4   zset_%s)rH   r   getrM   AttributeErrorKeyErrorr   	Exceptionr.   rL   r   __setattr__rT   append)	r   option_namerY   rH   current_valueerj   simple_settersetters	            r2   __setitem__zConfigHandler.__setitem__  s    __
 ll&&{K@	/#J<M 	?T\\%%k;?FF "))**@*@+NX%;]Kv,!  	/;'Q.	/ |d777 		s(   B1 #C 1	C:C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
        rl   )
isinstancelist
splitlinessplitstrip)r   rY   	separatorchunks       r2   _parse_listzConfigHandler._parse_list0  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|       |j                         ||j                         <   M |S )zPRepresents value as a dict.

        :param value:
        :rtype: dict
        =z&Unable to parse option value to dict: )r   r   r   r   )r   rY   r   resultlinerI   r   vals           r2   _parse_dictzConfigHandler._parse_dictD  sr     	OOE* 	.D NN95MCci!$J5'"RSS"%))+F399;		. r4   c                 *    |j                         }|dv S )zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )1trueyes)lowerr   rY   s     r2   _parse_boolzConfigHandler._parse_boolU  s     ,,,r4   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)rp   
ValueErrorformat)rY   exclude_directiverI   s     r2   parserz3ConfigHandler._exclude_files_parser.<locals>.parserk  s:     ' 12 --3VC[  Lr4   r   )r   rI   r   s    ` r2   _exclude_files_parserz#ConfigHandler._exclude_files_parser_  s    	 r4   root_dirc                 0   d}t        |t              s|S |j                  |      s|S |t        |      d }|j	                  d      D cg c]  }|j                          }}| j                  j                  |       t        j                  ||      S c c}w )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   N,)
r   r#   rp   rt   r   r   rc   rd   r   
read_files)r   rY   r   include_directivespecr=   	filepathss          r2   _parse_filezConfigHandler._parse_filev  s     $%%L 12LS*+-..2jjo>dTZZ\>	>%%i0  H55 ?s   	B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: )rp   replacerd   re   r`   r   	read_attr)r   rY   r`   r   attr_directive	attr_descs         r2   _parse_attrzConfigHandler._parse_attr  s]     !/LMM."5	 	411==>	;AAr4   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   r   )rY   rj   methodparse_methodss      r2   r_   z1ConfigHandler._get_parser_compound.<locals>.parse  s'    F' (( Mr4   r   )r   r   r_   s    ` r2   _get_parser_compoundz"ConfigHandler._get_parser_compound  s    	 r4   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   section_optionsvalues_parserrY   rI   _r   s          r2   _parse_section_to_dict_with_keyz-ConfigHandler._parse_section_to_dict_with_key  s>     ,224 	1MC!S&sC0E#J	1r4   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   r   )r   vr   s     r2   r   z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>  s    }Q/ r4   c                     |S r   r   )r   r   s     r2   r   z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>  s    UV r4   r   )r   r   r   r   s     ` r2   _parse_section_to_dictz$ConfigHandler._parse_section_to_dict  s#     5B/22?FKKr4   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   
contextlibsuppressr   )r   r   rw   r   rY   s        r2   parse_sectionzConfigHandler.parse_section  sV    
 !0 5 5 7 	#D*1e$$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.

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

        :param msg: deprecation message
        :param func: function to be wrapped around
        c                  f    j                  dd       t        j                  dfi   | i |S )N
stacklevelr   z Deprecated config in `setup.cfg`)
setdefault_DeprecatedConfigry   )argskwargsfunckwr~   s     r2   config_handlerz@ConfigHandler._deprecated_config_handler.<locals>.config_handler  s7    MM,*""#EsQbQ(((r4   r   )r   r   r~   r   r   s    ``` r2   _deprecated_config_handlerz(ConfigHandler._deprecated_config_handler  s#     
t	) 
	)
 r4   )r   r   )r'   N)r   
__module____qualname____doc__r#   __annotations__r   r
   r$   AllCommandOptionsr   r^   r   classmethodr   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r_   r   r   r4   r2   r9   r9      s>   ;
 !GT#s(^  #
 "::" *'8 * * 
 
-4 C C&    - -  ,67 64B B(  &   
L 
L#32r4   r9   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 )r[   ra   urldescriptionclassifiers	platforms)	home_pagesummary
classifierplatformFNrH   r    rf   r.   re   r`   r   c                 F    t         |   ||||       || _        || _        y r   )superr   r`   r   )r   rH   rf   r.   re   r`   r   r   s          r2   r   zConfigMetadataHandler.__init__  s)     	W.BDUV& r4   c                     | j                   }t        | j                  | j                        }| j                  }| j
                  }||||| j                  ||       |d      |||| j                  |dS )r   r   license)r  keywordsprovides	obsoletesr  r  license_filesr  long_descriptionversionproject_urls)r   r   r   r   r   r   r   _parse_version)r   
parse_list
parse_file
parse_dictexclude_files_parsers        r2   r   zConfigMetadataHandler.parsers$  s     %%
T--F
%%
#99 $""#44ZL+I6'% ***&
 	
r4   c                 :   | j                  || j                        }||k7  r|j                         }	 t        |       |S t        j                  | j                  || j                  | j                              S # t        $ r}t        d| d|       |d}~ww xY w)zSParses `version` option value.

        :param value:
        :rtype: str

        zVersion loaded from z does not comply with PEP 440: N)
r   r   r   r   r   r   r   r  r   r`   )r   rY   r  r   s       r2   r  z$ConfigMetadataHandler._parse_version:  s     ""5$--8emmoG  N~~d..ud6F6FVWW " !*5' 2,,396 s   A: :	BBB)r   r   r   rU   r   strict_moder<   curdirr   boolr   r^   r   rS   r   r   r  r   r  __classcell__r   s   @r2   r[   r[     s    N  #	G K '+II!*! #! #	!
 "::! d^! ! 
 
*Xr4   r[   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 )r\   rf   rH   r"   r.   re   c                 Z    t         |   ||||       |j                  | _        i | _        y r   )r  r   rb   r   r`   )r   rH   rf   r.   re   r   s        r2   r   zConfigOptionsHandler.__init__W  s/     	W.BDUV"+++-r4   c                 (    | j                  |d      S )N;)r   )r   r   s     r2   _parse_list_semicolonz*ConfigOptionsHandler._parse_list_semicolonb  s    u44r4   c                 <    | j                  || j                        S )Nr  )r   r   )r   rY   s     r2   _parse_file_in_rootz(ConfigOptionsHandler._parse_file_in_rootf  s    >>r4   rh   rY   c                     | j                  | j                  |            }t        |||       |D cg c]  }|j                  d      r| c}S c c}w )N#)r&  r(  r   rp   )r   rh   rY   rj   r   s        r2   _parse_requirements_listz-ConfigOptionsHandler._parse_requirements_listi  sJ    ++D,D,DU,KL-eUFC "(Dts/CDDDs   A	Ac                 &   | j                   }| j                  }| j                  }| j                  }||||||| j	                  |d      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&  _parse_packagesr(  r   )r   r  
parse_boolr  parse_cmdclasss        r2   r   zConfigOptionsHandler.parsersq  s     %%
%%
%%
-- #$.%!) *"&"A"AH# !(--/A! #88!77,, 44$+&-
 	
r4   c                     | j                   j                  }t        j                  | j	                  |      || j
                        S r   )re   r`   r   r:  r   r   )r   rY   r`   s      r2   r;  z$ConfigOptionsHandler._parse_cmdclass  s5    ,,88t//6T]]SSr4   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_dirr   )
r   r   parse_section_packages__findr   r   rd   r   r`   r   find_packages)r   rY   find_directivestrimmed_valuefind_kwargss        r2   r<  z$ConfigOptionsHandler._parse_packages  s     #$56/##E** 77MMor2
 	%);;]]!-- 	 	
 ##2k22r4   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excluderI  r   )r   r   rS   r   r   )r   r   section_data
valid_keyskr   rG  rI  s           r2   rC  z1ConfigOptionsHandler.parse_section_packages__find  s     22?DDTDTU4
+113
q!qJ1QF
  (#(8K 
s   A4
A4
	A4
c                 F    | j                  || j                        }|| d<   y)z`Parses `entry_points` configuration file section.

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

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

        :param dict section_options:
        exclude_package_dataNrW  rX  s     r2   "parse_section_exclude_package_dataz7ConfigOptionsHandler.parse_section_exclude_package_data  s    
 (,'?'?'P#$r4   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+  )rN  r   r   s     r2   r   zCConfigOptionsHandler.parse_section_extras_require.<locals>.<lambda>  s    6617MqQ r4   extras_requireNr   rP  s   `  r2   parse_section_extras_requirez1ConfigOptionsHandler.parse_section_extras_require  s(    
 55Q

 "(r4   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   rP  s      r2   parse_section_data_filesz-ConfigOptionsHandler.parse_section_data_files  s7    
 ,,_d>N>NO#66vt}}M\r4   )r   r   r   rU   r   r  r   r^   r   r   r&  r(  r#   r+  r  r   r;  r<  rC  rQ  rU  rY  r\  r`  rd  r   r!  s   @r2   r\   r\   T  s    N	."	. #	. #		.
 "::	. 5 5?Ec E# E 
 
@T32*&9IQ
(Nr4   r\   c                   (    e Zd ZdZdZdZed        Zy)rx   zAmbiguous requirement marker.z
    One of the parsed requirements in `{field}` looks like a valid environment marker:

        {req!r}

    Please make sure that the configuration file is correct.
    You can use dangling lines to avoid this problem.
    z'userguide/declarative_config.html#opt-2c                 r    d| j                    }| j                  | j                  | j                  ||      S )Nz%https://setuptools.pypa.io/en/latest/)see_urlformat_args)	_SEE_DOCS_format_SUMMARY_DETAILS)r   r   docss      r2   r{   z_AmbiguousMarker.message  s2    6s}}oF{{3<<tQS{TTr4   N)r   r   r   rk  rl  ri  r   r{   r   r4   r2   rx   rx     s+    .HH :I U Ur4   rx   c                       e Zd ZdZy)r   z!userguide/declarative_config.htmlN)r   r   r   ri  r   r4   r2   r   r     s    3Ir4   r   )FF)r   F)F)@r   r   rL   r<   collectionsr   r   r   typingr   r   r	   r
   r   r   r   r   r   r   r   r   _pathr   errorsr   r   extern.packaging.markersr   ru   extern.packaging.requirementsr   r   extern.packaging.specifiersr   extern.packaging.versionr   r   warningsr   r   r   distutils.distr    r)   r"   SingleCommandOptionsr   r$   rS   r3   r7   r  r+   r#   rQ   r,   rD   r   r   r9   r[   r\   rx   r   r   r4   r2   <module>rz     s  	   	 #       + H K 6 > 3 3,E5#445 
  445 	'M!N	O @E++	+4n  N  &(!&	
 '" 	
  <	F 	 	E*>$? D * + +&+ :;	+\2 2# 2t 2@^GFO ^B	JXM*@A JXZ\N=8 \N~U3 U(44 4r4   