K ig`UdZddlmZddlZddlZddlZddlmZddlm Z m Z ddlm Z m Z ddl mZmZmZmZmZmZmZddlmZdd lmZmZdd lmZmZd d lmZd d l m!Z!d dl"m#Z#m$Z$d dl%m&Z&ddlm'Z'erddl(m)Z)ddl*m+Z+ddl,m-Z-e.e/e0e/effZ1de2d< e.e/e1fZ3de2d< edddZ4 d, d-dZ5d.dZ6 d/ d0dZ7d1dZ8 d2dZ9 d3 d4d Z:d5d!Z;Gd"d#ee4Z<Gd$d%eGd(d)e&Z?Gd*d+e&Z@y)6a< 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``. ) annotationsN) defaultdict)IterableIterator)partialwraps) TYPE_CHECKINGAnyCallableClassVarGenericTypeVarcast)default_environment)InvalidRequirement Requirement)InvalidVersionVersion)_static)StrPath) FileError OptionError)SetuptoolsDeprecationWarning)expand) TypeAlias Distribution)DistributionMetadatarSingleCommandOptionsAllCommandOptionsTargetrr cvddlm}|}|r|jng}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 rr)setuptools.distrfind_config_files_applyconfiguration_to_dict)filepath find_othersignore_option_errorsrdist filenameshandlerss `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/config/setupcfg.pyread_configurationr02s<$- >D,7&&(RIdHi1EFH  **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_configurationr4Ls 4 Kr1cDddlm}tjj |}tjj |st d|dtj}tjtjj|g||} |j|ttt|t||j|}|j!tj||S#tj|wxYw)zHRead configuration from ``filepath`` and applies to the ``dist`` object.r) _DistributionzConfiguration file z does not exist.)r-)r+)r%r6ospathabspathisfilergetcwdchdirdirnameparse_config_filesrliststrparse_configurationcommand_options_finalize_license_files)r,r) other_filesr+r6current_directoryr-r.s r/r'r'Us.wwx(H 77>>( #-hZ7GHII HHRWW__X &'(+(x(I$((d3i9S(T& $&&=Q  $$& "# O "#s !ADDcjd|}tjt||}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_) functoolsrgetattr) target_objkey getter_name by_attributegetters r/ _get_optionrOts8 ,K$$Wj#>L Zl ;F 8Or1ctt}|D];}|jD]*}t|j|}|||j |<,=|S)zReturns configuration data gathered by given handlers as a dict. :param Iterable[ConfigHandler] handlers: Handlers list, usually from parse_configuration() :rtype: dict )rdict set_optionsrOrJsection_prefix)r. config_dicthandleroptionvalues r/r(r(se$D)K@)) @F 2 2F;E:?K.. / 7 @@ r1c tj|5}t||||}|j|js|j|_t |j ||||j|j}|j|jj|j|jddd||fS#1swYfSxYw)aPerforms 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) rEnsurePackagesDiscoveredConfigOptionsHandlerparse package_dirConfigMetadataHandlermetadatasrc_root_referenced_filesupdate) distributionrBr+ensure_discoveredoptionsmetas r/rArAs$  ( ( 6 :K&       '''.':':L $$  ! !    $ $  ! !   &&--  % %t'='= + 2 =3 2 =s B*C  Ccld|vstdk7rytj} td}|j|vrt j |dyy#t$rD}tfd|Dr&t j|d}t||Yd}~yd}~wwxYw)amBecause 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 (";") leads in a valid Requirement with a valid marker a UserWarning is shown to inform the user about the possible problem.  rNr)fieldreqc3FK|]}dj|yw)rN startswith).0markerparseds r/ z8_warn_accidental_env_marker_misconfig..s Bvay##F+Bs!) len marker_envkeysrname_AmbiguousMarkeremitranymessage)label orig_valueromarkersriexmsgs ` r/%_warn_accidental_env_marker_misconfigr~s" zS[A-l!G2&)$ 88w   ! !6!9 ! =  2 B'B B"**F1I*FC$S)r 1 C2s6A&& B3/:B..B3ceZdZUdZded< iZded< ddZe ddZe dZ dd Z edd Z ed Z ed Zed ZddZddZedZedZeddZddZddZdZy) ConfigHandlerz1Handles metadata supplied in configuration files.r@rSzClassVar[dict[str, str]]aliasesc||_||_t|j||_g|_||_tt|_ yN) r+rJrQ_section_optionssectionsrRrcsetr@r`)selfrJrdr+rcs r/__init__zConfigHandler.__init__sM%9!",T227;< &(!2!$S r1c#K|jD]<\}}|j|j\}}}|r(|jd|f>yw)N.)items partitionrSlstrip)clsrd full_namerWpre_seprts r/rzConfigHandler._section_optionssX!(  * Iu'11#2D2DEOCt++c"E) )  *sAAcFt|jjd).Metadata item name to parser function mapping.z must provide .parsers property)NotImplementedError __class____name__)rs r/parserszConfigHandler.parserss'"~~&&''F G  r1c|j}|jj||} t||}|ry |j j|d|}tj|j|}t|d||}|||jj|y#t$r}t ||d}~wwxYw#tf|jz$rYywxYw)Nc|Sr)xs r/z+ConfigHandler.__setitem__..&sQr1set_)rJrgetrIAttributeErrorKeyErrorr Exceptionr+rHr __setattr__rRappend) r option_namerWrJ current_valueero simple_settersetters r/ __setitem__zConfigHandler.__setitem__s__ ll&&{K@  /#J .parserksG '  12 8>--;;u% %r1r)rrKrs ` r/_exclude_files_parserz#ConfigHandler._exclude_files_parser_s & r1c|d}t|ts|S|j|stj|S|t |d}|j dDcgc]}|j}}|jj|tjtj||Scc}w)aORepresents 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 rN,) rr@rlrrrqrrr`rar read_files)rrWroot_dirinclude_directivespecr8 filepathss r/ _parse_filezConfigHandler._parse_filevs$%%L 12;;u% %S*+-..2jjo>dTZZ\> > %%i0{{6,,YABB?sB9cd}|j|stj|S|j|d}|j |j j tj|||S)zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:) rlrrreplacerarcr\r read_attr)rrWr\rattr_directive attr_descs r/ _parse_attrzConfigHandler._parse_attrsg!/;;u% %MM."5  411==> ;AAr1cfd}|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] }||} |Srr)rWromethod parse_methodss r/r[z1ConfigHandler._get_parser_compound..parses'F' ( (Mr1r)rrr[s ` r/_get_parser_compoundz"ConfigHandler._get_parser_compounds  r1cXi}|jD]\}\}}|||||<|S)aParses 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)rsection_options values_parserrWrK_rs r/_parse_section_to_dict_with_keyz-ConfigHandler._parse_section_to_dict_with_keys>,224 1MC!S&sC0E#J 1 r1Nc<rfdnd}|j||S)aParses 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|Srr)rvrs r/rz6ConfigHandler._parse_section_to_dict..s }Q/r1c|Srr)rrs r/rz6ConfigHandler._parse_section_to_dict..sUVr1)r)rrrrs ` r/_parse_section_to_dictz$ConfigHandler._parse_section_to_dicts#5B/22?FKKr1c|jD]/\}\}}tjt5|||<ddd1y#1swY "/ 2% 3r1c 6tfd}|S)zthis function will wrap around parameters that are deprecated :param msg: deprecation message :param func: function to be wrapped around cfjddtjdfi|i|S)N stacklevelrz Deprecated config in `setup.cfg`) setdefault_DeprecatedConfigrv)argskwargsfunckwr}s r/config_handlerz@ConfigHandler._deprecated_config_handler..config_handlers7 MM, *  " "#Es Qb Q(( (r1)r)rrr}rrs ``` r/_deprecated_config_handlerz(ConfigHandler._deprecated_config_handlers# t )  ) r1)rJr#rdr"rcexpand.EnsurePackagesDiscoveredreturnNone)rdr"rz*Iterator[tuple[str, SingleCommandOptions]]rr)r)rStrPath | None)rrr)r __module__ __qualname____doc____annotations__rr classmethodrpropertyrrrrrrrrrrrrr[rrr1r/rrs5; )+G %*   # ;    "*'* 3**  -4CC& --,C6B(&   L L#32 r1rceZdZdZdddddZdZ dejf d fd Ze d Z d Z xZ S) r]r^url description classifiers platforms) home_pagesummary classifierplatformFNcFt|||||||_||_yr)superrr\r)rrJrdr+rcr\rrs r/rzConfigMetadataHandler.__init__s) W.BDUV&  r1cV|j|jtj}|j|jtj }t |j|j}|j}idtjdtjdtjdtjd|d|d|d |d |j||d |d d |d |d|dtjd|jdtjd|S)rrauthor author_email maintainermaintainer_emailr keywordsprovides obsoletesr license license_filesrlong_descriptionlong_description_content_typeversionr project_urls) rrrListrDictrrrrr_parse_version)rparse_list_staticparse_dict_static parse_fileexclude_files_parsers r/rzConfigMetadataHandler.parsers%sj!55d6F6F U 55d6F6F UT-- F #99 gkk GKK  '++    *  )   )  *  444ZARS  +I6  .  :     ,W[[  t** 7;;! " -#  r1c:|j||j}||k7r|j} t||St j|j||j|jS#t$r}t d|d||d}~wwxYw)zSParses `version` option value. :param value: :rtype: str zVersion loaded from z does not comply with PEP 440: N) rrrrrrrrrr\)rrWrrs r/r"z$ConfigMetadataHandler._parse_versionAs""5$--8 e mmoG  N~~d..ud6F6F VWW" !*5'2,,396 s A:: BBB)rJr rdr"r+boolrcrr\z dict | Nonerrrr) rrrrSr strict_moder7curdirrrrr" __classcell__rs@r/r]r]sN # GK$(#%99 !( !# !# ! ; ! ! !! !  !  6Xr1r]ceZdZdZ dfd ZedZdZddZe dZ dZ dZ d Z dd Zd Zdd Zdd ZddZddZxZS)rZrdcZt||||||j|_i|_yr)rrr_rr\)rrJrdr+rcrs r/rzConfigOptionsHandler.__init__^s/ W.BDUV"++ +-r1c(|j|dS)N;)r)rrs r/_parse_list_semicolonz*ConfigOptionsHandler._parse_list_semicolonisu44r1c<|j||jS)Nr)rr)rrWs r/_parse_file_in_rootz(ConfigOptionsHandler._parse_file_in_rootms >>r1c|j|j|}t|||tjd|DS)Nc3DK|]}|jdr|yw)#Nrk)rmrs r/rpz@ConfigOptionsHandler._parse_requirements_list..vsPT4??3;ODPs  )r1r3r~rr )rryrWros r/_parse_requirements_listz-ConfigOptionsHandler._parse_requirements_listps@++D,D,DU,KL-eUFC||PVPPPr1c |j}|j}|j}|||j||||j |dt |j d|j|j|j|tj|dS)rzeThe namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).install_requires)zip_safeinclude_package_datar\scriptseager_resourcesdependency_linksnamespace_packagesr9setup_requirespackages entry_points py_modulespython_requirescmdclass) rr_parse_cmdclassrrrr7r1_parse_packagesr3r SpecifierSet)r parse_list parse_boolparse_cmdclasss r/rzConfigOptionsHandler.parsersys%% %% --#$.++!) *"&"A"AH# !(--/A!#88,, 44$&33&+  r1c|jj}tj|j |||j Sr)rcr\rrErr)rrWr\s r/rFz$ConfigOptionsHandler._parse_cmdclasss5,,88 t//6 T]]SSr1c0ddg}|j}||vr|j|S|j|jj di}|j ||dk(|j |jtjdi|S)zTParses `packages` option value. :param value: :rtype: list zfind:zfind_namespace:z packages.findr) namespacesrfill_package_dirr) rrparse_section_packages__findrrrarr\r find_packages)rrWfind_directives trimmed_value find_kwargss r/rGz$ConfigOptionsHandler._parse_packagess #$56  /##E* *77 MM  or 2  %);;]]!--  ##2k22r1c|j||j}gd}|jDcic]\}}||vs |s||}}}|jd}||d|d<|Scc}}w)zParses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options: )whereincludeexcluderVr)rrrr)rr section_data valid_keyskrrTrVs r/rPz1ConfigOptionsHandler.parse_section_packages__finds|22?DDTDTU 4 (4(:(:(<V1ZTUq!tV V(  #(8K  Ws A)A)A)cF|j||j}||d<y)z`Parses `entry_points` configuration file section. :param dict section_options: rBN)rrrrros r/parse_section_entry_pointsz/ConfigOptionsHandler.parse_section_entry_pointss& ,,_d>N>NO%^r1cd|j||j}tj|Sr)rrrcanonic_package_data)rr package_datas r/_parse_package_dataz(ConfigOptionsHandler._parse_package_datas+22?DDTDTU **<88r1c,|j||d<y)z`Parses `package_data` configuration file section. :param dict section_options: raNrbrrs r/parse_section_package_dataz/ConfigOptionsHandler.parse_section_package_datas $77H^r1c,|j||d<y)zhParses `exclude_package_data` configuration file section. :param dict section_options: exclude_package_dataNrdres r/"parse_section_exclude_package_dataz7ConfigOptionsHandler.parse_section_exclude_package_datas (,'?'?'P #$r1c`j|fd}tj|d<y)zbParses `extras_require` configuration file section. :param dict section_options: c0jd|d|S)Nzextras_require[r)r7)r[rrs r/rzCConfigOptionsHandler.parse_section_extras_require..s6617MqQr1extras_requireN)rrr!r]s` r/parse_section_extras_requirez1ConfigOptionsHandler.parse_section_extras_requires1 55  Q  ")f!5 r1c|j||j}tj||j|d<y)z^Parses `data_files` configuration file section. :param dict section_options: data_filesN)rrrcanonic_data_filesrr]s r/parse_section_data_filesz-ConfigOptionsHandler.parse_section_data_filess7 ,,_d>N>NO#66vt}}M\r1) rJrrdr"r+r(rcrrr)ryr@rWr@r)rrrrSrrr1r3r7rrrFrGrPr^rbrfrirmrqr+r,s@r/rZrZ[sN .  .# .# . ; .  .55?Q  <T32$&9IQ 6Nr1rZc(eZdZdZdZdZedZy)ruzAmbiguous 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 rd|j}|j|j|j||S)Nz%https://setuptools.pypa.io/en/latest/)see_url format_args) _SEE_DOCS_format_SUMMARY_DETAILS)rrdocss r/rxz_AmbiguousMarker.messages26s}}oF{{3<<tQS{TTr1N)rrrrxryrvrrxrr1r/rurus+.HH:IUUr1ruceZdZdZy)rz!userguide/declarative_config.htmlN)rrrrvrr1r/rr s3Ir1r)FF)r)rr*r(r+r(rrQ)r,rr)rrr)rF) r,rr)rrDzIterable[StrPath]r+r(r2tuple[ConfigMetadataHandler, ConfigOptionsHandler])rJz#Distribution | DistributionMetadatarKr@)r.zKIterable[ConfigHandler[Distribution] | ConfigHandler[DistributionMetadata]]rrQ)F)rbrrBr"r+r(rr|)ryr@rzr@ror?)Ar __future__rrrHr7 collectionsrcollections.abcrrrrtypingr r r r r rrpackaging.markersrrrpackaging.requirementsrrpackaging.versionrrrr_pathrerrorsrrwarningsrrtyping_extensionsrr%rdistutils.distr rQr@tupler!rr"r#r0r4r'rOr(rAr~rr]rZrurrr1r/rs # #.$QQQ?B5+3+,3"&sE#s(O';"<i< $C)=$=>9> >+A BPU++$(+HL+ +4&(!&  #  8 >  2"'++&++8 +\2@aGFOaH PXM*@APXfYN=8YNxU3U(444r1