_d{N,dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZmZmZddlZddlZddlmZddlmZddlmZdd l mZdd lmZgd Zej<d d j?Z de jCddvZ"Gdde#Z$GddejJjLZ&ejNdZ(dZ)dZ*dZ+ejNdZ,ee e-ee-ee-dffZ. GddZ/Gdde/Z0Gdde0Z1e0Z2e2jfZ3e2jhZ4e2jjZ5e2jlZ6e2jnZ7e"s$e2jpZ8e2jrZ9e2jtZ:e1Z;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 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. N)Path)DictIteratorListOptionalUnion)errors) same_path) parse_strings)SetuptoolsDeprecationWarning) strtobool) 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__SetupRequirementsErrorSETUPTOOLS_ENABLE_FEATURESzlegacy-editable_-ceZdZdZy)rc||_yN) specifiers)selfr s 7/usr/lib/python3/dist-packages/setuptools/build_meta.py__init__zSetupRequirementsError.__init__Ds $N)__name__ __module__ __qualname__r#r$r"rrCs%r$rc@eZdZdZeej dZy) Distributionc@tt|}t|r)listr r)r!r specifier_lists r"fetch_build_eggszDistribution.fetch_build_eggsIsmJ78$^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.patchNsC~~**&) # / *.INN '$INN 's0A'A A' A$$A'N)r%r&r'r. classmethod contextlibcontextmanagerr4r(r$r"r*r*Hs)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..gsr$N) setuptools_install_setup_requires)r3s r"no_install_setup_requiresr>^s3  - -D);J&2 -1 *T *sA0 A =Ac tj|Dcgc]B}tjjtjj ||sA|Dc}Scc}wr)oslistdirpathisdirjoin)a_dirnames r"_get_immediate_subdirectoriesrGnsGE* bggmmBGGLLPTz'_file_with_extension..usJaAJJy4IJs!!z[No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.)r@rA ValueError) directoryrMmatchingfiles ` r"_file_with_extensionrStsLJ2::i0JH  K   8   s'<ctjj|stjdSt t dt|S)Nz%from setuptools import setup; setup()open)r@rBexistsioStringIOgetattrtokenizerU setup_scripts r"_open_setup_scriptr]s8 77>>, '{{CDD *78VT *< 88r$c#Ktj5tjddddddy#1swYyxYww)Nignorezsetup.py install is deprecated)warningscatch_warningsfilterwarningsr(r$r"suppress_known_deprecationrcs:  "*JK sA; AAAceZdZdZdededeefdZdZdede efdZ dede efdZ dede efd Z dede efd Z y ) _ConfigSettingsTranslatorzTranslate ``config_settings`` into distutils-style command arguments. Only a limited number of options is currently supported. keyconfig_settingsreturnc|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!rfrgcfgoptss r" _get_configz%_ConfigSettingsTranslator._get_configs=$#wws|!r$.tS$9u{{4 CtCr$cdtjjjD}|Dchc]}|D]}|s| c}}Scc}}w)z>Global options accepted by setuptools (e.g. quiet or verbose).c3&K|] }|dd yw)Nr()rKopts r"rNzB_ConfigSettingsTranslator._valid_global_options..sRs3r7Rs)r<distr*global_options)r!optionslong_and_shortflags r"_valid_global_optionsz/_ConfigSettingsTranslator._valid_global_optionss?Rjoo&B&B&Q&QR+2V~VtQUVVVVs AAc#K|xsi}hd}d|vsd|vrIt|jdxs|jdxsd}|j|vrdndd|vsd|vrIt|jdxs|jdxsd}|j|vrdnd|j|j d |}fd |DEd {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--quiet--global-optionc3JK|]}|jdvs|yw)rN)strip)rKargvalids r"rNz9_ConfigSettingsTranslator._global_args..s CC399S>U+BCCs##N)rlrjlowerr{rq)r!rgrofalseylevelargsrs @r" _global_argsz&_ConfigSettingsTranslator._global_argss*#,  {c1 *Icggk.BIcJE ;;=F24 = c>Y#-(ECGGI,>E#FE ;;=F24 =**, 1?CC4CCCsCC( 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-daterz --tag-datez --no-datez tag-buildz --tag-buildN)rrl)r!rgrovals 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)rjrl)r!rgromodes r"_editable_argsz(_ConfigSettingsTranslator._editable_argssF#ww'C377?+C c$i(((s>AAAc#*K|jd|}|j}g}|D]+}|jd|vs|j||-|jd|Ed{|rt j dd|dd yy7$w) 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'] >>> warnings.simplefilter('error', SetuptoolsDeprecationWarning) >>> list(fn({'--global-option': 'foo'})) # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): SetuptoolsDeprecationWarning: ...arguments given via `--global-option`... rrz--build-optionNz7Incompatible `config_settings` passed to build backend.z The arguments z were given via `--global-option`. Please use `--build-option` instead, `--global-option` is reserved for flags like `--verbose` or `--quiet`. )i )due_date)rqr{rappendr emit)r!rgr global_optsbad_argsrs r"_arbitrary_argsz)_ConfigSettingsTranslator._arbitrary_args s. 1?C002  Cyy~[0$   ##$4oFFF  ( - -I'l+ '   Gs=B,B,B-%BN)r%r&r'__doc__rl_ConfigSettingsrrqr{rr)_ConfigSettingsTranslator__dist_info_argsrrr(r$r"reres DsD_DcD,W DO D DD>>HSM>4)o)(3-) ++8C=+r$receZdZdZddZddZddZdededefd Zdedede fd Z dd Z d Z dd Z ddZdeedeefdZes ddZddZ ddZyy)_BuildMetaBackendcLgtjdd|j|d|j|t_ tj 5|j ddd|S#1swY|SxYw#t$r}||jz }Yd}~|Sd}~wwxYw)Nr egg_info) sysargvrrr*r4 run_setuprr )r!rg requirementses r"_get_build_requiresz%_BuildMetaBackend._get_build_requires<s XXbq\    /    ! !/ 2    )##% !  !   ! & ) ALL (L )s6BA3)B3A=8B=B B# BB#cftjj|}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) r@rBabspathr]readreplaceexeclocals SystemExitcoder r)r!r\__file__r%rLrrs r"rz_BuildMetaBackend.run_setupKs77??<0  ) 4Q668##GU3D 4  vx  4 4  vv ( - -HJ+    s#!A,A8,A58 B0%B++B0Nc*|j|dgS)Nwheelrrr!rgs r"rz._BuildMetaBackend.get_requires_for_build_wheelbs''wi'PPr$c(|j|gS)Nrrrs r"rz._BuildMetaBackend.get_requires_for_build_sdistes''b'IIr$metadata_directorysuffixrhc|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 parentshutilmoverlrF)r!rrinfo_dirs r"_bubble_up_info_directoryz+_BuildMetaBackend._bubble_up_info_directoryhsC,,-?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 )r@walkrJlenrr InternalError) r!rrrdirsrrL candidatesmsgs r"rz&_BuildMetaBackend._find_info_directoryus!ww'9: 3OFD!%)@QZZ-?!@J@:!#s4yA~:!+Sy@R-SS+FJqM22  3F8/0B/CD""3''As B#B#cgtjdd|j|dd|dt_t5|j ddd|j |d|j |dS#1swY-xYw)Nr dist_infoz --output-dirz--keep-egg-infoz .egg-infoz .dist-info)rrrr>rrr!rrgs r"rz2_BuildMetaBackend.prepare_metadata_for_build_wheels XXbq\    /          ' (  NN   &&'9;G--.@,OO   s A??Bctjj|}tj|dd|d}t j di|5}gt jdd|j||d||j|t _t5|jdddt||}tjj||}tjj|rtj|tj tjj|||ddd|S#1swYxYw#1swYSxYw)NT)exist_okz.tmp-)prefixdirr z --dist-dirr()r@rBrmakedirstempfileTemporaryDirectoryrrrrr>rrSrDrVremoverename) r! setup_commandresult_extensionresult_directoryrg temp_opts tmp_dist_dirresult_basename result_paths r"_build_with_temp_dirz&_BuildMetaBackend._build_with_temp_dirsO77??+;< $t4&/?@  ( ( 59 5 P"1""?3    %%o6 CH+, !  !3WW__RWW__\%BC SXX % HHOOAz * XXa[ "  % )4 : : U#CHHQK$CHHQK#CHHQK$CHHQKs 0C++(Dr)r%r&r'rr __classcell__)rs@r"rrs %%r$r)rGrSr]rcrlrrerr_BACKENDrrrrrrrrrr(r$r"rs8  88 2$ 'RYY'CRHNNP#'A'I'I#s'SS%]% /:??///,  2 2 9  4U3S 4+?%@ @AB YYx`1`F%%/%%R  'DD'DD#+#L#L "" "" &.&N&N#*2*V*V',,N% & r$