3 e()@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z dddddd d gZ Gd d d eZGd d d e jjZejddZddZddZddZejddZGdddeZGdddeZeZejZejZejZejZej 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_requirementsget_requires_for_build_sdistget_requires_for_build_wheel prepare_metadata_for_build_wheel build_wheel build_sdist __legacy__SetupRequirementsErrorc@seZdZddZdS)r cCs ||_dS)N) specifiers)selfr r ;/tmp/pip-build-vlmub77e/setuptools/setuptools/build_meta.py__init__5szSetupRequirementsError.__init__N)__name__ __module__ __qualname__rr r r r r 4sc@s&eZdZddZeejddZdS) DistributioncCstttt|}t|dS)N)listmapstrrr )r r Zspecifier_listr r r fetch_build_eggs:szDistribution.fetch_build_eggsc cs*tjj}|tj_z dVWd|tj_XdS)zw Replace distutils.dist.Distribution with this class for the duration of this context. N) distutilscorer)clsorigr r r patch?s  zDistribution.patchN)rrrr classmethod contextlibcontextmanagerrr r r r r9src cs(tj}ddt_z dVWd|t_XdS)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. cSsdS)Nr )attrsr r r Xsz+no_install_setup_requires..N) setuptoolsZ_install_setup_requires)rr r r no_install_setup_requiresOs   r"csfddtjDS)Ncs&g|]}tjjtjj|r|qSr )ospathisdirjoin).0name)a_dirr r `sz1_get_immediate_subdirectories..)r#listdir)r)r )r)r _get_immediate_subdirectories_sr,c sDfddtj|D}y |\}Wntk r>tdYnX|S)Nc3s|]}|jr|VqdS)N)endswith)r'f) extensionr r fsz'_file_with_extension..z[No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.)r#r+ ValueError) directoryr/Zmatchingfiler )r/r _file_with_extensionds  r4cCs&tjj|stjdSttdt|S)Nz%from setuptools import setup; setup()open)r#r$existsioStringIOgetattrtokenizer5) setup_scriptr r r _open_setup_scriptrs  r<c cs*tjtjdddVWdQRXdS)Nignorezsetup.py install is deprecated)warningscatch_warningsfilterwarningsr r r r suppress_known_deprecationzs  rAc@s`eZdZddZddZdddZdd d Zdd d Zdd dZddZ dddZ dddZ dS)_BuildMetaBackendcCs|pi}|jdg|S)Nz--global-option) setdefault)r config_settingsr r r _fix_configs z_BuildMetaBackend._fix_configcCsz|j|}tjdddg|dt_y tj|jWdQRXWn,tk rt}z||j7}WYdd}~XnX|S)Negg_infoz--global-option)rEsysargvrr run_setupr r )r rD requirementser r r _get_build_requiress   z%_BuildMetaBackend._get_build_requiressetup.pyc CsD|}d}t|}|jjdd}WdQRXtt||dtdS)N__main__z\r\nz\nexec)r<readreplacerPcompilelocals)r r;__file__rr.coder r r rJs  z_BuildMetaBackend.run_setupNcCs|j|}|j|dgdS)Nwheel)rK)rErM)r rDr r r rs z._BuildMetaBackend.get_requires_for_build_wheelcCs|j|}|j|gdS)N)rK)rErM)r rDr r r rs z._BuildMetaBackend.get_requires_for_build_sdistc Cstjdddd|gt_t|jWdQRX|}x`ddtj|D}t|dkrtt|dkrtjj |tj|d}q:t|dkst Pq:W||krt j tjj ||d|t j |dd|dS) NrFZ dist_infoz --egg-basecSsg|]}|jdr|qS)z .dist-info)r-)r'r.r r r r*szF_BuildMetaBackend.prepare_metadata_for_build_wheel..rT) ignore_errors)rHrIr"rJr#r+lenr,r$r&AssertionErrorshutilmovermtree)r metadata_directoryrDZdist_info_directoryZ dist_infosr r r rs(  z2_BuildMetaBackend.prepare_metadata_for_build_wheelcCs|j|}tjj|}tj|ddtj|d}tjdd|d|g|dt_t |j WdQRXt ||}tjj ||}tjj |rtj|tjtjj |||WdQRX|S)NT)exist_ok)dirrFz --dist-dirz--global-option)rEr#r$abspathmakedirstempfileTemporaryDirectoryrHrIr"rJr4r&r6removerename)r Z setup_commandZresult_extensionZresult_directoryrDZ tmp_dist_dirZresult_basenameZ result_pathr r r _build_with_temp_dirs      z&_BuildMetaBackend._build_with_temp_dirc Cs$t|jdgd||SQRXdS)N bdist_wheelz.whl)rArg)r Zwheel_directoryrDr^r r r rs z_BuildMetaBackend.build_wheelcCs|jdddgd||S)Nsdistz --formatsgztarz.tar.gz)rg)r Zsdist_directoryrDr r r rs z_BuildMetaBackend.build_sdist)rN)N)N)N)NN)N) rrrrErMrJrrrrgrrr r r r rBs   ! rBcs"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. setup.pyc sttj}tjjtjj|}|tjkr6tjjd|tjd}|tjd<ztt |j |dWd|tjdd<|tjd<XdS)Nr)r;) rrHr$r#dirnamerainsertrIsuperrkrJ)r r;sys_pathZ script_dirZ sys_argv_0) __class__r r rJs    z!_BuildMetaLegacyBackend.run_setup)rl)rrr__doc__rJ __classcell__r r )rqr rks rk)"rrr7r#rHr:r[rrcr>r!r pkg_resourcesr__all__ BaseExceptionr distrrr"r,r4r<rAobjectrBrkZ_BACKENDrrrrrrr r r r sD n)