1jGhUdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddlm Z mZddlmZmZmZmZmZmZmZdd lmZdd lmZmZdd lmZmZd d l m!Z!d dl"m#Z#d dl$m%Z%m&Z&d dl'm(Z(ddl m)Z)erddl*m+Z+ddl,m-Z-ddl.m/Z/e0e1e2e1effZ3de4d< e0e1e3fZ5de4d< edddZ6 dFdGd$Z7dHd&Z8 dIdJd+Z9dKd0Z:dLd3Z; dMdNd6ZGd>d?e>dZ?Gd@dAe>dZ@GdBdCe(ZAGdDdEe(ZBdS)Pa< 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)abstractmethod) defaultdict)IterableIterator)partialwraps) TYPE_CHECKINGAnyCallableClassVarGenericTypeVarcast)default_environment)InvalidRequirement Requirement)InvalidVersionVersion)_static)StrPath) FileError OptionError)SetuptoolsDeprecationWarning)expand) TypeAlias Distribution)DistributionMetadatarSingleCommandOptionsAllCommandOptionsTargetr r!Ffilepathr find_othersboolignore_option_errorsreturndictcddlm}|}|r|ng}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.distr find_config_files_applyconfiguration_to_dict)r%r&r(r dist filenameshandlerss Q/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/config/setupcfg.pyread_configurationr43s^$-,,,,, <>>D,7?&&(((RIdHi1EFFH  * **r0cNt||||S)z`Apply the configuration from a ``setup.cfg`` file into an existing distribution object. )r._finalize_requires)r0r%s r3apply_configurationr8Ms+ 4 Kr5 other_filesIterable[StrPath]2tuple[ConfigMetadataHandler, ConfigOptionsHandler]cfddlm}tj|}tj|st d|dtj}tjtj |g||} | |ttt|t||j|}|tj|n#tj|wxYw|S)zHRead configuration from ``filepath`` and applies to the ``dist`` object.r) _DistributionzConfiguration file z does not exist.)r1)r()r,r>ospathabspathisfilergetcwdchdirdirnameparse_config_filesrliststrparse_configurationcommand_options_finalize_license_files)r0r%r:r(r>current_directoryr1r2s r3r.r.Vs".-----wx((H 7>>( # #JHhHHHIII HRW__X & &'''(+(x(I$((d3i9S9S(TTT& $&=Q    $$&&& "####"#### Os #A DD. target_obj#Distribution | DistributionMetadatakeyrHcxd|}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)rMrO getter_name by_attributegetters r3 _get_optionrWus? ,,K$Wj#>>L Zl ; ;F 688Or5r2KIterable[ConfigHandler[Distribution] | ConfigHandler[DistributionMetadata]]ctt}|D]1}|jD]'}t|j|}|||j|<(2|S)zReturns configuration data gathered by given handlers as a dict. :param Iterable[ConfigHandler] handlers: Handlers list, usually from parse_configuration() :rtype: dict )rr* set_optionsrWrMsection_prefix)r2 config_dicthandleroptionvalues r3r/r/sk$D))K@@) @ @F 2F;;E:?K. / 7 7 @ r5 distributionrJc tj|5}t||||}||js |j|_t |j||||j|j}||j |j|jdddn #1swxYwY||fS)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)r`rJr(ensure_discoveredoptionsmetas r3rIrIs$  ( 6 6 :K&        ' ;'.':L $$  !    $  !    &--  %t'=   +               2 =sBB77B;>B;label orig_valueparsedrGcd|vstdkrdSt} td}|j|vr$t |ddSdS#t$rX}tfd|Dr2t |d}t||Yd}~dSd}~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)fieldreqc3NK|]}d|V dS)rN startswith).0markerrps r3 z8_warn_accidental_env_marker_misconfig..s5BBvay##F++BBBBBBr5) len marker_envkeysrname_AmbiguousMarkeremitranymessage)rnrorpmarkersrtexmsgs ` r3%_warn_accidental_env_marker_misconfigrs" zS[[A--ll!!G2&)$$ 8w    ! !6!9 ! = = = = =   222 BBBB'BBB B B 2"**F1I*FFC$S))r 1 2 2 2 2 2 22sAB C" A CC"cDeZdZUdZded< iZded< d%dZed&dZe e d'dZ d(dZ ed)dZ edZedZedZd*dZd+dZedZedZed,d!Zd(d"Zd(d#Zd$Zd S)- ConfigHandlerz1Handles metadata supplied in configuration files.rHr[zClassVar[dict[str, str]]aliasesrMr$rlr#rkexpand.EnsurePackagesDiscoveredr)Nonec||_||_t|||_g|_||_tt|_ dSN) r(rMr*_section_optionssectionsrZrksetrHri)selfrMrlr(rks r3__init__zConfigHandler.__init__sZ%9!",T227;;<< &(!2!$S  r5*Iterator[tuple[str, SingleCommandOptions]]c#K|D]?\}}||j\}}}|r&|d|fV@dS)N.)items partitionr[lstrip)clsrl full_namer_pre_sepr~s r3rzConfigHandler._section_optionssu!(  * * Iu'11#2DEEOCt ++c""E) ) ) ) )  * *r5dict[str, Callable]c:t|jjd).Metadata item name to parser function mapping.z must provide .parsers property)NotImplementedError __class____name__)rs r3parserszConfigHandler.parserss'"~& G G G   r5c|j}|j||} t||}n"#t$r}t ||d}~wwxYw|rdS |j|d|}n#tf|jz$rYdSwxYwtj |j |}t|d||}|||j |dS)Nc|Srr9)xs r3z+ConfigHandler.__setitem__..(sQr5set_)rMrgetrSAttributeErrorKeyErrorr Exceptionr(rRr __setattr__rZappend) r option_namer_rM current_valueerp simple_settersetters r3 __setitem__zConfigHandler.__setitem__s'_ l&&{K@@  /#J <z-ConfigHandler._parse_list..Ds-BBB%EKKMMB BBBr5) isinstancerG splitlinessplit)rr_ separators r3 _parse_listzConfigHandler._parse_list2s\ eT " " L 5==$$&&EEKK **EBB5BBBBr5cd}i}||D]\}||\}}}||krtd||||<]|S)zPRepresents value as a dict. :param value: :rtype: dict =z&Unable to parse option value to dict: )rrrr)rr_rresultlinerOsepvals r3 _parse_dictzConfigHandler._parse_dictFs OOE** . .D NN955MCci!"R5"R"RSSS"%))++F399;;   r5c2|}|dvS)zQRepresents value as boolean. :param value: :rtype: bool )1trueyes)lowerrr_s r3 _parse_boolzConfigHandler._parse_boolWs ,,,r5cfd}|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 cd}||rtddtj|S)Nfile:z"Only strings are accepted for the z field, files are not accepted)rw ValueErrorrStr)r_exclude_directiverOs r3parserz3ConfigHandler._exclude_files_parser..parsermsZ '  122  ----;u%% %r5r9)rrOrs ` r3_exclude_files_parserz#ConfigHandler._exclude_files_parseras# & & & & & r5root_dirStrPath | Nonectd}t|ts|S||stj|S|t |d}d|dD}|j|tjtj ||S)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 rNc6g|]}|Sr9r)rxr@s r3rz-ConfigHandler._parse_file..s >>>dTZZ\\>>>r5r) rrHrwrrr{rrirjr read_files)rr_rinclude_directivespec filepathss r3 _parse_filezConfigHandler._parse_filexs$%%% L 122 &;u%% %S*++--.>>djjoo>>>  %%i000{6,YAABBBr5rcd}||stj|S||d}||jjtj|||S)zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:) rwrrreplacerjrkrer read_attr)rr_rerattr_directive attr_descs r3 _parse_attrzConfigHandler._parse_attrss!// &;u%% %MM."55  41=>>> ;AAAr5cfd}|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] }||}|Srr9)r_rpmethod parse_methodss r3rdz1ConfigHandler._get_parser_compound..parses+F' ( (Mr5r9)rrrds ` r3_get_parser_compoundz"ConfigHandler._get_parser_compounds#      r5cbi}|D]\}\}}|||||<|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_parserr_rO_rs r3_parse_section_to_dict_with_keyz-ConfigHandler._parse_section_to_dict_with_keysH,2244 1 1MC!S&sC00E#JJ r5NcDrfdnd}|||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|Srr9)rvrs r3rz6ConfigHandler._parse_section_to_dict..s}}Q//r5c|Srr9)rrs r3rz6ConfigHandler._parse_section_to_dict..sUVr5)r)rrrrs ` r3_parse_section_to_dictz$ConfigHandler._parse_section_to_dicts75BW/////22?FKKKr5c|D]>\}\}}tjt5|||<dddn #1swxYwY?dS)zQParses configuration file section. :param dict section_options: N)r contextlibsuppressr)rrr~rr_s r3 parse_sectionzConfigHandler.parse_sections !0 5 5 7 7 # # D*1e$X.. # #"T  # # # # # # # # # # # # # # # # #sAA A c|jD]^\}}d}|rd|}t|d|ddd}|t d|jd|d||_dS) zTParses configuration file items from one or more related sections. rrrr__Nz*Unsupported distribution option section: [])rrrSrrr[)r section_namermethod_postfixsection_parser_methods r3rdzConfigHandler.parses .2]-@-@-B-B 3 3 )L/N 4!3\!3!35<00088dCC 66 !%,!>+>>.:>>> " !/ 2 2 2 2% 3 3r5c Dtfd}|S)zthis function will wrap around parameters that are deprecated :param msg: deprecation message :param func: function to be wrapped around cfddtjdfi|i|S)N stacklevelrz Deprecated config in `setup.cfg`) setdefault_DeprecatedConfigr)argskwargsfunckwrs r3config_handlerz@ConfigHandler._deprecated_config_handler..config_handlersH MM, * * *  "#Es Q Qb Q Q Q4((( (r5)r )rrrrr s ``` r3_deprecated_config_handlerz(ConfigHandler._deprecated_config_handlersB t ) ) ) ) ) )  ) r5)rMr$rlr#rkrr)r)rlr#r)rr)rr)r)r)rr)rrr)r __module__ __qualname____doc____annotations__rr classmethodrpropertyrrrrrrrrrrrrrrdr r9r5r3rrs;; )+G****     "***[*   ^X ----4CCC[C&[ --[-[,CCCC6BBBB([&  [  L L L[ L####33332     r5rcfeZdZdZdddddZdZ dejfdfd Ze ddZ dZ xZ S)rfrgurl description classifiers platforms) home_pagesummary classifierplatformFNrMr!rlr#r(r'rkrre dict | Nonerrr)rclt||||||_||_dSr)superrrer)rrMrlr(rkrerrs r3rzConfigMetadataHandler.__init__s8 W.BDUVVV&  r5rc||jtj}||jtj}t |j|j}|j }idtj dtj dtj dtj d|d|d|d |d |||d |d d |d |d|dtj d|j dtj d|S)rrauthor author_email maintainermaintainer_emailrkeywordsprovides obsoletesrlicense license_filesrlong_descriptionlong_description_content_typeversionr project_urls) rrrListrDictrrrrr_parse_version)rparse_list_staticparse_dict_static parse_fileexclude_files_parsers r3rzConfigMetadataHandler.parsers's^!55d6F UU 55d6F UUT- FFF #9 gk GK  '+    *  )   )  *  444ZARSS  ++I66  .  :     ,W[  t* 7;! " -#  r5cH|||j}||krO|} t|n(#t$r}t d|d||d}~wwxYw|St j|||j |jS)zSParses `version` option value. :param value: :rtype: str zVersion loaded from z does not comply with PEP 440: N) rrrrrrrr,rre)rr_r,rs r3r0z$ConfigMetadataHandler._parse_versionCs""5$-88 e  mmooG     !   !6566,366  N~d..ud6F VVWWWsA A,A''A,)rMr!rlr#r(r'rkrrerrrr)rr ) rr rr[r strict_moder?curdirrrrr0 __classcell__rs@r3rfrf sN # GK$(#%9 ! ! ! ! ! ! !   X 6XXXXXXXr5rfceZdZdZdfd Zed Zd ZddZe ddZ dZ dZ dZ d dZdZd dZd dZd dZd dZxZS)!rcrlrMr r#r(r'rkrr)rcvt|||||j|_i|_dSr)rrrhrre)rrMrlr(rkrs r3rzConfigOptionsHandler.__init__`s= W.BDUVVV"+ +-r5c0||dS)N;)r)rrs r3_parse_list_semicolonz*ConfigOptionsHandler._parse_list_semicolonksu444r5c:|||jS)Nr )rr)rr_s r3_parse_file_in_rootz(ConfigOptionsHandler._parse_file_in_rootos >>>r5rnrHr_c|||}t|||tjd|DS)Nc3DK|]}|d|VdS)#Nrv)rxrs r3rzz@ConfigOptionsHandler._parse_requirements_list..xs3PPT4??3;O;OPDPPPPPPr5)r>r@rrr.)rrnr_rps r3_parse_requirements_listz-ConfigOptionsHandler._parse_requirements_listrsV++D,D,DU,K,KLL-eUFCCC|PPVPPPPPPr5rc|j}|j}|j}|||j|||||dt |jd|j|j|j |tj |dS)rzeThe namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).install_requires)zip_safeinclude_package_datarescriptseager_resourcesdependency_linksnamespace_packagesrFsetup_requirespackages entry_points py_modulespython_requirescmdclass) rr_parse_cmdclassrr rrDr>_parse_packagesr@r SpecifierSet)r parse_list parse_boolparse_cmdclasss r3rzConfigOptionsHandler.parsers{s% % -#$.+!) *"&"A"AH## !(-/A!!#8, 4$&3&+   r5cv|jj}tj||||jSr)rkrerrRrr)rr_res r3rSz$ConfigOptionsHandler._parse_cmdclasss1,8 t//66 T]SSSr5c:ddg}|}||vr||S||jdi}|||dk|j|jtj di|S)zTParses `packages` option value. :param value: :rtype: list zfind:zfind_namespace:z packages.findr) namespacesrfill_package_dirr9) rrparse_section_packages__findrrrjrrer find_packages)rr_find_directives trimmed_value find_kwargss r3rTz$ConfigOptionsHandler._parse_packagess #$56  / /##E** *77 M  or 2 2   %);;]!-    #22k222r5c|||j}gdfd|D}|d}| |d|d<|S)zParses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options: )whereincludeexcludec(i|]\}}|v | ||Sr9r9)rxkr valid_keyss r3 zEConfigOptionsHandler.parse_section_packages__find..s)VVV1ZTUq!r5rcNr)rrrr)rr section_datararcrhs @r3r]z1ConfigOptionsHandler.parse_section_packages__findsx22?DDTUU 444 VVVV (:(:(<(<VVV ((  #(8K r5cF|||j}||d<dS)z`Parses `entry_points` configuration file section. :param dict section_options: rON)rrrrrps r3parse_section_entry_pointsz/ConfigOptionsHandler.parse_section_entry_pointss, ,,_d>NOO%^r5c`|||j}tj|Sr)rrrcanonic_package_data)rr package_datas r3_parse_package_dataz(ConfigOptionsHandler._parse_package_datas+22?DDTUU *<888r5c6|||d<dS)z`Parses `package_data` configuration file section. :param dict section_options: rpNrqrrs r3parse_section_package_dataz/ConfigOptionsHandler.parse_section_package_datas" $77HH^r5c6|||d<dS)zhParses `exclude_package_data` configuration file section. :param dict section_options: exclude_package_dataNrsrts r3"parse_section_exclude_package_dataz7ConfigOptionsHandler.parse_section_exclude_package_datas# (,'?'?'P'P #$$$r5ch|fd}tj|d<dS)zbParses `extras_require` configuration file section. :param dict section_options: c8d|d|S)Nzextras_require[r)rD)rgrrs r3rzCConfigOptionsHandler.parse_section_extras_require..s#667M7M7M7MqQQr5extras_requireN)rrr/rls` r3parse_section_extras_requirez1ConfigOptionsHandler.parse_section_extras_requiresF 55  Q Q Q Q   ")f!5!5 r5cv|||j}tj||j|d<dS)z^Parses `data_files` configuration file section. :param dict section_options: data_filesN)rrrcanonic_data_filesrrls r3parse_section_data_filesz-ConfigOptionsHandler.parse_section_data_filess; ,,_d>NOO#6vt}MM\r5) rMr rlr#r(r'rkrr)r)rnrHr_rHr r )rr rr[rrr>r@rDrrrSrTr]rmrqrurxr|rr8r9s@r3rcrc]sWN . . . . . .55[5???QQQQ   X <TTT3332$&&&&999IIIIQQQQ 6 6 6 6NNNNNNNNr5rcc0eZdZdZdZdZedZdS)rzAmbiguous 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 \d|j}||j|j||S)Nz%https://setuptools.pypa.io/en/latest/)see_url format_args) _SEE_DOCS_format_SUMMARY_DETAILS)rrdocss r3rz_AmbiguousMarker.messages0Fs}FF{{3<tQS{TTTr5N)rr rrrrrrr9r5r3rrsG.HH:IUU[UUUr5rceZdZdZdS)rz!userguide/declarative_config.htmlN)rr rrr9r5r3rr s3IIIr5r)FF)r%rr&r'r(r'r)r*)r0r r%rr)r )r9F) r0r r%rr:r;r(r'r)r<)rMrNrOrH)r2rXr)r*)F)r`r rJr#r(r'r)r<)rnrHrorHrprG)Cr __future__rrrRr?abcr collectionsrcollections.abcrrrr typingr r r r rrrpackaging.markersrr|packaging.requirementsrrpackaging.versionrrrr_pathrerrorsrrwarningsrrtyping_extensionsrr,r distutils.distr!r*rHtupler"rr#r$r4r8r.rWr/rIrrrfrcrrr9r5r3rs   #""""" ######........$$$$$$$$QQQQQQQQQQQQQQQQQQ??????BBBBBBBB55555555++++++++3333334++++++,,,,,,333333"&sE#s(O';"<<<<< $C)=$=>>>>> >+A B BPU+++++4&(!& >    2"'+++++\2222@bbbbbGFObbbJ PXPXPXPXPXM*@APXPXPXfYNYNYNYNYN=8YNYNYNxUUUUU3UUU(44444444444r5