a c_P@sddlmZmZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddl m Z ddlmZmZddlmZmZdd lmZdd lmZmZeZdd d ZddZddZdddZGdddZGdddeZ GdddeZ!dS))absolute_importunicode_literalsN) defaultdict)partialwraps) import_module)DistutilsOptionErrorDistutilsFileError) LegacyVersionparse) SpecifierSet) string_typesPY3Fc 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.distrrospathabspathisfiler getcwdchdirdirnamefind_config_filesappendparse_config_filesparse_configurationcommand_optionsconfiguration_to_dict) filepathZ find_othersrrrZcurrent_directorydistrhandlersr$^/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/setuptools/config.pyread_configurations(   r&cCs2djfit}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})formatlocals functoolsrgetattr) target_objkeyZ getter_nameZ by_attributegetterr$r$r% _get_optionEs r.cCs<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_optionsr.r+section_prefix)r#Z config_dicthandleroptionvaluer$r$r%r Qs   r cCs6t|||}|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) distributionrroptionsmetar$r$r%rcsrc@seZdZdZdZiZd%ddZeddZdd Z e d&d d Z e d dZ e ddZ e ddZe ddZeddZeddZe d'ddZe ddZe d(ddZdd Zd!d"Zd#d$ZdS)) ConfigHandlerz1Handles metadata supplied in configuration files.NFcCs^i}|j}|D].\}}||s&q||dd}|||<q||_||_||_g|_dS)N.) r1items startswithreplacestriprr+sectionsr0)selfr+r:rrCr1 section_namesection_optionsr$r$r%__init__s  zConfigHandler.__init__cCstd|jjdS).Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)NotImplementedError __class____name__)rDr$r$r%parserss zConfigHandler.parsersc Cst}|j}|j||}t|||}||ur6t||r>dSd}|j|}|r~z ||}Wnty|d}|jsxYn0|rdSt|d|d}|durt |||n|||j |dS)NFTzset_%s) tupler+aliasesgetr*KeyErrorrL Exceptionrsetattrr0r) rDZ option_namer4unknownr+Z current_valueZ skip_optionparsersetterr$r$r% __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$)rB).0chunkr$r$r% z-ConfigHandler._parse_list..) isinstancelist splitlinessplit)clsr4 separatorr$r$r% _parse_lists   zConfigHandler._parse_listcCsPd}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)rc partitionr rB)rar4rbresultliner,sepvalr$r$r% _parse_dictszConfigHandler._parse_dictcCs|}|dvS)zQRepresents value as boolean. :param value: :rtype: bool )1trueyes)lower)rar4r$r$r% _parse_boolszConfigHandler._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)r@ ValueErrorr')r4Zexclude_directiver,r$r%rTs z3ConfigHandler._exclude_files_parser..parserr$)rar,rTr$rrr%_exclude_files_parsers 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 rpNcss|]}tj|VqdSN)rrrrBrYrr$r$r% %r\z,ConfigHandler._parse_file..rWrXc3s.|]&}|stj|r|VqdS)TN) _assert_localrrr _read_filerurar$r%rv&s  )r]rr@lenr`join)rar4Zinclude_directivespecZ filepathsr$ryr% _parse_files  zConfigHandler._parse_filecCs|tstd|dS)Nz#`file:` directive can not access %s)r@rrr )r!r$r$r%rw-szConfigHandler._assert_localcCs:tj|dd}|WdS1s,0YdS)Nzutf-8)encoding)ioopenread)r!fr$r$r%rx3szConfigHandler._read_filec Csd}||s|S||dd}|}d|}|p@d}t}|r|d|vr||d}|dd} t | dkrtj t| d}| d}q|}nd|vrtj t|d}t j d|z&t |} t| |}Wt j ddt _ nt j ddt _ 0|S) zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:r=r>rGr/N)r@rArBr`popr{rrrsplitrzrsysinsertrr*) rar4r8Zattr_directiveZ attrs_path attr_name module_name parent_pathZ custom_pathpartsmoduler$r$r% _parse_attr8s0         $zConfigHandler._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|Srtr$)r4parsedmethod parse_methodsr$r%r ns z1ConfigHandler._get_parser_compound..parser$)rarr r$rr%_get_parser_compoundes 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|Srtr$)rir$r$r%r\z6ConfigHandler._parse_section_to_dict..)r?)rarFZ values_parserr4r,_rir$r$r%_parse_section_to_dictxs  z$ConfigHandler._parse_section_to_dictc Cs:|D],\}\}}z |||<Wqty2Yq0qdS)zQParses configuration file section. :param dict section_options: N)r?rP)rDrFnamerr4r$r$r% 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. r=z_%szparse_section%sr>__Nz0Unsupported distribution option section: [%s.%s])rCr?r*rAr r1)rDrErFZmethod_postfixZsection_parser_methodr$r$r%r s zConfigHandler.parsecstfdd}|S)z this 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|Srt)warningswarn)argskwargsfuncmsg warning_classr$r%config_handlers z@ConfigHandler._deprecated_config_handler..config_handlerr)rDrrrrr$rr%_deprecated_config_handlersz(ConfigHandler._deprecated_config_handler)F)rW)N)N)rK __module__ __qualname____doc__r1rNrGpropertyrLrV classmethodrcrjrorsr} staticmethodrwrxrrrrr rr$r$r$r%r<~s<  &        ,   r<csHeZdZdZdddddZdZdfd d Zed d Zd dZ Z S)r6r7url description classifiers platforms)Z home_pagesummary classifierplatformFNcstt||||||_dSrt)superr6rGr8)rDr+r:rr8rJr$r%rGszConfigMetadataHandler.__init__c CsN|j}|j}|j}|j}|||||dt|||||d||||j|d S)rHz[The requires parameter is deprecated, please use install_requires for runtime dependencies.license) rkeywordsprovidesrequires obsoletesrrZ license_filesrlong_descriptionversion project_urls)rcr}rjrsrDeprecationWarningr_parse_version)rD parse_listZ parse_file parse_dictZexclude_files_parserr$r$r%rLs* 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__r>z%s)r}rBr]r r r r'r(rr8callablerhasattrr{mapstr)rDr4rtmplr$r$r%rs    z$ConfigMetadataHandler._parse_version)FN) rKrrr1rNZ strict_moderGrrLr __classcell__r$r$rr%r6s r6c@s\eZdZdZeddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ dS)r5r:cCsN|j}t|jdd}|j}|j}|||||||||||||||j|j|tdS)rH;rb)Zzip_safeZuse_2to3Zinclude_package_datar8Zuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctestsscriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ tests_requirepackages entry_points py_modulesZpython_requires)rcrrorj_parse_packagesr}r )rDrZparse_list_semicolonZ parse_boolrr$r$r%rLs.zConfigOptionsHandler.parserscCs~ddg}|}||vr"||S||dk}|r>ts>td||jdi}|rdddlm}n ddlm }|fi|S) zTParses `packages` option value. :param value: :rtype: list zfind:zfind_namespace:rz8find_namespace: directive is unsupported on Python < 3.3z packages.findr)find_namespace_packages) find_packages) rBrcrr parse_section_packages__findrCrO setuptoolsrr)rDr4Zfind_directivesZ trimmed_valueZfindns find_kwargsrr$r$r%r2s     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||fqSr$r$rYkvZ valid_keysr$r%r[[r\zEConfigOptionsHandler.parse_section_packages__find..rNr)rrcr/r?rO)rDrFZ section_datarrr$rr%rNs  z1ConfigOptionsHandler.parse_section_packages__findcCs|||j}||d<dS)z`Parses `entry_points` configuration file section. :param dict section_options: rN)rrcrDrFrr$r$r%parse_section_entry_pointscsz/ConfigOptionsHandler.parse_section_entry_pointscCs.|||j}|d}|r*||d<|d=|S)N*r=)rrcrO)rDrFrrootr$r$r%_parse_package_dataks  z(ConfigOptionsHandler._parse_package_datacCs|||d<dS)z`Parses `package_data` configuration file section. :param dict section_options: package_dataNrrDrFr$r$r%parse_section_package_datausz/ConfigOptionsHandler.parse_section_package_datacCs|||d<dS)zhParses `exclude_package_data` configuration file section. :param dict section_options: Zexclude_package_dataNrrr$r$r%"parse_section_exclude_package_data|sz7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd}||||d<dS)zbParses `extras_require` configuration file section. :param dict section_options: rrZextras_requireN)rrcr)rDrFrr$r$r%parse_section_extras_requiresz1ConfigOptionsHandler.parse_section_extras_requirecCs(|||j}dd|D|d<dS)z^Parses `data_files` configuration file section. :param dict section_options: cSsg|]\}}||fqSr$r$rr$r$r%r[r\zAConfigOptionsHandler.parse_section_data_files.. data_filesN)rrcr?rr$r$r%parse_section_data_filessz-ConfigOptionsHandler.parse_section_data_filesN)rKrrr1rrLrrrrrrrrr$r$r$r%r5s   r5)FF)F)" __future__rrrrrrr) collectionsrrr importlibrdistutils.errorsr r Z#setuptools.extern.packaging.versionr r Z&setuptools.extern.packaging.specifiersr Zsetuptools.extern.sixrrtype __metaclass__r&r.r rr<r6r5r$r$r$r%s2      /  ?V