a ˆåÏhp'ã@sødZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z gd¢Z Gdd„de ƒZGdd„dejjƒZejd d „ƒZd d „Zd d„Zdd„ZGdd„deƒZGdd„deƒZeƒZejZejZejZejZejZeƒZdS)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)Úparse_requirements)Úget_requires_for_build_sdistÚget_requires_for_build_wheelÚ prepare_metadata_for_build_wheelÚ build_wheelÚ build_sdistÚ __legacy__ÚSetupRequirementsErrorc@seZdZdd„ZdS)r cCs ||_dS©N)Ú specifiers)Úselfr ©r ú9/usr/lib/python3.9/site-packages/setuptools/build_meta.pyÚ__init__4szSetupRequirementsError.__init__N)Ú__name__Ú __module__Ú __qualname__rr r r rr 3sr c@s&eZdZdd„Zeejdd„ƒƒZdS)Ú DistributioncCstttt|ƒƒƒ}t|ƒ‚dSr )ÚlistÚmapÚstrrr )r r Zspecifier_listr r rÚfetch_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)Ú distutilsZcorer)ÚclsÚorigr r rÚpatch>s zDistribution.patchN)rrrrÚ classmethodÚ contextlibÚcontextmanagerrr r r rr8srccs.tj}dd„t_zdVW|t_n|t_0dS)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. cSsdSr r )Úattrsr r rÚWóz+no_install_setup_requires..N)Ú setuptoolsZ_install_setup_requires)rr r rÚno_install_setup_requiresNs  r#cs‡fdd„t ˆ¡DƒS)Ncs&g|]}tj tj ˆ|¡¡r|‘qSr )ÚosÚpathÚisdirÚjoin)Ú.0Úname©Za_dirr rÚ _sÿz1_get_immediate_subdirectories..©r$Úlistdirr*r r*rÚ_get_immediate_subdirectories^sr.cs"‡fdd„t |¡Dƒ}|\}|S)Nc3s|]}| ˆ¡r|VqdSr ©Úendswith©r(Úf©Ú extensionr rÚ ds ÿz'_file_with_extension..r,)Z directoryr4ZmatchingÚfiler r3rÚ_file_with_extensioncs  ÿr7cCs&tj |¡st d¡Sttdtƒ|ƒS)Nz%from setuptools import setup; setup()Úopen)r$r%ÚexistsÚioÚStringIOÚgetattrÚtokenizer8©Ú setup_scriptr r rÚ_open_setup_scriptls  r@c@s`eZdZdd„Zdd„Zddd„Zdd d „Zdd d „Zdd d„Zdd„Z ddd„Z ddd„Z dS)Ú_BuildMetaBackendcCs|pi}| dg¡|S)Nú--global-option)Ú setdefault©r Úconfig_settingsr r rÚ _fix_configvs z_BuildMetaBackend._fix_configc Cs�| |¡}tjdd…dg|dt_z4t ¡�| ¡Wdƒn1sP0YWn.tyŠ}z||j7}WYd}~n d}~00|S)NéZegg_inforB)rFÚsysÚargvrrÚ run_setupr r )r rEÚ requirementsÚer r rÚ_get_build_requires{s ÿ * z%_BuildMetaBackend._get_build_requiresúsetup.pycCsX|}d}t|ƒ� }| ¡ dd¡}Wdƒn1s60Ytt||dƒtƒƒdS)NÚ__main__z\r\nz\nÚexec)r@ÚreadÚreplacerPÚcompileÚlocals)r r?Ú__file__rr2Úcoder r rrJˆs  .z_BuildMetaBackend.run_setupNcCs| |¡}|j|dgd�S)NZwheel©rK©rFrMrDr r rr“s ÿz._BuildMetaBackend.get_requires_for_build_wheelcCs| |¡}|j|gd�S)NrWrXrDr r rr˜s z._BuildMetaBackend.get_requires_for_build_sdistcCsâtjdd…dd|gt_tƒ�| ¡Wdƒn1s>0Y|}dd„t |¡Dƒ}t|ƒdkr–tt|ƒƒdkr–tj  |t |¡d¡}qLt|ƒdksªJ‚qªqL||krÚt   tj  ||d¡|¡t j |dd�|dS) NrGZ dist_infoz --egg-basecSsg|]}| d¡r|‘qS)z .dist-infor/r1r r rr+¥s ÿzF_BuildMetaBackend.prepare_metadata_for_build_wheel..rT)Ú ignore_errors) rHrIr#rJr$r-Úlenr.r%r'ÚshutilÚmoveÚrmtree)r Úmetadata_directoryrEZdist_info_directoryZ dist_infosr r rrœs0 ÿ& ÿþÿþz2_BuildMetaBackend.prepare_metadata_for_build_wheelc Csê| |¡}tj |¡}tj|dd�tj|d��¦}tjdd…|d|g|dt_t ƒ�|  ¡Wdƒn1sz0Yt ||ƒ}tj  ||¡}tj  |¡r²t |¡t tj  ||¡|¡Wdƒn1sÜ0Y|S)NT)Úexist_ok)ÚdirrGz --dist-dirrB)rFr$r%ÚabspathÚmakedirsÚtempfileZTemporaryDirectoryrHrIr#rJr7r'r9ÚremoveÚrename)r Z setup_commandZresult_extensionZresult_directoryrEZ tmp_dist_dirZresult_basenameÚ result_pathr r rÚ_build_with_temp_dir¾s&  ÿþ&ÿ  4z&_BuildMetaBackend._build_with_temp_dircCs| dgd||¡S)NZ bdist_wheelz.whl©rg)r Zwheel_directoryrEr^r r rrÖs ÿz_BuildMetaBackend.build_wheelcCs| gd¢d||¡S)N)Zsdistz --formatsÚgztarz.tar.gzrh)r Zsdist_directoryrEr r rrÛs þz_BuildMetaBackend.build_sdist)rN)N)N)N)NN)N) rrrrFrMrJrrrrgrrr r r rrAts  ÿ "ÿ rAcs"eZdZdZd‡fdd„ Z‡ZS)Ú_BuildMetaLegacyBackendaOCompatibility 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. rNc s˜ttjƒ}tj tj |¡¡}|tjvr6tj d|¡tjd}|tjd<z.tt |ƒj |d�W|tjdd…<|tjd<n|tjdd…<|tjd<0dS)Nrr>) rrHr%r$ÚdirnameraÚinsertrIÚsuperrjrJ)r r?Zsys_pathZ script_dirZ sys_argv_0©Ú __class__r rrJìs     ÿÿ ÿz!_BuildMetaLegacyBackend.run_setup)rN)rrrÚ__doc__rJÚ __classcell__r r rnrrjás rj) rpr:r$rHr=r[rrcr"rZ pkg_resourcesrÚ__all__Ú BaseExceptionr Zdistrrr#r.r7r@ÚobjectrArjZ_BACKENDrrrrrrr r r rÚs6    m)