_dRD dZddlZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZddlmZmZddlmZd d lmZd d lmZmZd d lmZerdd lmZeeej>fZ ejBe"Z#de de$fdZ%de$de de&fdZ' d"ddde ddfdZ( d#de de dfdZ) d$de$de e de&de dde$f dZ*GddZ+dZ,ede&fdZ-Gddej\Z/Gd d!eZ0y)%ac Load setuptools configuration from ``pyproject.toml`` files. **PRIVATE MODULE**: API reserved for setuptools internal usage only. 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 ``tomllib`` or ``tomli``. N)contextmanager)partial) TYPE_CHECKINGCallableDictMappingOptionalSetUnion) FileError OptionError)SetuptoolsWarning)expand)_PREVIOUSLY_DEFINED_WouldIgnoreField)apply Distributionfilepathreturnctddlm}t|d5}|j|cdddS#1swYyxYw)Nr)tomlirb)setuptools.externropenload)rrfiles A/usr/lib/python3/dist-packages/setuptools/config/pyprojecttoml.py load_filer!s2' h  zz$   s.7configcddlm}|jjd}t |dr|j  |j |S#|j$r}d|j}|jjddk7r4tj|tj|jd|jd }t|d |dd}~wwxYw) Nr)_validate_pyprojectztrove-classifier_disable_downloadzconfiguration error: `projectzinvalid pyproject.toml config: . )r$FORMAT_FUNCTIONSgethasattrr%validateValidationErrorsummarynamestrip_loggerdebugdetails ValueError)r"r validatortrove_classifierexr0errors r r.r.%s2 11556HI!45**, :!!&))  $ $:)"**6 77==  * MM' " MM"** %1"''!<E7"WI./T9:sAC&BC!!C&distrc8t|d||}t|||S)zeApply the configuration from a ``pyproject.toml`` file into an existing distribution object. T)read_configuration_apply)r;rignore_option_errorsr"s r apply_configurationr@:s$ $0Dd KF $ ))ctjj|}tjj|st d|dt |xsi}|j di}|j di}|j di}|r|s|siSd|vrtjd|r*t|d d |jd |jn|jd d ||d<||d<t|5|d|id }t||d d d |r-tjj|} t|| ||S|S#1swY:xYw)aRead given configuration file and returns options from it as a dict. :param str|unicode filepath: Path to configuration file in the ``pyproject.toml`` format. :param bool expand: Whether to expand directives and other computed values (i.e. post-process the given configuration) :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. :param Distribution|None: Distribution object to which the configuration refers. If not given a dummy object will be created and discarded after the configuration is read. This is used for auto-discovery of packages and in the case a dynamic configuration (e.g. ``attr`` or ``cmdclass``) is expanded. When ``expand=False`` this object is simply ignored. :rtype: dict zConfiguration file z does not exist.r'tool setuptools distutilsz[tool.distutils])subjectinclude_package_dataNzinclude-package-dataT)r'rC)ospathabspathisfiler r!r,_ExperimentalConfigurationemitgetattr setdefaultrG_ignore_errorsr.dirnameexpand_configuration) rrr?r;asdict project_table tool_tablesetuptools_tablesubsetroot_dirs r r=r=FsX6wwx(H 77>>( #-h\9IJKK x &BFJJy"-MFB'J!~~lB7 -+; j "''0B'C  4d;G##$:D.>@S@ST  8%+77K  # # %  ! !+ .  $ $T; 7  8 %%d&<&<={{ 8 8s %ACC'c|jjd}|t|ttfry|jd}t|t ro|j |d<|jjdi|d<t|j5tjdi||jd<dddyy#1swYyxYw)NpackagesfindrX package-dirfill_package_dir) r`r, isinstancelisttupledictrXrOrPr?rs find_packages)rerrs r rxz _ConfigExpander._expand_packagess&&**:6  z(T5MB ||F# dD !#}}D '+':':'E'EmUW'XD# $ 9 9: P292G2G2O$2O##J/ P P " P Ps #CCcttj|j}|j |j d|y)N)rXz data-files)rrscanonic_data_filesrXrqr`)re data_filess r r{z"_ConfigExpander._expand_data_filess0W77$--P  D//zJrArzc|j}ttj||}|j |j d|y)N)rzrXcmdclass)rXrrsrrqr`)rerzrXrs r r|z _ConfigExpander._expand_cmdclasss7==7++xX D//XFrAc d}|jDcic]}||vr||j|||}}|j|j||xsi|j |||j ||j ||j||j||jDcic] \}}| || }}}|jj|ycc}wcc}}w)N)versionreadme entry-pointsscripts gui-scripts classifiers dependenciesoptional-dependencies)rrrroptional_dependencies) r]_obtainr~_obtain_entry_points_obtain_version_obtain_readme_obtain_classifiers_obtain_dependencies_obtain_optional_dependenciesitemsr_) rer;rzspecialrmobtained_dynamickvupdatess r r}z#_ConfigExpander._expand_all_dynamics   G# 4<<e[9 9    % %dK 8 >B(({;&&t,0062248"&"D"DT"J  %5$:$:$<NDAq 1a4NN (! OsC+< C0C0c`t||}||jsd|d}t|yy)Nz#No configuration found for dynamic z. Some dynamic fields need to be specified via `tool.setuptools.dynamic` others must be specified via the equivalent attribute in `setup.py`.)rr?r)rer;rmpreviousmsgs r _ensure_previously_setz&_ConfigExpander._ensure_previously_setsL&u-d3  D$=$=5eY?YY  c" " %> rA specifiercnddlm}t|j5|j}d|vrF|j j ||dtj|d|cdddSd|vr#tj|d||cdddStd|d|#1swYyxYw)Nr)always_iterablerattrz invalid `z`: ) setuptools.extern.more_itertoolsrrPr?rXrdr~rs read_files read_attrr6)rer directiverzrrXs r _expand_directivez!_ConfigExpander._expand_directives E D55 6 F}}H"&&--oi>O.PQ)))F*;XF  F F "((6):KR  F Fy 3ymDE E FsA B+3B+B++B4c||jvr#|jd||j||S|j||y)Nztool.setuptools.dynamic.)rarr)rer;rmrzs r rz_ConfigExpander._obtainsS D$$ $))*5'2  '  ##D%0rAcd|jvr4d|jvr&tj|j |d|Sy)Nr)r]rarsrr)rer;rzs r rz_ConfigExpander._obtain_version's:  $d6F6F)F??4<<i#MN NrAcd|jvry|j}d|vr)|j|di|djdddS|j |dy)Nr content-typez text/x-rst)textr)r]rarr,r)rer;ras r rz_ConfigExpander._obtain_readme-sh 4<< '&& { " T8R8 +H 5 9 9., W  ##D(3rAcd}tfd|Dsyj|d|}|ytj|didtdtffd }|dd|d d S) N)rrrc3:K|]}|jvywrp)r]).0rmres r z7_ConfigExpander._obtain_entry_points..?s=U5DLL(=srrmgroupc|vr<j|}|jvrtj||||<yy)N)rmvalue)popr]rrM)rmrrexpandedgroupsres r _set_scriptsz:_ConfigExpander._obtain_entry_points.._set_scriptsIsD 5) ,%**eD#( rArconsole_scriptsr gui_scripts)anyrrs entry_pointsstr)rer;rzfieldsrrrrs` @@r rz$_ConfigExpander._obtain_entry_points;s~<=f==||D.+> <%%d+"F+ ( (C ( Y 12]M2rAcjd|jvr%|j|di}|r|jSy)Nr)r]r splitlinesrer;rs r rz#_ConfigExpander._obtain_classifiersWs5 DLL (LL}b9E''))rAc`d|jvr |j|di}|r t|Sy)Nr)r]r_parse_requirements_listrs r rz$_ConfigExpander._obtain_dependencies^s1 T\\ )LL~r:E/66rAc 2d|jvryd|jvrb|jd}t|tsJ|j Dcic]%\}}|t |j d||i'c}}S|j|dycc}}w)Nrz.tool.setuptools.dynamic.optional-dependencies.)r]rarrrrrr)rer;optional_dependencies_maprrs r rz-_ConfigExpander._obtain_optional_dependencieses "$,, 6 "d&6&6 6(,(8(89P(Q %7> >>)B(G(G(I %E9/**HP!   ##D*AB s*BNFN)rr)z package-data)r;r)__name__ __module__ __qualname__rr _Pathboolrfrkrrrqrvrrxr{rr|r}rrrrrrrrrrrrAr rZrZs}%)%*)- 115/1# 1 ~& 1"1 88S8h8 :" PKGGCH,=G ))WSRUXEV)<#>###  6=c3h6G N3WSRUXEVNcAR > htCH~6N "18c1B $sDy/ "8rArZc|jDcgc]3}|jr!|jjds|5c}Scc}w)N#)rr2 startswith)rlines r rrysI$$&   ::< 7 7 <   s8Ac#K|sdy dy#t$r9}tjd|jjd|Yd}~yd}~wwxYww)Nzignored error: z - ) Exceptionr3r4 __class__r)r?r9s r rPrPsP  H H  (=(='>c"FGGHs*AA A/A A AAc@eZdZdddedeffd ZfdZfdZxZS)ry distributionrr_r`c@t||||_||_yrp)superrf _project_cfg_setuptools_cfg)rerr_r`rs r rfz"_EnsurePackagesDiscovered.__init__s" &'-rAc|j|j}}|jdi}|j|jxsi||_|j j |jj*|jjd|j_|j|jd|_ |j|jd|_ t|9S)zWhen entering the context, the values of ``packages``, ``py_modules`` and ``package_dir`` that are missing in ``dist`` are copied from ``setuptools_cfg``. rr1 py-modulesr)rbrrOr~rz set_defaults_ignore_ext_modulesmetadatar1rr, py_modulesrr __enter__)rer;cfgrzrs r rz#_EnsurePackagesDiscovered.__enter__sJJ 4 4c&)nn]B&G 4++1r2& --/ ==   %!%!2!2!6!6v!>DMM  ?? "!ggl3DO == GGJ/DMw ""rAc|jjd|jj|jjd|jjt ||||S)zWhen exiting the context, if values of ``packages``, ``py_modules`` and ``package_dir`` are missing in ``setuptools_cfg``, copy from ``dist``. rr)rrOrbrrr__exit__)reexc_type exc_value tracebackrs r rz"_EnsurePackagesDiscovered.__exit__sY '' DJJ4G4GH '' djj6K6KLw)Y??rA)rrrrrfrr __classcell__)rs@r ryrys1.*.9=.OS.#,@@rAryceZdZdZy)rLz``{subject}` in `pyproject.toml` is still *experimental* and likely to change in future releases.N)rrr_SUMMARYrrAr rLrLs  3 rArL)F)TFNr)1__doc__loggingrH contextlibr functoolsrtypingrrrrr r r errorsr rwarningsrr*rrs_apply_pyprojecttomlrrrr>rirrPathLiker getLoggerrr3rr!rr.r@r=rRrZrrPEnsurePackagesDiscoveredryrLrrAr rss  %OOO+(H1, c2;; '  H %  $ :T:U:t:0 *  * * * %) ?? > " ?H!%!&%) R RuoRR > " R  R.WWtHHH%@ @ @%@P!2rA