bgdtUdZddlmZddlZddlZddlZddlmZddlm Z m Z ddlm Z m Z ddl mZmZmZmZmZmZmZddlmZdd lmZmZdd lmZdd lmZmZd d l m!Z!d dl"m#Z#m$Z$d dl%m&Z&ddl'm(Z(erddl)m*Z*ddl+m,Z,ddl-m.Z.e/e0e1e0effZ2de3d< e/e0e2fZ4de3d< edddZ5 dEdFd#Z6dGd%Z7 dHdId*Z8dJd/Z9dKd2Z: dLdMd5Z;dNd:Z<Gd;de=dZ>Gd?d@e=dZ?GdAdBe&Z@GdCdDe&ZAdS)Oa< 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) SpecifierSet)InvalidVersionVersion)StrPath) FileError OptionError)SetuptoolsDeprecationWarning)expand) TypeAlias Distribution)DistributionMetadatarSingleCommandOptionsAllCommandOptionsTargetrr 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.distrfind_config_files_applyconfiguration_to_dict)r$r%r'rdist filenameshandlerss Q/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/config/setupcfg.pyread_configurationr32s^$-,,,,, <>>D,7?&&(((RIdHi1EFFH  * **r/cNt||||S)z`Apply the configuration from a ``setup.cfg`` file into an existing distribution object. )r-_finalize_requires)r/r$s r2apply_configurationr7Ls+ 4 Kr4 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.)r0)r')r+r=ospathabspathisfilergetcwdchdirdirnameparse_config_filesrliststrparse_configurationcommand_options_finalize_license_files)r/r$r9r'r=current_directoryr0r1s r2r-r-Us".-----wx((H 7>>( # #JHhHHHIII HRW__X & &'''(+(x(I$((d3i9S9S(TTT& $&=Q    $$&&& "####"#### Os #A DD. target_obj#Distribution | DistributionMetadatakeyrGcxd|}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)rLrN getter_name by_attributegetters r2 _get_optionrVts? ,,K$Wj#>>L Zl ; ;F 688Or4r1KIterable[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_optionsrVrLsection_prefix)r1 config_dicthandleroptionvalues r2r.r.sk$D))K@@) @ @F 2F;;E:?K. / 7 7 @ r4 distributionrIc 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_rIr'ensure_discoveredoptionsmetas r2rHrHs$  ( 6 6 :K&        ' ;'.':L $$  !    $  !    &--  %t'=   +               2 =sBB77B;>B;label orig_valueparsedrFcd|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).0markerros r2 z8_warn_accidental_env_marker_misconfig..s5BBvay##F++BBBBBBr4) len marker_envkeysrname_AmbiguousMarkeremitranymessage)rmrnromarkersrsexmsgs ` r2%_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"c2eZdZUdZded< iZded< d$dZed%dZe dZ d&dZ ed'dZ edZ edZedZd(dZd)dZedZedZed*d Zd&d!Zd&d"Zd#ZdS)+ ConfigHandlerz1Handles metadata supplied in configuration files.rGrZzClassVar[dict[str, str]]aliasesrLr#rkr"rjexpand.EnsurePackagesDiscoveredr(Nonec||_||_t|||_g|_||_t|_dSN) r'rLr)_section_optionssectionsrYrjsetrh)selfrLrkr'rjs r2__init__zConfigHandler.__init__sV%9!",T227;;<< &(!2+.55  r4*Iterator[tuple[str, SingleCommandOptions]]c#K|D]?\}}||j\}}}|r&|d|fV@dS)N.)items partitionrZlstrip)clsrk full_namer^pre_sepr}s r2rzConfigHandler._section_optionssu!(  * * Iu'11#2DEEOCt ++c""E) ) ) ) )  * *r4c:td|jjz).Metadata item name to parser function mapping.z!%s must provide .parsers property)NotImplementedError __class____name__)rs r2parserszConfigHandler.parserss#" /$.2I I   r4c|j}|j||} t||}n"#t$r}t ||d}~wwxYw|rdS |j|d|}n#tf|jz$rYdSwxYwtj |j |}t|d||}|||j |dS)Nc|Srr8)xs r2z+ConfigHandler.__setitem__..&sQr4set_)rLrgetrRAttributeErrorKeyErrorr Exceptionr'rQr __setattr__rYappend) r option_namer^rL current_valueero simple_settersetters r2 __setitem__zConfigHandler.__setitem__s'_ l&&{K@@  /#J <z-ConfigHandler._parse_list..Bs-BBB%EKKMMB BBBr4) isinstancerF splitlinessplit)rr^ separators r2 _parse_listzConfigHandler._parse_list0s\ eT " " L 5==$$&&EEKK **EBB5BBBBr4cd}i}||D]\}||\}}}||krtd||||<]|S)zPRepresents value as a dict. :param value: :rtype: dict =z&Unable to parse option value to dict: )rrrr)rr^rresultlinerNsepvals r2 _parse_dictzConfigHandler._parse_dictDs OOE** . .D NN955MCci!"R5"R"RSSS"%))++F399;;   r4c2|}|dvS)zQRepresents value as boolean. :param value: :rtype: bool )1trueyes)lowerrr^s r2 _parse_boolzConfigHandler._parse_boolUs ,,,r4cfd}|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\d}||rtdd|S)Nfile:z"Only strings are accepted for the z field, files are not accepted)rv ValueError)r^exclude_directiverNs r2parserz3ConfigHandler._exclude_files_parser..parserksO '  122  ----Lr4r8)rrNrs ` r2_exclude_files_parserz#ConfigHandler._exclude_files_parser_s#      r4root_dirStrPath | Nonec,d}t|ts|S||s|S|t|d}d|dD}|j|tj||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|]}|Sr8r)rwr?s r2rz-ConfigHandler._parse_file..s >>>dTZZ\\>>>r4r) rrGrvrzrrhrir read_files)rr^rinclude_directivespec filepathss r2 _parse_filezConfigHandler._parse_filevs$%%% L 122 LS*++--.>>djjoo>>>  %%i000 H555r4rcd}||s|S||d}||jjt j|||S)zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:)rvreplacerirjrdr read_attr)rr^rdrattr_directive attr_descs r2 _parse_attrzConfigHandler._parse_attrsh!// LMM."55  41=>>> ;AAAr4cfd}|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] }||}|Srr8)r^romethod parse_methodss r2rcz1ConfigHandler._get_parser_compound..parses+F' ( (Mr4r8)rrrcs ` r2_get_parser_compoundz"ConfigHandler._get_parser_compounds#      r4cbi}|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^rN_rs r2_parse_section_to_dict_with_keyz-ConfigHandler._parse_section_to_dict_with_keysH,2244 1 1MC!S&sC00E#JJ r4NcDrfdnd}|||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|Srr8)rvrs r2rz6ConfigHandler._parse_section_to_dict..s}}Q//r4c|Srr8)rrs r2rz6ConfigHandler._parse_section_to_dict..sUVr4r)rrrrs ` r2_parse_section_to_dictz$ConfigHandler._parse_section_to_dicts75BW/////22?FKKKr4c|D]>\}\}}tjt5|||<dddn #1swxYwY?dS)zQParses configuration file section. :param dict section_options: N)r contextlibsuppressr)rrr}rr^s r2 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: [])rrrRrrrZ)r section_namermethod_postfixsection_parser_methods r2rczConfigHandler.parses .2]-@-@-B-B 3 3 )L/N 4!3\!3!35<00088dCC 66 !%,!>+>>.:>>> " !/ 2 2 2 2% 3 3r4c 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 r2config_handlerz@ConfigHandler._deprecated_config_handler..config_handlersH MM, * * *  "#Es Q Qb Q Q Q4((( (r4)r)rrrrrs ``` r2_deprecated_config_handlerz(ConfigHandler._deprecated_config_handlersB t ) ) ) ) ) )  ) r4)rLr#rkr"rjrr(r)rkr"r(rr(r)r)rr)rrr)r __module__ __qualname____doc____annotations__rr classmethodrpropertyrrrrrrrrrrrrrcrr8r4r2rrs;; )+G****     "***[*  X ----4CCC[C&[ --[-[,66664BBBB([&  [  L L L[ L####33332     r4rcdeZdZdZdddddZdZ dejfdfd Ze dZ dZ xZ S)rerfurl description classifiers platforms) home_pagesummary classifierplatformFNrLr rkr"r'r&rjrrd dict | Nonerrr(rclt||||||_||_dSr)superrrdr)rrLrkr'rjrdrrs r2rzConfigMetadataHandler.__init__s8 W.BDUVVV&  r4c |j}t|j|j}|j}|j}||||||||d||||j|d S)rrlicense) rkeywordsprovides obsoletesrr license_filesrlong_descriptionversion project_urls)rrrrrrr_parse_version)r parse_list parse_file parse_dictexclude_files_parsers r2rzConfigMetadataHandler.parsers$s% T- FFF % #9$""#44ZLL++I66'% **&   r4cH|||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$rrd)rr^r$rs r2r&z$ConfigMetadataHandler._parse_version:s""5$-88 e  mmooG     !   !6566,366  N~d..ud6F VVWWWsA A,A''A,)rLr rkr"r'r&rjrrdrrrr(r) rr r rZr strict_moder>curdirrrrr& __classcell__rs@r2reresN # GK$(#%9 ! ! ! ! ! ! !  X *XXXXXXXr4receZdZdZdfd Zed Zd ZddZe dZ dZ dZ dZ ddZdZddZddZddZddZxZS)rbrkrLrr"r'r&rjrr(rcvt|||||j|_i|_dSr)rrrgrrd)rrLrkr'rjrs r2rzConfigOptionsHandler.__init__Ws= W.BDUVVV"+ +-r4c0||dS)N;)r)rrs r2_parse_list_semicolonz*ConfigOptionsHandler._parse_list_semicolonbsu444r4c:|||jS)Nr)rr)rr^s r2_parse_file_in_rootz(ConfigOptionsHandler._parse_file_in_rootfs >>>r4rmrGr^c|||}t|||d|DS)Nc<g|]}|d|S)#ru)rwrs r2rzAConfigOptionsHandler._parse_requirements_list..os)DDDts/C/CDDDDr4)r4r6r)rrmr^ros r2_parse_requirements_listz-ConfigOptionsHandler._parse_requirements_listisL++D,D,DU,K,KLL-eUFCCCEDDDDDr4c|j}|j}|j}|j}||||||||dt |jd|j|j|j |t|dS)rzeThe namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).install_requires)zip_safeinclude_package_datardscriptseager_resourcesdependency_linksnamespace_packagesr<setup_requirespackages entry_points py_modulespython_requirescmdclass) rrr_parse_cmdclassrrr:r4_parse_packagesr6r)rr' parse_boolr)parse_cmdclasss r2rzConfigOptionsHandler.parsersqs% % % -#$.%!) *"&"A"AH## !(-/A!!#8, 4$+&+   r4cv|jj}tj||||jSr)rjrdrrHrr)rr^rds r2rIz$ConfigOptionsHandler._parse_cmdclasss1,8 t//66 T]SSSr4c: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_dirr8) rrparse_section_packages__findrrrirrdr find_packages)rr^find_directives trimmed_value find_kwargss r2rJz$ConfigOptionsHandler._parse_packagess #$56  / /##E** *77 M  or 2 2   %);;]!-    #22k222r4c|||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 | ||Sr8r8)rwkr valid_keyss r2 zEConfigOptionsHandler.parse_section_packages__find..s)VVV1ZTUq!r4rWNr)rrrr)rr section_datarUrWr\s @r2rQz1ConfigOptionsHandler.parse_section_packages__findsx22?DDTUU 444 VVVV (:(:(<(<VVV ((  #(8K r4cF|||j}||d<dS)z`Parses `entry_points` configuration file section. :param dict section_options: rEN)rrrrros r2parse_section_entry_pointsz/ConfigOptionsHandler.parse_section_entry_pointss, ,,_d>NOO%^r4c`|||j}tj|Sr)rrrcanonic_package_data)rr package_datas r2_parse_package_dataz(ConfigOptionsHandler._parse_package_datas+22?DDTUU *<888r4c6|||d<dS)z`Parses `package_data` configuration file section. :param dict section_options: rdNrerrs r2parse_section_package_dataz/ConfigOptionsHandler.parse_section_package_datas" $77HH^r4c6|||d<dS)zhParses `exclude_package_data` configuration file section. :param dict section_options: exclude_package_dataNrgrhs r2"parse_section_exclude_package_dataz7ConfigOptionsHandler.parse_section_exclude_package_datas# (,'?'?'P'P #$$$r4cD|fd}|d<dS)zbParses `extras_require` configuration file section. :param dict section_options: c8d|d|S)Nzextras_require[r)r:)r[rrs r2rzCConfigOptionsHandler.parse_section_extras_require..s#667M7M7M7MqQQr4extras_requireNrr`s` r2parse_section_extras_requirez1ConfigOptionsHandler.parse_section_extras_requires< 55  Q Q Q Q   "( r4cv|||j}tj||j|d<dS)z^Parses `data_files` configuration file section. :param dict section_options: data_filesN)rrrcanonic_data_filesrr`s r2parse_section_data_filesz-ConfigOptionsHandler.parse_section_data_filess; ,,_d>NOO#6vt}MM\r4) rLrrkr"r'r&rjrr(r)rmrGr^rGr )rr r rZrrr4r6r:rrrIrJrQrarerirlrprtr.r/s@r2rbrbTsRN . . . . . .55[5???EEEE  X >TTT3332$&&&&999IIIIQQQQ ( ( ( (NNNNNNNNr4rbc0eZdZdZdZdZedZdS)r~zAmbiguous 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 r2rz_AmbiguousMarker.messages0Fs}FF{{3<tQS{TTTr4N)rr r r{r|ryrrr8r4r2r~r~sG.HH:IUU[UUUr4r~ceZdZdZdS)rz!userguide/declarative_config.htmlN)rr r ryr8r4r2rrs3IIIr4r)FF)r$rr%r&r'r&r(r))r/rr$rr(r)r8F) r/rr$rr9r:r'r&r(r;)rLrMrNrG)r1rWr(r))F)r_rrIr"r'r&r(r;)rmrGrnrGrorF)Br  __future__rrrQr> collectionsrcollections.abcrrrrtypingr r r r r rrpackaging.markersrr{packaging.requirementsrrpackaging.specifiersrpackaging.versionrr_pathrerrorsrrwarningsrrrtyping_extensionsrr+rdistutils.distr r)rGtupler!r r"r#r3r7r-rVr.rHrrrerbr~rr8r4r2rs   #""""" ######........$$$$$$$$QQQQQQQQQQQQQQQQQQ??????BBBBBBBB------55555555++++++++3333334++++++,,,,,,333333"&sE#s(O';"<<<<< $C)=$=>>>>> >+A B BPU+++++4&(!& >    2"'+++++\2222@`````GFO```F JXJXJXJXJXM*@AJXJXJXZXNXNXNXNXN=8XNXNXNvUUUUU3UUU(44444444444r4