o _a()@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z gdZ GdddeZGddde jjZejd d Zd d Zd dZddZejddZGdddeZGdddeZeZejZejZejZejZej 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)parse_requirements)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 r 7/usr/lib/python3/dist-packages/setuptools/build_meta.py__init__5s zSetupRequirementsError.__init__N)__name__ __module__ __qualname__rr r r rr 4s r c@s&eZdZddZeejddZdS) DistributioncCstttt|}t|r )listmapstrrr )r r specifier_listr r rfetch_build_eggs:szDistribution.fetch_build_eggsccs2tjj}|tj_z dVW|tj_dS|tj_w)zw Replace distutils.dist.Distribution with this class for the duration of this context. N) distutilscorer)clsorigr r rpatch?s zDistribution.patchN)rrrr classmethod contextlibcontextmanagerrr r r rr9s rccs.tj}ddt_z dVW|t_dS|t_w)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 rXsz+no_install_setup_requires..N) setuptools_install_setup_requires)rr r rno_install_setup_requiresOs  r%csfddtDS)Ncs&g|]}tjtj|r|qSr )ospathisdirjoin).0namea_dirr r `s z1_get_immediate_subdirectories..)r&listdirr,r r,r_get_immediate_subdirectories_sr0cs<fddt|D}z|\}W|Stytdw)Nc3s|] }|r|VqdSr endswithr*f extensionr r es z'_file_with_extension..z[No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.)r&r/ ValueError) directoryr6matchingfiler r5r_file_with_extensionds  r<cCs&tj|s tdSttdt|S)Nz%from setuptools import setup; setup()open)r&r'existsioStringIOgetattrtokenizer= setup_scriptr r r_open_setup_scriptrs  rEccsBttdddVWddS1swYdS)Nignorezsetup.py install is deprecated)warningscatch_warningsfilterwarningsr r r rsuppress_known_deprecationzs   "rJc@sfeZdZddZddZdddZdd d Zdd d Z dd dZddZ  dddZ dddZ dS)_BuildMetaBackendcCs|pi}|dg|S)N--global-option) setdefaultr config_settingsr r r _fix_configs z_BuildMetaBackend._fix_configc Cs||}tjdddg|dt_zt|WdW|S1s*wYW|StyI}z ||j7}WYd}~|Sd}~ww)Negg_inforL)rPsysargvrr run_setupr r )r rO requirementser r r_get_build_requiress    z%_BuildMetaBackend._get_build_requiressetup.pycCsX|}d}t|}|dd}Wdn1swYtt||dtdS)N__main__z\r\nz\nexec)rEreadreplacer[compilelocals)r rD__file__rr4coder r rrUs  z_BuildMetaBackend.run_setupNcCs||}|j|dgdS)NwheelrVrPrXrNr r rrs z._BuildMetaBackend.get_requires_for_build_wheelcCs||}|j|gdS)NrcrdrNr r rrs z._BuildMetaBackend.get_requires_for_build_sdistcCstjdddd|gt_t |Wdn1swY|} ddt|D}t|dkrLtt|dkrLtj |t|d}q&t|dksTJ ||krmt tj ||d|t j |dd|dS) NrQ dist_infoz --egg-baseTcSsg|] }|dr|qS)z .dist-infor1r3r r rr.s zF_BuildMetaBackend.prepare_metadata_for_build_wheel..r) ignore_errors) rSrTr%rUr&r/lenr0r'r)shutilmovermtree)r metadata_directoryrOdist_info_directory dist_infosr r rrs0   z2_BuildMetaBackend.prepare_metadata_for_build_wheelc Cs||}tj|}tj|ddtj|dT}tjdd|d|g|dt_t | Wdn1s=wYt ||}tj ||}tj |rYt|ttj |||Wd|S1sowY|S)NT)exist_ok)dirrQz --dist-dirrL)rPr&r'abspathmakedirstempfileTemporaryDirectoryrSrTr%rUr<r)r>removerename)r setup_commandresult_extensionresult_directoryrO tmp_dist_dirresult_basename result_pathr r r_build_with_temp_dirs.      z&_BuildMetaBackend._build_with_temp_dircCs<t|dgd||WdS1swYdS)N bdist_wheelz.whl)rJr|)r wheel_directoryrOrkr r rrs  $z_BuildMetaBackend.build_wheelcCs|gdd||S)N)sdistz --formatsgztarz.tar.gz)r|)r sdist_directoryrOr r rrs z_BuildMetaBackend.build_sdistrYr )NN) rrrrPrXrUrrrr|rrr r r rrKs  " rKcs"eZdZdZdfdd ZZS)_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. rYc sttj}tjtj|}|tjvrtjd|tjd}|tjd<ztt |j |dW|tjdd<|tjd<dS|tjdd<|tjd<w)NrrC) rrSr'r&dirnamerpinsertrTsuperrrU)r rDsys_path script_dir sys_argv_0 __class__r rrUs     z!_BuildMetaLegacyBackend.run_setupr)rrr__doc__rU __classcell__r r rrrs r)"rr?r&rSrBrhrrrrGr#r pkg_resourcesr__all__ BaseExceptionr distrr r%r0r<rErJobjectrKr_BACKENDrrrrrrr r r rs>    n)