K iNUdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z mZmZddlmZddlmZmZddlZddlmZdd lmZmZdd lmZdd l mZddlZdd lm Z erdd l!m"Z"gdZ#Gdde$Z%GddejLjNZ'ejPdZ)dZ*d"dZ+dZ,ejPdZ-eee.ee.e/e.dffdfZ0de1d< GddZ2Gdde2Z3Gdde3Z4Gd d!eZ5e3Z6e6jnZ7e6jpZ8e6jrZ9e6jtZ:e6jvZ;e6jxZe4Z?y)#a'A PEP 517 interface to setuptools Previously, when a user or a command line tool (let's call it a "frontend") needed to make a request of setuptools to take a certain action, for example, generating a list of installation requirements, the frontend would call "setup.py egg_info" or "setup.py bdist_wheel" on the command line. PEP 517 defines a different method of interfacing with setuptools. Rather than calling "setup.py" directly, the frontend should: 1. Set the current directory to the directory with a setup.py file 2. Import this module into a safe python interpreter (one in which setuptools can potentially set global variables or crash hard). 3. Call one of the functions defined in PEP 517. What each function does is defined in PEP 517. However, here is a "casual" definition of the functions (this definition should not be relied on for bug reports or API stability): - `build_wheel`: build a wheel in the folder and return the basename - `get_requires_for_build_wheel`: get the `setup_requires` to build - `prepare_metadata_for_build_wheel`: get the `install_requires` - `build_sdist`: build an sdist in the folder and return the basename - `get_requires_for_build_sdist`: get the `setup_requires` to build Again, this is not a formal definition! Just a "taste" of the module. ) annotationsN)IterableIteratorMapping)Path) TYPE_CHECKINGUnion)errors)StrPath same_path) parse_strings)SetuptoolsDeprecationWarning) strtobool) TypeAlias) get_requires_for_build_sdistget_requires_for_build_wheel prepare_metadata_for_build_wheel build_wheel build_sdistget_requires_for_build_editable#prepare_metadata_for_build_editablebuild_editable __legacy__SetupRequirementsErrorceZdZddZy)rc||_yN) specifiers)selfrs [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/build_meta.py__init__zSetupRequirementsError.__init__Hs $N)returnNone)__name__ __module__ __qualname__r"r#r!rrGs%r#rc@eZdZdZeej dZy) Distributionc@tt|}t|r)listrr)r rspecifier_lists r!fetch_build_eggszDistribution.fetch_build_eggsMsmJ78$^44r#c#Ktjj}|tj_ d|tj_y#|tj_wxYww)zw Replace distutils.dist.Distribution with this class for the duration of this context. N) distutilscorer+)clsorigs r!patchzDistribution.patchRsC~~**&) # / *.INN '$INN 's0A'A A' A$$A'N)r&r'r(r/ classmethod contextlibcontextmanagerr5r)r#r!r+r+Ls)5  / /r#r+c#Ktj}dt_ d|t_y#|t_wxYww)a Temporarily disable installing setup_requires Under PEP 517, the backend reports build dependencies to the frontend, and the frontend is responsible for ensuring they're installed. So setuptools (acting as a backend) should not try to install them. cyrr))attrss r!z+no_install_setup_requires..ksr#N) setuptools_install_setup_requires)r4s r!no_install_setup_requiresr?bs3  - -D);J&2 -1 *T *sA0 A =Ac tj|Dcgc]B}tjjtjj ||sA|Dc}Scc}wr)oslistdirpathisdirjoin)a_dirnames r!_get_immediate_subdirectoriesrHrsGE* bggmmBGGLLPTz'_file_with_extension..ysJaAJJy4IJs!!z[No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.)rArB ValueError) directoryrNmatchingfiles ` r!_file_with_extensionrTxsQJ2::i0JH K  8  s'=ctjj|stjdSt j |S)Nz%from setuptools import setup; setup())rArCexistsioStringIOtokenizeopen setup_scripts r!_open_setup_scriptr]s1 77>>, '{{BCC == &&r#c#Ktj5tjddddddy#1swYyxYww)Nignorezsetup.py install is deprecated)warningscatch_warningsfilterwarningsr)r#r!suppress_known_deprecationrcs:  "*JK sA; AAAr_ConfigSettingsc8eZdZdZddZd dZd dZd dZd dZy) _ConfigSettingsTranslatorzTranslate ``config_settings`` into distutils-style command arguments. Only a limited number of options is currently supported. c|xsi}|j|xsg}t|trtj|S|S)aA Get the value of a specific key in ``config_settings`` as a list of strings. >>> fn = _ConfigSettingsTranslator()._get_config >>> fn("--global-option", None) [] >>> fn("--global-option", {}) [] >>> fn("--global-option", {'--global-option': 'foo'}) ['foo'] >>> fn("--global-option", {'--global-option': ['foo']}) ['foo'] >>> fn("--global-option", {'--global-option': 'foo'}) ['foo'] >>> fn("--global-option", {'--global-option': 'foo bar'}) ['foo', 'bar'] )get isinstancestrshlexsplit)r keyconfig_settingscfgoptss r! _get_configz%_ConfigSettingsTranslator._get_configs=$#wws|!r$.tS$9u{{4 CtCr#c#K|xsi}hd}d|vsd|vrIt|jdxs|jdxsd}|j|vrdndd|vsd|vrIt|jdxs|jdxsd}|j|vrdnd|jd |Ed {y 7w) a Let the user specify ``verbose`` or ``quiet`` + escape hatch via ``--global-option``. Note: ``-v``, ``-vv``, ``-vvv`` have similar effects in setuptools, so we just have to cover the basic scenario ``-v``. >>> fn = _ConfigSettingsTranslator()._global_args >>> list(fn(None)) [] >>> list(fn({"verbose": "False"})) ['-q'] >>> list(fn({"verbose": "1"})) ['-v'] >>> list(fn({"--verbose": None})) ['-v'] >>> list(fn({"verbose": "true", "--global-option": "-q --no-user-cfg"})) ['-v', '-q', '--no-user-cfg'] >>> list(fn({"--quiet": None})) ['-q'] >0noofffalseverbosez --verbose1z-qz-vquietz--quietz--global-optionN)rjrhlowerrq)r rnrofalseylevels r! _global_argsz&_ConfigSettingsTranslator._global_argss*#,  {c1 *Icggk.BIcJE ;;=F24 = c>Y#-(ECGGI,>E#FE ;;=F24 =##$5GGGsCC C C c#K|xsi}d|vr#tt|dxsd}|rdndd|vrdt|dgEd{yy7w)a The ``dist_info`` command accepts ``tag-date`` and ``tag-build``. .. warning:: We cannot use this yet as it requires the ``sdist`` and ``bdist_wheel`` commands run in ``build_sdist`` and ``build_wheel`` to reuse the egg-info directory created in ``prepare_metadata_for_build_wheel``. >>> fn = _ConfigSettingsTranslator()._ConfigSettingsTranslator__dist_info_args >>> list(fn(None)) [] >>> list(fn({"tag-date": "False"})) ['--no-date'] >>> list(fn({"tag-date": None})) ['--no-date'] >>> list(fn({"tag-date": "true", "tag-build": ".a"})) ['--tag-date', '--tag-build', '.a'] ztag-datervz --tag-datez --no-datez tag-buildz --tag-buildN)rrj)r rnrovals r!__dist_info_argsz*_ConfigSettingsTranslator.__dist_info_argssd&#  CJ :7;>> fn = _ConfigSettingsTranslator()._editable_args >>> list(fn(None)) [] >>> list(fn({"editable-mode": "strict"})) ['--mode', 'strict'] z editable-mode editable_modeNz--mode)rhrj)r rnromodes r!_editable_argsz(_ConfigSettingsTranslator._editable_argssF#ww'C377?+C c$i(((s>AAAc#DK|jd|Ed{y7w)av Users may expect to pass arbitrary lists of arguments to a command via "--global-option" (example provided in PEP 517 of a "escape hatch"). >>> fn = _ConfigSettingsTranslator()._arbitrary_args >>> list(fn(None)) [] >>> list(fn({})) [] >>> list(fn({'--build-option': 'foo'})) ['foo'] >>> list(fn({'--build-option': ['foo']})) ['foo'] >>> list(fn({'--build-option': 'foo'})) ['foo'] >>> list(fn({'--build-option': 'foo bar'})) ['foo', 'bar'] >>> list(fn({'--global-option': 'foo'})) [] z--build-optionN)rqr rns r!_arbitrary_argsz)_ConfigSettingsTranslator._arbitrary_args s*##$4oFFFs   N)rmrjrnrdr$ list[str])rnrdr$z Iterator[str]) r&r'r(__doc__rqr})_ConfigSettingsTranslator__dist_info_argsrrr)r#r!rfrfs$ D,H@>4) Gr#rfceZdZ ddZdddZdddZdddZ ddZddZ d ddZ d dd Z d dd Z d dd Z dd Z d dd ZdddZ d ddZy)_BuildMetaBackendc*gtjdd|j|dt_ tj 5|j ddd|S#1swY|SxYw#t $r}||jz }Yd}~|Sd}~wwxYw)Nr egg_info)sysargvr}r+r5 run_setuprr)r rn requirementses r!_get_build_requiresz%_BuildMetaBackend._get_build_requires#s XXbq\    /     )##% !  !   ! & ) ALL (L )s5A/A"A/"A,'A/,A// B8B  Bcftjj|}d}t|5}|j j dd}ddd t ty#1swYxYw#t$r/}|jrtjdddYd}~yd}~wwxYw)N__main__z\r\nz\nz6Running `setup.py` directly as CLI tool is deprecated.znPlease avoid using `sys.exit(0)` or similar statements that don't fit in the paradigm of a configuration file.zAhttps://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html)see_url) rArCabspathr]readreplaceexeclocals SystemExitcoderemit)r r\__file__r&rMrrs r!rz_BuildMetaBackend.run_setup3s77??<0  ) 4Q668##GU3D 4  vx  4 4  vv ( - -HJ+    s#!A,A8,A58 B0%B++B0Nc(|j|gSN)rrrs r!rz._BuildMetaBackend.get_requires_for_build_wheelJ''b'IIr#c(|j|gSrrrs r!rz._BuildMetaBackend.get_requires_for_build_sdistMrr#c|j||}t|j|stjt |||j S)z PEP 517 requires that the .dist-info directory be placed in the metadata_directory. To comply, we MUST copy the directory to the root. Returns the basename of the info directory, e.g. `proj-0.0.0.dist-info`. )_find_info_directoryr parentshutilmoverjrG)r metadata_directorysuffixinfo_dirs r!_bubble_up_info_directoryz+_BuildMetaBackend._bubble_up_info_directoryPsC,,-?H*<= KKH '9 :}}r#cPtj|D]m\}}}|Dcgc]}|j|s|}}t|dk7st|dk7sEt|dk(s Jd|dt ||dcSd|d|}t j |cc}w)Nrr z Multiple z directories foundzNo z directory found in )rAwalkrKlenrr InternalError) r rrrdirs_rM candidatesmsgs r!rz&_BuildMetaBackend._find_info_directory_s!ww'9: 3OFD!%)@QZZ-?!@J@:!#s4yA~:!+Sy@R-SS+FJqM22  3F8/0B/CD""3''As B#B#c(gtjdd|j|ddt|dt_t 5|j ddd|j |d|j |dS#1swY-xYw)Nr dist_infoz --output-dirz--keep-egg-infoz .egg-infoz .dist-info)rrr}rjr?rrr rrns r!rz2_BuildMetaBackend.prepare_metadata_for_build_wheeljs XXbq\    /      " #    ' (  NN   &&'9;G--.@,OO   s BBctjj|}tj|dt j d|5}gt jdd|j||d||t _t5|jdddt||}tjj||}tjj|rtj|tjtjj|||ddd|S#1swYxYw#1swYSxYw)NT)exist_okz.tmp-)prefixdirr z --dist-dir)rArCrmakedirstempfileTemporaryDirectoryrrr}r?rrTrErVremoverename) r setup_commandresult_extensionresult_directoryrnarbitrary_args tmp_dist_dirresult_basename result_paths r!_build_with_temp_dirz&_BuildMetaBackend._build_with_temp_dir{s=77??+;< $t4  ( ( 0  P "1""?3     CH+, !  !3._buildsF+- 00##((9    s $:A bdist_wheel--dist-info-dirz--dist-info-dir not recognized)rr)rjr_IncompatibleBdistWheelr)r rrnrrexs``` r!rz_BuildMetaBackend.build_wheelss    %=/* * +=*;SAS=TUV V +/s2w> # ( ( *=/* *  +s, A**A%A*%A*c.|jgdd||S)N)sdistz --formatsgztarz.tar.gz)r)r sdist_directoryrns r!rz_BuildMetaBackend.build_sdists (( +Y  r#c|sytt|jd}t|dksJ|rt |dSdS)Nz *.dist-infor r)r-rglobrrj)r rdist_info_candidatess r!_get_dist_info_dirz$_BuildMetaBackend._get_dist_info_dirsP!#D);$<$A$A-$PQ'(A---/Cs'*+MMr#c|j|}|rd|gng}dg||j|}t5|j|d||cdddS#1swYyxYw)Nreditable_wheelr)rrrcr)r rrnrrrprs r!rz _BuildMetaBackend.build_editabless**+=>08!8,bN$N)<)<_)MN ' ) ,,V_o   s AA!c$|j|Sr)rrs r!rz1_BuildMetaBackend.get_requires_for_build_editables00AAr#c&|j||Sr)rrs r!rz5_BuildMetaBackend.prepare_metadata_for_build_editables44   r#)rnrdrrzsetup.pyr\rjr)rnrd)rr rrjr$rj)rr rrjr$r)rr rnrd)r)) r Iterable[str]rstr | tuple[str, ...]rr rnrdrr)NN)rr rnrdrStrPath | None)rr rnrd)rrr$z str | None)r&r'r(rrrrrrrrrrrrrrr)r#r!rr"s:.>G .JJ ") 36    (OSP")PWW__RWW__\%BC SXX % HHOOAz * XXa[ "  % G <  8#CHHQK$CHHQK#CHHQK$CHHQKs 0C''(Drr)r&r'r(rr __classcell__)rs@r!rrs %%r#rceZdZdZdZdZdZy)rzAwheel.bdist_wheel is deprecated, please import it from setuptoolsz| Ensure that any custom bdist_wheel implementation is a subclass of setuptools.command.bdist_wheel.bdist_wheel. )i z&https://github.com/pypa/wheel/pull/631N)r&r'r(_SUMMARY_DETAILS _DUE_DATE_SEE_URLr)r#r!rr sRHHI7Hr#r)rQr rNr)@r __future__rr7rWrArkrrrrYr`collections.abcrrrpathlibrtypingrr r=r _pathr r _reqsrrr1distutils.utilrtyping_extensionsr__all__ BaseExceptionrdistr+r8r?rHrTr]rcrjr-rd__annotations__rfrrr_BACKENDrrrrrrrrrr)r#r!rs8# 77'% 2$+ %]% /:??///,  2 2 '  #73c49d6J0K+K#Ld#RSS |G|G~~ 1~ B%%/%%P8:8  'DD'DD#+#L#L "" "" "*"J"J&.&R&R#((% & r#