3

Q'íc'ã@s¸dZddlZddlZddlZddlZddlZddlZddlZGdd„deƒZ	Gdd„dej
jƒZddd	„Zd
d„Z
dd
„Zdd„Zddd„Zddd„Zddd„Zddd„Zddd„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.
éNc@seZdZdd„ZdS)ÚSetupRequirementsErrorcCs
||_dS)N)Ú
specifiers)Úselfr©rú;/tmp/pip-build-l_bcah40/setuptools/setuptools/build_meta.pyÚ__init__(szSetupRequirementsError.__init__N)Ú__name__Ú
__module__Ú__qualname__rrrrrr'src@s&eZdZdd„Zeejdd„ƒƒZdS)ÚDistributioncCst|ƒ‚dS)N)r)rrrrrÚfetch_build_eggs-szDistribution.fetch_build_eggsccs*tjj}|tj_z
dVWd|tj_XdS)zw
        Replace
        distutils.dist.Distribution with this class
        for the duration of this context.
        N)Ú	distutilsÚcorer)ÚclsÚorigrrrÚpatch0s

zDistribution.patchN)rr	r
rÚclassmethodÚ
contextlibÚcontextmanagerrrrrrr,srúsetup.pycCsH|}d}ttdtƒ|ƒ}|jƒjddƒ}|jƒtt||dƒtƒƒdS)NÚ__main__Úopenz\r\nz\nÚexec)	ÚgetattrÚtokenizerÚreadÚreplaceÚcloserÚcompileÚlocals)Zsetup_scriptÚ__file__rÚfÚcoderrrÚ
_run_setup@sr#cCs|pi}|jdgƒ|S)Nz--global-option)Ú
setdefault)Úconfig_settingsrrrÚ_fix_configKsr&cCs~t|ƒ}ddg}tjdd…dg|dt_ytjƒtƒWdQRXWn,tk
rx}z||j7}WYdd}~XnX|S)NÚ
setuptoolsÚwheeléÚegg_infoz--global-option)r&ÚsysÚargvrrr#rr)r%ÚrequirementsÚerrrÚ_get_build_requiresQs
r/cs‡fdd„tjˆƒDƒS)Ncs&g|]}tjjtjjˆ|ƒƒr|‘qSr)ÚosÚpathÚisdirÚjoin)Ú.0Úname)Úa_dirrrú
<listcomp>asz1_get_immediate_subdirectories.<locals>.<listcomp>)r0Úlistdir)r6r)r6rÚ_get_immediate_subdirectories`sr9cCst|ƒ}t|ƒS)N)r&r/)r%rrrÚget_requires_for_build_wheelesr:cCst|ƒ}t|ƒS)N)r&r/)r%rrrÚget_requires_for_build_sdistjsr;cCs¾tjdd…dd|gt_tƒ|}x`dd„tj|ƒDƒ}t|ƒdkrptt|ƒƒdkrptjj|tj|ƒdƒ}q&t|ƒdks€t	‚Pq&W||kr¶t
jtjj||dƒ|ƒt
j|dd|dS)	Nr)Z	dist_infoz
--egg-basecSsg|]}|jdƒr|‘qS)z
.dist-info)Úendswith)r4r!rrrr7usz4prepare_metadata_for_build_wheel.<locals>.<listcomp>rT)Ú
ignore_errors)
r+r,r#r0r8Úlenr9r1r3ÚAssertionErrorÚshutilÚmoveÚrmtree)Úmetadata_directoryr%Zdist_info_directoryZ
dist_infosrrrÚ prepare_metadata_for_build_wheelos$rDcCs‚t|ƒ}tjj|ƒ}tjdd…dg|dt_tƒ|dkrVtj|ƒtj	d|ƒdd„tj
|ƒDƒ}t|ƒdkszt‚|dS)Nr)Úbdist_wheelz--global-optionÚdistcSsg|]}|jdƒr|‘qS)z.whl)r<)r4r!rrrr7—szbuild_wheel.<locals>.<listcomp>r)
r&r0r1Úabspathr+r,r#r@rBÚcopytreer8r>r?)Zwheel_directoryr%rCÚwheelsrrrÚbuild_wheelŒs
rJcCs‚t|ƒ}tjj|ƒ}tjdd…dg|dt_tƒ|dkrVtj|ƒtj	d|ƒdd„tj
|ƒDƒ}t|ƒdkszt‚|dS)Nr)Úsdistz--global-optionrFcSsg|]}|jdƒr|‘qS)z.tar.gz)r<)r4r!rrrr7¨szbuild_sdist.<locals>.<listcomp>r)
r&r0r1rGr+r,r#r@rBrHr8r>r?)Zsdist_directoryr%ZsdistsrrrÚbuild_sdistžs
rL)r)N)N)N)NN)N)Ú__doc__r0r+rr@rr'r
Ú
BaseExceptionrrFrr#r&r/r9r:r;rDrJrLrrrrÚ<module>s&