3 ]'@sdZddlZddlZddlZddlZddlZddlZddlZGdddeZ Gdddej j Z ddd Z d d Z d d ZddZdddZdddZdddZdddZdddZdS) 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@seZdZddZdS)SetupRequirementsErrorcCs ||_dS)N) specifiers)selfrr;/tmp/pip-build-8jg9gmni/setuptools/setuptools/build_meta.py__init__(szSetupRequirementsError.__init__N)__name__ __module__ __qualname__rrrrrr'src@s&eZdZddZeejddZdS) DistributioncCs t|dS)N)r)rrrrrfetch_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 )clsorigrrrpatch0s  zDistribution.patchN)rr r r classmethod contextlibcontextmanagerrrrrrr ,sr setup.pycCsH|}d}ttdt|}|jjdd}|jtt||dtdS)N__main__openz\r\nz\nexec) getattrtokenizerreadreplaceclosercompilelocals)Z setup_script__file__rfcoderrr _run_setup@s r#cCs|pi}|jdg|S)Nz--global-option) setdefault)config_settingsrrr _fix_configKs r&cCs~t|}ddg}tjdddg|dt_ytj tWdQRXWn,tk rx}z||j7}WYdd}~XnX|S)N setuptoolswheelegg_infoz--global-option)r&sysargvr rr#rr)r% requirementserrr_get_build_requiresQs  r/csfddtjDS)Ncs&g|]}tjjtjj|r|qSr)ospathisdirjoin).0name)a_dirrr asz1_get_immediate_subdirectories..)r0listdir)r6r)r6r_get_immediate_subdirectories`sr9cCst|}t|S)N)r&r/)r%rrrget_requires_for_build_wheelesr:cCst|}t|S)N)r&r/)r%rrrget_requires_for_build_sdistjsr;cCstjdddd|gt_t|}x`ddtj|D}t|dkrptt|dkrptjj|tj|d}q&t|dkst Pq&W||krt j tjj||d|t j |dd|dS) Nr)Z dist_infoz --egg-basecSsg|]}|jdr|qS)z .dist-info)endswith)r4r!rrrr7usz4prepare_metadata_for_build_wheel..rT) ignore_errors) r+r,r#r0r8lenr9r1r3AssertionErrorshutilmovermtree)metadata_directoryr%Zdist_info_directoryZ dist_infosrrr prepare_metadata_for_build_wheelos$ rDcCst|}tjj|}tjdddg|dt_t|dkrVtj|tj d|ddtj |D}t |dkszt |dS)Nr) bdist_wheelz--global-optiondistcSsg|]}|jdr|qS)z.whl)r<)r4r!rrrr7szbuild_wheel..r) r&r0r1abspathr+r,r#r@rBcopytreer8r>r?)Zwheel_directoryr%rCwheelsrrr build_wheels    rJcCst|}tjj|}tjdddg|dt_t|dkrVtj|tj d|ddtj |D}t |dkszt |dS)Nr)sdistz--global-optionrFcSsg|]}|jdr|qS)z.tar.gz)r<)r4r!rrrr7szbuild_sdist..r) r&r0r1rGr+r,r#r@rBrHr8r>r?)Zsdist_directoryr%Zsdistsrrr build_sdists    rL)r)N)N)N)NN)N)__doc__r0r+rr@rr'r BaseExceptionrrFr r#r&r/r9r:r;rDrJrLrrrrs&