a c&@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl mZgdZGdddeZGd d d ejjZd d Zd dZddZddZGdddeZGdddeZeZejZejZejZejZej Z eZ!dS)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)TemporaryDirectory)parse_requirements)makedirs)get_requires_for_build_sdistget_requires_for_build_wheel prepare_metadata_for_build_wheel build_wheel build_sdist __legacy__SetupRequirementsErrorc@seZdZddZdS)r cCs ||_dSN) specifiers)selfr rb/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/setuptools/build_meta.py__init__4szSetupRequirementsError.__init__N)__name__ __module__ __qualname__rrrrrr 3sr c@s&eZdZddZeejddZdS) DistributioncCstttt|}t|dSr )listmapstrrr )rr Zspecifier_listrrrfetch_build_eggs9szDistribution.fetch_build_eggsccs2tjj}|tj_zdVW|tj_n |tj_0dS)zw Replace distutils.dist.Distribution with this class for the duration of this context. N) distutilscorer)clsorigrrrpatch>s zDistribution.patchN)rrrr classmethod contextlibcontextmanagerrrrrrr8srcCs*tjddkr&t|ts&|tS|S)z Convert a filename to a string (on Python 2, explicitly a byte string, not Unicode) as distutils checks for the exact type str. r)sys version_info isinstancerencodegetfilesystemencoding)srrr_to_strNsr)csfddtDS)Ncs&g|]}tjtj|r|qSr)ospathisdirjoin).0nameZa_dirrr \sz1_get_immediate_subdirectories..r*listdirr0rr0r_get_immediate_subdirectories[sr4cs"fddt|D}|\}|S)Nc3s|]}|r|VqdSr endswithr.f extensionrr as z'_file_with_extension..r2) directoryr:Zmatchingfilerr9r_file_with_extension`s  r>cCs&tj|stdSttdt|S)Nz%from setuptools import setup; setup()open)r*r+existsioStringIOgetattrtokenizer? setup_scriptrrr_open_setup_scriptis  rGc@s`eZdZddZddZdddZdd d Zdd d Zdd dZddZ dddZ dddZ dS)_BuildMetaBackendcCs|pi}|dg|S)N--global-option) setdefaultrconfig_settingsrrr _fix_configss z_BuildMetaBackend._fix_configc Cs||}tjdddg|dt_z4t|Wdn1sP0YWn.ty}z||j7}WYd}~n d}~00|S)Negg_inforI)rMr#argvrr run_setupr r )rrL requirementserrr_get_build_requiresxs  * z%_BuildMetaBackend._get_build_requiressetup.pycCsX|}d}t| }|dd}Wdn1s60Ytt||dtdS)N__main__z\r\nz\nexec)rGreadreplacerWcompilelocals)rrF__file__rr8coderrrrQs  .z_BuildMetaBackend.run_setupNcCs||}|j|dgdS)NwheelrRrMrTrKrrrrs z._BuildMetaBackend.get_requires_for_build_wheelcCs||}|j|gdS)Nr_r`rKrrrrs z._BuildMetaBackend.get_requires_for_build_sdistcCstjddddt|gt_||}ddt|D}t|dkrttt|dkrttj |t|d}q*t|dksJqq*||krt tj ||d|t j |dd|dS) NrNZ dist_infoz --egg-basecSsg|]}|dr|qS)z .dist-infor5r7rrrr1s zF_BuildMetaBackend.prepare_metadata_for_build_wheel..rT) ignore_errors) r#rPr)rQr*r3lenr4r+r-shutilmovermtree)rmetadata_directoryrLZdist_info_directoryZ dist_infosrrrrs, z2_BuildMetaBackend.prepare_metadata_for_build_wheelcCs||}tj|}t|ddt|d}tjdd|d|g|dt_|t ||}tj ||}tj |rt |t tj |||Wdn1s0Y|S)NT)exist_ok)dirrNz --dist-dirrI)rMr*r+abspathrrr#rPrQr>r-r@removerename)rZ setup_commandZresult_extensionZresult_directoryrLZ tmp_dist_dirZresult_basename result_pathrrr_build_with_temp_dirs        4z&_BuildMetaBackend._build_with_temp_dircCs|dgd||S)N bdist_wheelz.whlrm)rwheel_directoryrLrfrrrrs z_BuildMetaBackend.build_wheelcCs|gdd||S)N)sdistz --formatsgztarz.tar.gzro)rsdist_directoryrLrrrr s z_BuildMetaBackend.build_sdist)rU)N)N)N)NN)N) rrrrMrTrQrrrrmrr rrrrrHqs    rHcs"eZdZdZdfdd ZZS)_BuildMetaLegacyBackendaCCompatibility backend for setuptools This is a version of setuptools.build_meta that endeavors to maintain backwards compatibility with pre-PEP 517 modes of invocation. It exists as a temporary bridge between the old packaging mechanism and the new packaging mechanism, and will eventually be removed. rUc sttj}tjtj|}|tjvr6tjd|tjd}|tjd<z.tt |j |dW|tjdd<|tjd<n|tjdd<|tjd<0dS)NrrE) rr#r+r*dirnameriinsertrPsuperrtrQ)rrFsys_pathZ script_dirZ sys_argv_0 __class__rrrQs      z!_BuildMetaLegacyBackend.run_setup)rU)rrr__doc__rQ __classcell__rrryrrtsrt)"r{rAr*r#rDrcr setuptoolsrZsetuptools.py31compatr pkg_resourcesrZpkg_resources.py31compatr__all__ BaseExceptionr distrr)r4r>rGobjectrHrtZ_BACKENDrrrrr r rrrrs6     h%