U e((@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z dddddd d gZ Gd d d e ZGd d d ejjZejddZddZddZddZGdddeZGdddeZeZejZejZejZejZejZeZdS)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 ||_dSN) specifiers)selfr r C/opt/hc_python/lib/python3.8/site-packages/setuptools/build_meta.py__init__4szSetupRequirementsError.__init__N)__name__ __module__ __qualname__rr r r rr 3sc@s&eZdZddZeejddZdS) DistributioncCstttt|}t|dSr )listmapstrrr )r r Zspecifier_listr r rfetch_build_eggs9szDistribution.fetch_build_eggsccs*tjj}|tj_z dVW5|tj_XdS)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 rr8srccs(tj}ddt_z dVW5|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. cSsdSr r )attrsr r rWz+no_install_setup_requires..N) setuptoolsZ_install_setup_requires)rr r rno_install_setup_requiresNs   r$csfddtDS)Ncs&g|]}tjtj|r|qSr )ospathisdirjoin).0nameZa_dirr r _sz1_get_immediate_subdirectories..)r%listdirr+r r+r_get_immediate_subdirectories^sr.csDfddt|D}z |\}Wntk r>tdYnX|S)Nc3s|]}|r|VqdSr endswithr)f extensionr r ds z'_file_with_extension..z[No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.)r%r- ValueError) directoryr4Zmatchingfiler r3r_file_with_extensioncs   r9cCs&tj|stdSttdt|S)Nz%from setuptools import setup; setup()open)r%r&existsioStringIOgetattrtokenizer: setup_scriptr r r_open_setup_scriptqs  rBc@s`eZdZddZddZdddZdd d Zdd d Zdd dZddZ dddZ dddZ dS)_BuildMetaBackendcCs|pi}|dg|S)N--global-option) setdefaultr config_settingsr r r _fix_config{s z_BuildMetaBackend._fix_configc Csz||}tjdddg|dt_z t|W5QRXWn,tk rt}z||j7}W5d}~XYnX|S)Negg_inforD)rHsysargvrr run_setupr r )r rG requirementser r r_get_build_requiress  z%_BuildMetaBackend._get_build_requiressetup.pyc CsD|}d}t|}|dd}W5QRXtt||dtdS)N__main__z\r\nz\nexec)rBreadreplacerScompilelocals)r rA__file__rr2coder r rrMs  z_BuildMetaBackend.run_setupNcCs||}|j|dgdS)NwheelrNrHrPrFr r rrs  z._BuildMetaBackend.get_requires_for_build_wheelcCs||}|j|gdS)Nr[r\rFr r rrs z._BuildMetaBackend.get_requires_for_build_sdistc Cstjdddd|gt_t|W5QRX|}ddt|D}t|dkrtt|dkrtj |t|d}q8t|dkst qq8||krt tj ||d|t j |dd|dS) NrIZ dist_infoz --egg-basecSsg|]}|dr|qS)z .dist-infor/r1r r rr,s zF_BuildMetaBackend.prepare_metadata_for_build_wheel..rT) ignore_errors)rKrLr$rMr%r-lenr.r&r(AssertionErrorshutilmovermtree)r metadata_directoryrGZdist_info_directoryZ dist_infosr r rrs6   z2_BuildMetaBackend.prepare_metadata_for_build_wheelc Cs||}tj|}tj|ddtj|d}tjdd|d|g|dt_t | W5QRXt ||}tj ||}tj |rt|ttj |||W5QRX|S)NT)exist_ok)dirrIz --dist-dirrD)rHr%r&abspathmakedirstempfileTemporaryDirectoryrKrLr$rMr9r(r;removerename)r Z setup_commandZresult_extensionZresult_directoryrGZ tmp_dist_dirZresult_basename result_pathr r r_build_with_temp_dirs(     z&_BuildMetaBackend._build_with_temp_dircCs|dgd||S)N bdist_wheelz.whlrm)r wheel_directoryrGrcr r rrs z_BuildMetaBackend.build_wheelcCs|dddgd||S)Nsdistz --formatsgztarz.tar.gzro)r sdist_directoryrGr r rrs  z_BuildMetaBackend.build_sdist)rQ)N)N)N)NN)N) rrrrHrPrMrrrrmrrr r r rrCys   " rCcs"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. rQc sttj}tjtj|}|tjkr6tjd|tjd}|tjd<ztt |j |dW5|tjdd<|tjd<XdS)Nrr@) rrKr&r%dirnamerfinsertrLsuperrtrM)r rAsys_pathZ script_dirZ sys_argv_0 __class__r rrMs     z!_BuildMetaLegacyBackend.run_setup)rQ)rrr__doc__rM __classcell__r r ryrrts rt) r{r<r%rKr?r`rrhr#r pkg_resourcesr__all__ BaseExceptionr distrrr$r.r9rBobjectrCrtZ_BACKENDrrrrrrr r r rsD   m)