o )aSZ@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 }|}Wdn1swYt|}t| t |` dSN) importlibutil find_specopenoriginreadastr varsupdatelocalsself)rnamespecZstrmsrcmodulerD/opt/alt/python310/lib/python3.10/site-packages/setuptools/config.py__init__s    zStaticModule.__init__c sNztfdd|jjDWSty&}z tdjdit|d}~ww)Nc3sJ|] }t|tjr|jD]}t|tjr |jkr t|jVq qdSr ) isinstancerZAssigntargetsNameidZ literal_evalvalue).0Z statementtargetattrrr #s    z+StaticModule.__getattr__..z#{self.name} has no attribute {attr}r)nextrbody ExceptionAttributeErrorformatr)rr(err'r __getattr__!s  zStaticModule.__getattr__N)__name__ __module__ __qualname____doc__rr0rrrrr s r c cs8ztjd|dVWtj|dStj|w)zH Add path to front of sys.path for the duration of the context. rN)syspathinsertremove)r6rrr patch_path0s r9Fc Csddlm}m}tj|}tj|std|t}t tj |z-|}|r1| ng}||vr<| ||j ||dt||j|d}Wt |t|St |w)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;osr6abspathisfilergetcwdchdirdirnameZfind_config_filesappendZparse_config_filesparse_configurationcommand_optionsconfiguration_to_dict) filepathZ find_othersr=r:r;Zcurrent_directoryZdistr<handlersrrrread_configuration<s$      rJcCs2djdit}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}Nr)r.r functoolsrgetattr) target_objkeyZ getter_nameZ by_attributegetterrrr _get_optionis rPcCs<tt}|D]}|jD]}t|j|}|||j|<q q|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_optionsrPrMsection_prefix)rIZ config_dictZhandlerZoptionr$rrrrGus  rGcCs6t|||}|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)Z distributionrFr=optionsmetarrrrEs rEc@seZdZdZdZ iZ d'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]\}}||sq ||dd}|||<q ||_||_||_g|_dS)N.) rSitems startswithreplacestripr=rMsectionsrR)rrMrXr=rarS section_namesection_optionsrrrrs   zConfigHandler.__init__cCstd|jj).Metadata item name to parser function mapping.z!%s must provide .parsers property)NotImplementedError __class__r1)rrrrparserss zConfigHandler.parsersc Cst}|j}|j||}t|||}||urt||rdSd}|j|}|r?z||}Wnty>d}|js<Ynw|rCdSt|d|d}|durVt |||n|||j |dS)NFTzset_%s) tuplerMaliasesgetrLKeyErrorrgr,r=setattrrRrD) rZ option_namer$unknownrMZ current_valueZ skip_optionparsersetterrrr __setitem__s4    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)r`)r%chunkrrr sz-ConfigHandler._parse_list..)r list splitlinessplit)clsr$ separatorrrr _parse_lists   zConfigHandler._parse_listc sjd}|j|d}g}|D]%tfdd|Dr-|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 )*?[]{}ryc3s|]}|vVqdSr r)r%charr$rrr)sz1ConfigHandler._parse_list_glob..css"|] }tj|tVqdSr )r>r6relpathrAr%r6rrrr)s  ) rzanyextendsortedrr>r6r?rD)rxr$ryZglob_charactersvaluesZexpanded_valuesrrr_parse_list_globs   zConfigHandler._parse_list_globcCsPd}i}||D]}||\}}}||krtd||||<q |S)zPRepresents value as a dict. :param value: :rtype: dict =z(Unable to parse option value to dict: %s)rz partitionrr`)rxr$ryresultlinerNsepvalrrr _parse_dict szConfigHandler._parse_dictcCs|}|dvS)zQRepresents value as boolean. :param value: :rtype: bool )1trueZyes)lower)rxr$rrr _parse_bool3szConfigHandler._parse_boolcfdd}|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.)r$Zexclude_directiverNrrrnIs z3ConfigHandler._exclude_files_parser..parserr)rxrNrnrrr_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 )r>r6r?r`rrrrr)ksz,ConfigHandler._parse_file..rqrrc3s4|]}|s tj|r|VqdS)TN) _assert_localr>r6r@ _read_filerrxrrr)ls  )r strr^lenrwjoin)rxr$Zinclude_directiverZ filepathsrrr _parse_fileTs  zConfigHandler._parse_filecCs|ts td|dS)Nz#`file:` directive can not access %s)r^r>rAr)rHrrrrrs zConfigHandler._assert_localcCs:tj|dd }|WdS1swYdS)Nzutf-8)encoding)iorr)rHfrrrrws$zConfigHandler._read_filec Cs0d}||s |S||dd}|}d|}|p d}t}|ra|d|vrR||d}|dd} t | dkrOtj t| d}| d}qa|}nd|vratj t|d}t |&zt t ||WWdStyt|} YnwWdn1swYt | |S) zRepresents value as a module attribute. Examples: attr: package.attr attr: package.module.attr :param str value: :rtype: str zattr:r[r\rr/N)r^r_r`rwpoprr>rArsplitrr6r9rLr r,r import_module) rxr$rWZattr_directiveZ attrs_pathZ attr_nameZ module_name parent_pathZ custom_pathpartsrrrr _parse_attr|s8          zConfigHandler._parse_attrcr)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)rxrr 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)rrrrsz6ConfigHandler._parse_section_to_dict..)r])rxrcZ values_parserr$rN_rrrr_parse_section_to_dicts  z$ConfigHandler._parse_section_to_dictc Cs8|D]\}\}}z|||<WqtyYqwdS)zQParses configuration file section. :param dict section_options: N)r]rk)rrcrrr$rrr parse_sections  zConfigHandler.parse_sectioncCsb|jD])\}}d}|rd|}t|d|ddd}|dur*td|j|f||qdS)zTParses configuration file items from one or more related sections. r[z_%szparse_section%sr\__Nz0Unsupported distribution option section: [%s.%s])rar]rLr_rrS)rrbrcZmethod_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_handlerF)rqr )r1r2r3r4rSrirpropertyrgrp classmethodrzrrrrr staticmethodrrrrrrr rrrrrrZsF  &         -   rZcsLeZdZdZdddddZdZ dfd d Zed d Zd dZ Z S)rUrVurl description classifiers platforms)Z home_pageZsummaryZ classifierplatformFNcstt||||||_dSr )superrUrrW)rrMrXr=rWrfrrrs  zConfigMetadataHandler.__init__cCs^|j}|j}|j}|j}|||||dt|||||d||ddt||||j|d S)rdz[The requires parameter is deprecated, please use install_requires for runtime dependencies.license license_filezDThe license_file parameter is deprecated, use license_files instead.) rkeywordsZprovidesZrequiresZ obsoletesrrrZ license_filesrZlong_descriptionversionZ project_urls)rzrrrrDeprecationWarningr_parse_version)r parse_listZ parse_file parse_dictZexclude_files_parserrrrrgs4 zConfigMetadataHandler.parserscCs||}||kr#|}tt|tr!d}t|jdit|S|||j }t |r1|}t|t sIt |drEd tt |}|Sd|}|S)zSParses `version` option value. :param value: :rtype: str zCVersion loaded from {value} does not comply with PEP 440: {version}__iter__r\z%sNr)rr`r r r rr.rrrWcallablerhasattrrmap)rr$rZtmplrrrr?s"   z$ConfigMetadataHandler._parse_version)FN) r1r2r3rSriZ strict_moderrrgr __classcell__rrrrrUs !rUc@sdeZdZdZeddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdS)rTrXcCsN|j}t|jdd}|j}|j}|j}|||||||||||j|j|t|dS)rd;r)Zzip_safeZinclude_package_datarWZscriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZ tests_requireZpackages entry_pointsZ py_modulesZpython_requiresZcmdclass)rzrrr_parse_cmdclass_parse_packagesrr )rrZparse_list_semicolonZ parse_boolrZparse_cmdclassrrrrggs*zConfigOptionsHandler.parserscs$ddfdd||DS)NcSs8|d}||dd}|d|}t|}t||S)Nr\r)rfind __import__rL)Zqualified_class_nameidx class_nameZpkg_namerrrr resolve_classs   z;ConfigOptionsHandler._parse_cmdclass..resolve_classcsi|] \}}||qSrrr%kvrrr sz8ConfigOptionsHandler._parse_cmdclass..)rr])rr$rrrrs z$ConfigOptionsHandler._parse_cmdclasscCsnddg}|}||vr||S||dk}||jdi}|r*ddlm}nddlm}|d i|S) zTParses `packages` option value. :param value: :rtype: list zfind:zfind_namespace:rz packages.findr)find_namespace_packages) find_packagesNr)r`rzparse_section_packages__findrarjZ setuptoolsrr)rr$Zfind_directivesZ trimmed_valueZfindns find_kwargsrrrrrs    z$ConfigOptionsHandler._parse_packagescsR|||j}gdtfdd|D}|d}|dur'|d|d<|S)zParses `packages.find` configuration file section. To be used in conjunction with _parse_packages(). :param dict section_options: )whereZincludeZexcludecs$g|]\}}|vr|r||fqSrrrZ valid_keysrrrts$zEConfigOptionsHandler.parse_section_packages__find..rNr)rrzrQr]rj)rrcZ section_datarrrrrrs  z1ConfigOptionsHandler.parse_section_packages__findcCs|||j}||d<dS)z`Parses `entry_points` configuration file section. :param dict section_options: rN)rrzrrcrrrrparse_section_entry_pointss z/ConfigOptionsHandler.parse_section_entry_pointscCs.|||j}|d}|r||d<|d=|S)Nr{r[)rrzrj)rrcrrootrrr_parse_package_datas  z(ConfigOptionsHandler._parse_package_datacC|||d<dS)z`Parses `package_data` configuration file section. :param dict section_options: Z package_dataNrrrcrrrparse_section_package_dataz/ConfigOptionsHandler.parse_section_package_datacCr)zhParses `exclude_package_data` configuration file section. :param dict section_options: Zexclude_package_dataNrrrrr"parse_section_exclude_package_datarz7ConfigOptionsHandler.parse_section_exclude_package_datacCs"t|jdd}||||d<dS)zbParses `extras_require` configuration file section. :param dict section_options: rrZextras_requireN)rrzr)rrcrrrrparse_section_extras_requires z1ConfigOptionsHandler.parse_section_extras_requirecCs(|||j}dd|D|d<dS)z^Parses `data_files` configuration file section. :param dict section_options: cSsg|]\}}||fqSrrrrrrrtszAConfigOptionsHandler.parse_section_data_files..Z data_filesN)rrr]rrrrparse_section_data_filessz-ConfigOptionsHandler.parse_section_data_filesN)r1r2r3rSrrgrrrrrrrrrrrrrrTcs    rT)FFr) rrr>r5rrKr collectionsrrrglobr contextlibZdistutils.errorsrrZ#setuptools.extern.packaging.versionr r Z&setuptools.extern.packaging.specifiersr r contextmanagerr9rJrPrGrErZrUrTrrrrs6       - c_