a (ReSZ@sddlZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddl m Z ddl Z ddlmZmZddlmZmZddlmZGd d d Ze jd d ZdddZddZddZdddZGdddZGdddeZGdddeZdS)N) defaultdict)partialwraps)iglob)DistutilsOptionErrorDistutilsFileError) LegacyVersionparse) SpecifierSetc@s eZdZdZddZddZdS) StaticModulez0 Attempt to load the module by the name cCs`tj|}t|j}|}Wdn1s40Yt|}t| t |` dSN) importlibutil find_specopenoriginreadastr varsupdatelocalsself)rnamespecstrmsrcmoduler/builddir/build/BUILDROOT/alt-python39-setuptools-58.3.0-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/setuptools/config.py__init__s   & zStaticModule.__init__c s^ztfdd|jjDWStyX}z$tdjfit|WYd}~n d}~00dS)Nc3sH|]@}t|tjr|jD](}t|tjr|jkrt|jVqqdSr ) isinstancerAssigntargetsNameid literal_evalvalue).0Z statementtargetattrrr #s   z+StaticModule.__getattr__..z#{self.name} has no attribute {attr})nextrbody ExceptionAttributeErrorformatr)rr+err*r __getattr__!s  zStaticModule.__getattr__N)__name__ __module__ __qualname____doc__r r3rrrrr sr c cs8z$tjd|dVWtj|ntj|0dS)zH Add path to front of sys.path for the duration of the context. rN)syspathinsertremove)r9rrr patch_path0sr<Fc Csddlm}m}tj|}tj|s4td|t}t tj |zT|}|rb| ng}||vrx| ||j ||dt||j|d}Wt |n t |0t|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) Distribution _Distributionz%Configuration file %s does not exist.) filenames)ignore_option_errors)Zsetuptools.distr=r>osr9abspathisfilergetcwdchdirdirnamefind_config_filesappendparse_config_filesparse_configurationcommand_optionsconfiguration_to_dict) filepathZ find_othersr@r=r>Zcurrent_directorydistr?handlersrrrread_configuration<s"    rPcCs2djfit}tt||}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})r1r functoolsrgetattr) target_objkeyZ getter_nameZ by_attributegetterrrr _get_optionis rVcCs<tt}|D]*}|jD]}t|j|}|||j|<qq |S)zReturns configuration data gathered by given handlers as a dict. :param list[ConfigHandler] handlers: Handlers list, usually from parse_configuration() :rtype: dict )rdict set_optionsrVrSsection_prefix)rOZ config_dicthandleroptionr'rrrrLus   rLcCs6t|||}|t|j|||j}|||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 )ConfigOptionsHandlerr ConfigMetadataHandlermetadata package_dir) distributionrKr@optionsmetarrrrJs rJc@seZdZdZdZiZd'ddZeddZdd Z e d(d d Z e d)d dZ e ddZ e ddZe ddZe ddZeddZeddZe d*ddZe ddZe d+dd Zd!d"Zd#d$Zd%d&ZdS), ConfigHandlerz1Handles metadata supplied in configuration files.NFcCs^i}|j}|D].\}}||s&q||dd}|||<q||_||_||_g|_dS)N.) rYitems startswithreplacestripr@rSsectionsrX)rrSrar@rjrY section_namesection_optionsrrrr s  zConfigHandler.__init__cCstd|jjdS).Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)NotImplementedError __class__r4)rrrrparserss zConfigHandler.parsersc Cst}|j}|j||}t|||}||ur6t||r>dSd}|j|}|r~z ||}Wnty|d}|jsxYn0|rdSt|d|d}|durt |||n|||j |dS)NFTzset_%s) tuplerSaliasesgetrRKeyErrorrpr/r@setattrrXrH) rZ option_namer'unknownrSZ current_valueZ skip_optionparsersetterrrr __setitem__s0    zConfigHandler.__setitem__,cCs8t|tr|Sd|vr |}n ||}dd|DS)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  cSsg|]}|r|qSr)ri)r(chunkrrr z-ConfigHandler._parse_list..)r!list splitlinessplit)clsr' separatorrrr _parse_lists   zConfigHandler._parse_listc sjd}|j|d}g}|D]Jtfdd|DrZ|tddttjDq|q|S)aEquivalent to _parse_list() but expands any glob patterns using glob(). However, unlike with glob() calls, the results remain relative paths. :param value: :param separator: List items separator character. :rtype: list )*?[]{}rc3s|]}|vVqdSr r)r(charr'rrr,r~z1ConfigHandler._parse_list_glob..css |]}tj|tVqdSr )rAr9relpathrDr(r9rrrr,s) ranyextendsortedrrAr9rBrH)rr'rZglob_charactersvaluesZexpanded_valuesrrr_parse_list_globs    zConfigHandler._parse_list_globcCsPd}i}||D]8}||\}}}||kr:td||||<q|S)zPRepresents value as a dict. :param value: :rtype: dict =z(Unable to parse option value to dict: %s)r partitionrri)rr'rresultlinerTsepvalrrr _parse_dict szConfigHandler._parse_dictcCs|}|dvS)zQRepresents value as boolean. :param value: :rtype: bool )1trueyes)lower)rr'rrr _parse_bool3szConfigHandler._parse_boolcsfdd}|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 cs d}||rtd|S)Nfile:zCOnly strings are accepted for the {0} field, files are not accepted)rg ValueErrorr1)r'Zexclude_directiverTrrrwIs z3ConfigHandler._exclude_files_parser..parserr)rrTrwrrr_exclude_files_parser=s z#ConfigHandler._exclude_files_parsercs\d}t|ts|S||s |S|t|d}dd|dD}dfdd|DS)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 rNcss|]}tj|VqdSr )rAr9rBrirrrrr,kr~z,ConfigHandler._parse_file..rzr{c3s.|]&}|stj|r|VqdS)TN) _assert_localrAr9rC _read_filerrrrr,ls)r!strrglenrjoin)rr'Zinclude_directiverZ filepathsrrr _parse_fileTs  zConfigHandler._parse_filecCs|tstd|dS)Nz#`file:` directive can not access %s)rgrArDr)rMrrrrrszConfigHandler._assert_localcCs:tj|dd}|WdS1s,0YdS)Nzutf-8)encoding)iorr)rMfrrrrwszConfigHandler._read_filec Cs4d}||s|S||dd}|}d|}|p@d}t}|r|d|vr||d}|dd} t | dkrtj t| d}| d}q|}nd|vrtj t|d}t |Nzt t ||WWdStyt|} Yn0Wdn1s 0Yt | |S) zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:rdrer r/N)rgrhrirpoprrArDrsplitrr9r<rRr r/r import_module) rr'r_Zattr_directiveZ attrs_path attr_name module_name parent_pathZ custom_pathpartsrrrr _parse_attr|s0         0zConfigHandler._parse_attrcsfdd}|S)zReturns parser function to represents value as a list. Parses a value applying given methods one after another. :param parse_methods: :rtype: callable cs|}D] }||}q|Sr r)r'parsedmethod parse_methodsrrr s z1ConfigHandler._get_parser_compound..parser)rrr rrr_get_parser_compounds z"ConfigHandler._get_parser_compoundcCs6i}|pdd}|D]\}\}}||||<q|S)zParses section options into a dictionary. Optionally applies a given parser to values. :param dict section_options: :param callable values_parser: :rtype: dict cSs|Sr r)rrrrr~z6ConfigHandler._parse_section_to_dict..)rf)rrlZ values_parserr'rT_rrrr_parse_section_to_dicts  z$ConfigHandler._parse_section_to_dictc Cs:|D],\}\}}z |||<Wqty2Yq0qdS)zQParses configuration file section. :param dict section_options: N)rfrt)rrlrrr'rrr parse_sections   zConfigHandler.parse_sectioncCsb|jD]R\}}d}|r"d|}t|d|ddd}|durTtd|j|f||q dS)zTParses configuration file items from one or more related sections. rdz_%szparse_section%sre__Nz0Unsupported distribution option section: [%s.%s])rjrfrRrhrrY)rrkrlZmethod_postfixZsection_parser_methodrrrr s zConfigHandler.parsecstfdd}|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 cst|i|Sr )warningswarn)argskwargsfuncmsg warning_classrrconfig_handlers z@ConfigHandler._deprecated_config_handler..config_handlerr)rrrrrrrr_deprecated_config_handlersz(ConfigHandler._deprecated_config_handler)F)rz)rz)N)N)r4r5r6r7rYrrr propertyrpry classmethodrrrrrr staticmethodrrrrrrr rrrrrrcs@  &         -   rccsHeZdZdZdddddZdZdfd d Zed d Zd dZ Z S)r]r^url description classifiers platforms)Z home_pagesummary classifierplatformFNcstt||||||_dSr )superr]r r_)rrSrar@r_rorrr s zConfigMetadataHandler.__init__cCs^|j}|j}|j}|j}|||||dt|||||d||ddt||||j|d S)rmz[The requires parameter is deprecated, please use install_requires for runtime dependencies.license license_filezDThe license_file parameter is deprecated, use license_files instead.) rkeywordsprovidesrequires obsoletesrrrZ license_filesrlong_descriptionversionZ project_urls)rrrrrDeprecationWarningr_parse_version)r parse_listZ parse_file parse_dictZexclude_files_parserrrrrps4 zConfigMetadataHandler.parserscCs||}||krF|}tt|trBd}t|jfit|S|||j }t |rb|}t|t st |drd tt |}nd|}|S)zSParses `version` option value. :param value: :rtype: str zCVersion loaded from {value} does not comply with PEP 440: {version}__iter__rez%s)rrir!r r rr1rrr_callablerhasattrrmap)rr'rtmplrrrr?s    z$ConfigMetadataHandler._parse_version)FN) r4r5r6rYrrZ strict_moder rrpr __classcell__rrrrr]s !r]c@sdeZdZdZeddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdS)r\racCsN|j}t|jdd}|j}|j}|j}|||||||||||j|j|t|dS)rm;r)Zzip_safeZinclude_package_datar_scriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ tests_requirepackages entry_points py_modulesZpython_requirescmdclass)rrrr_parse_cmdclass_parse_packagesrr )rrZparse_list_semicolonZ parse_boolrZparse_cmdclassrrrrpgs*zConfigOptionsHandler.parserscs$ddfdd||DS)NcSs8|d}||dd}|d|}t|}t||S)Nrer)rfind __import__rR)Zqualified_class_nameidx class_namepkg_namerrrr resolve_classs   z;ConfigOptionsHandler._parse_cmdclass..resolve_classcsi|]\}}||qSrrr(kvrrr r~z8ConfigOptionsHandler._parse_cmdclass..)rrf)rr'rrrrs z$ConfigOptionsHandler._parse_cmdclasscCsnddg}|}||vr"||S||dk}||jdi}|rTddlm}n ddlm}|fi|S)zTParses `packages` option value. :param value: :rtype: list zfind:zfind_namespace:rz packages.findr)find_namespace_packages) find_packages)rirparse_section_packages__findrjrs setuptoolsrr)rr'Zfind_directivesZ trimmed_valueZfindns find_kwargsrrrrrs    z$ConfigOptionsHandler._parse_packagescsR|||j}gdtfdd|D}|d}|durN|d|d<|S)zParses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options: )whereincludeexcludecs$g|]\}}|vr|r||fqSrrrZ valid_keysrrr}r~zEConfigOptionsHandler.parse_section_packages__find..rNr)rrrWrfrs)rrlZ section_datarrrrrrs  z1ConfigOptionsHandler.parse_section_packages__findcCs|||j}||d<dS)z`Parses `entry_points` configuration file section. :param dict section_options: rN)rrrrlrrrrparse_section_entry_pointssz/ConfigOptionsHandler.parse_section_entry_pointscCs.|||j}|d}|r*||d<|d=|S)Nrrd)rrrs)rrlrrootrrr_parse_package_datas  z(ConfigOptionsHandler._parse_package_datacCs|||d<dS)z`Parses `package_data` configuration file section. :param dict section_options: package_dataNr rrlrrrparse_section_package_datasz/ConfigOptionsHandler.parse_section_package_datacCs|||d<dS)zhParses `exclude_package_data` configuration file section. :param dict section_options: Zexclude_package_dataNr r rrr"parse_section_exclude_package_datasz7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd}||||d<dS)zbParses `extras_require` configuration file section. :param dict section_options: rrZextras_requireN)rrr)rrlrrrrparse_section_extras_requiresz1ConfigOptionsHandler.parse_section_extras_requirecCs(|||j}dd|D|d<dS)z^Parses `data_files` configuration file section. :param dict section_options: cSsg|]\}}||fqSrrrrrrr}r~zAConfigOptionsHandler.parse_section_data_files.. data_filesN)rrrfrrrrparse_section_data_filessz-ConfigOptionsHandler.parse_section_data_filesN)r4r5r6rYrrprrrrr rrrrrrrrr\cs    r\)FF)F) rrrAr8rrQr collectionsrrrglobr contextlibdistutils.errorsrrZ#setuptools.extern.packaging.versionr r Z&setuptools.extern.packaging.specifiersr r contextmanagerr<rPrVrLrJrcr]r\rrrrs4      -  c_