3 (\$@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddddd d d gZ Gd d d eZGd ddejjZddZddZddZddZGdddeZGdddeZeZejZejZejZejZejZeZdS)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_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 q/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-rm6ck8ia/setuptools/setuptools/build_meta.py__init__3szSetupRequirementsError.__init__N)__name__ __module__ __qualname__rr r r rr 2sc@s&eZdZddZeejddZdS) DistributioncCstttt|}t|dS)N)listmapstrrr )r r Zspecifier_listr r rfetch_build_eggs8szDistribution.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 rpatch=s  zDistribution.patchN)rrrr classmethod contextlibcontextmanagerrr r r rr7srcCs,tjddkr(t|t r(|jtjS|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)sr r r_to_strMsr'csfddtjDS)Ncs&g|]}tjjtjj|r|qSr )ospathisdirjoin).0name)a_dirr r [sz1_get_immediate_subdirectories..)r(listdir)r.r )r.r_get_immediate_subdirectoriesZsr1cs"fddtj|D}|\}|S)Nc3s|]}|jr|VqdS)N)endswith)r,f) extensionr r asz'_file_with_extension..)r(r0) directoryr4Zmatchingfiler )r4r_file_with_extension_sr8cCs&tjj|stjdSttdt|S)Nz%from setuptools import setup; setup()open)r(r)existsioStringIOgetattrtokenizer9) setup_scriptr r r_open_setup_scripths  r@c@sXeZdZddZddZdddZdd d Zdd d Zdd dZdddZ dddZ dS)_BuildMetaBackendcCs|pi}|jdg|S)Nz--global-option) setdefault)r config_settingsr r r _fix_configrs z_BuildMetaBackend._fix_configcCsz|j|}tjdddg|dt_y tj|jWdQRXWn,tk rt}z||j7}WYdd}~XnX|S)Negg_infoz--global-option)rDr!argvrr run_setupr r )r rC requirementser r r_get_build_requiresws   z%_BuildMetaBackend._get_build_requiressetup.pyc CsD|}d}t|}|jjdd}WdQRXtt||dtdS)N__main__z\r\nz\nexec)r@readreplacerNcompilelocals)r r?__file__rr3coder r rrHs  z_BuildMetaBackend.run_setupNcCs|j|}|j|dgdS)Nwheel)rI)rDrK)r rCr r rrs z._BuildMetaBackend.get_requires_for_build_wheelcCs|j|}|j|gdS)N)rI)rDrK)r rCr r rrs z._BuildMetaBackend.get_requires_for_build_sdistcCstjddddt|gt_|j|}x`ddtj|D}t|dkrvtt|dkrvtjj |tj|d}q,t|dkst Pq,W||krt j tjj ||d|t j |dd|dS) NrEZ dist_infoz --egg-basecSsg|]}|jdr|qS)z .dist-info)r2)r,r3r r rr/szF_BuildMetaBackend.prepare_metadata_for_build_wheel..rT) ignore_errors)r!rGr'rHr(r0lenr1r)r+AssertionErrorshutilmovermtree)r metadata_directoryrCZdist_info_directoryZ dist_infosr r rrs& z2_BuildMetaBackend.prepare_metadata_for_build_wheelc Cs|j|}tjj|}t|dt}tjdddd|g|dt_|jt|d}tjj ||}tjj |rztj |tj tjj |||WdQRX|S)N)dirrE bdist_wheelz --dist-dirz--global-optionz.whl) rDr(r)abspathrr!rGrHr8r+r:removerename)r wheel_directoryrCr\Z tmp_dist_dirZwheel_basename wheel_pathr r rrs        z_BuildMetaBackend.build_wheelcCsR|j|}tjj|}tjdddddg|dd|gt_|jt|dS)NrEsdistz --formatsgztarz--global-optionz --dist-dirz.tar.gz)rDr(r)r_r!rGrHr8)r sdist_directoryrCr r rrs    z_BuildMetaBackend.build_sdist)rL)N)N)N)NN)N) rrrrDrKrHrrrrrr r r rrAps    rAcs"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. setup.pyc sbttj}tjjtjj|}|tjkr6tjjd|ztt|j |dWd|tjdd<XdS)Nr)r?) rr!r)r(dirnamer_insertsuperrgrH)r r?sys_pathZ script_dir) __class__r rrHs  z!_BuildMetaLegacyBackend.run_setup)rh)rrr__doc__rH __classcell__r r )rmrrgsrg) rnr;r(r!r>rYr setuptoolsrZsetuptools.py31compatr pkg_resourcesr__all__ BaseExceptionr distrr'r1r8r@objectrArgZ_BACKENDrrrrrr r r r rs@    f