zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
U
H=®dö ã@s`dZddlmZddlmZddlZddlZddlZddlmZddl    Z    ddl
Z
ddl Z ddl Z e j ddkr€dd„Zd    d
„Znd d„Zd d
„ZGd d„deƒZGdd„deƒZGdd„deƒZdd„Zdd„Zdd„Zdd„ZdZdd„Zdd„Zd d!„Zd/d"d#„Zd$d%„ZGd&d'„d'eƒZGd(d)„d)eƒZd*d+„Z ddd#d%d+hZ!d,d-„Z"e#d.kr\e"ƒdS)0agThis is invoked in a subprocess to call the build backend hooks.
 
It expects:
- Command line args: hook_name, control_dir
- Environment variables:
      PEP517_BUILD_BACKEND=entry.point:spec
      PEP517_BACKEND_PATH=paths (separated with os.pathsep)
- control_dir/input.json:
  - {"kwargs": {...}}
 
Results:
- control_dir/output.json
  - {"return_val": ...}
é)Úglob)Ú import_moduleN)Újoinéc    Ks.t|ddd}tj||f|ŽW5QRXdS)NÚwúutf-8©Úencoding©ÚopenÚjsonÚdump©ÚobjÚpathÚkwargsÚf©rúUD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/pep517/_in_process.pyÚ
write_json!src
Cs0t|ddd}t |¡W5QR£SQRXdS)NÚrrr©r r Úload©rrrrrÚ    read_json%src    Ks2t|dƒ}tj||fddi|—ŽW5QRXdS)NÚwbr    rr
rrrrr+s c
Cs,t|dƒ}t |¡W5QR£SQRXdS)NÚrbrrrrrr/s c@seZdZdZdd„ZdS)ÚBackendUnavailablez&Raised if we cannot import the backendcCs
||_dS©N©Ú    traceback©Úselfr rrrÚ__init__6szBackendUnavailable.__init__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__r#rrrrr4src@seZdZdZdd„ZdS)ÚBackendInvalidz Raised if the backend is invalidcCs
||_dSr)Úmessage)r"r*rrrr#<szBackendInvalid.__init__Nr$rrrrr):sr)c@seZdZdZdS)Ú HookMissingzARaised if a hook is missing and we are not executing the fallbackN©r%r&r'r(rrrrr+@sr+cCs<tj tj |¡¡}tj tj |¡¡}tj ||g¡|kS)z5Test if a file is located within the given directory.)ÚosrÚnormcaseÚabspathÚ commonprefix)ÚfilenameÚ    directoryrrrÚ contained_inDsr3cs¶tj d¡}|r*| tj¡}|tjdd…<tjd}| d¡\}}}z t|ƒ‰Wn t    k
rpt
t   ¡ƒ‚YnX|r”t ‡fdd„|Dƒƒs”tdƒ‚|r²| d    ¡D]}tˆ|ƒ‰q¢ˆS)
zFind and load the build backendÚPEP517_BACKEND_PATHNrÚPEP517_BUILD_BACKENDú:c3s|]}tˆj|ƒVqdSr)r3Ú__file__)Ú.0r©rrrÚ    <genexpr>[sÿz!_build_backend.<locals>.<genexpr>z(Backend was not loaded from backend-pathÚ.)r-ÚenvironÚgetÚsplitÚpathsepÚsysrÚ    partitionrÚ ImportErrorrr Ú
format_excÚanyr)Úgetattr)Ú backend_pathZextra_pathitemsÚepZmod_pathÚ_Zobj_pathZ    path_partrr9rÚ_build_backendKs&  
  þ rIcCs6tƒ}z
|j}Wntk
r(gYSX||ƒSdS©zfInvoke the optional get_requires_for_build_wheel hook
 
    Returns [] if the hook is not defined.
    N)rIÚget_requires_for_build_wheelÚAttributeError©Úconfig_settingsÚbackendÚhookrrrrKgs 
 
rKcCsJtƒ}z
|j}Wn*tk
r:|s*tƒ‚t|||ƒYSX|||ƒSdS)zÈInvoke optional prepare_metadata_for_build_wheel
 
    Implements a fallback by building a wheel if the hook isn't defined,
    unless _allow_fallback is False in which case HookMissing is raised.
    N)rIÚ prepare_metadata_for_build_wheelrLr+Ú_get_wheel_metadata_from_wheel)Úmetadata_directoryrNÚ_allow_fallbackrOrPrrrrQus
ÿ
rQZPEP517_ALREADY_BUILT_WHEELcCs@g}| ¡D]}t d|¡}|r | |¡q |r4|Stdƒ‚dS)z6Identify the .dist-info folder inside a wheel ZipFile.z[^/\\]+-[^/\\]+\.dist-info/z#No .dist-info folder found in wheelN)ÚnamelistÚreÚmatchÚappendÚ    Exception)Zwhl_zipÚresrÚmrrrÚ_dist_info_files‹s   r\c    Cs‚ddlm}| ||¡}ttj |t¡dƒW5QRXtj ||¡}||ƒ}t|ƒ}|j    ||dW5QRX|d 
d¡dS)zBuild a wheel and extract the metadata from it.
 
    Fallback for when the build backend does not
    define the 'get_wheel_metadata' hook.
    r)ÚZipFiler)rÚmembersú/) Úzipfiler]Ú build_wheelr r-rrÚWHEEL_BUILT_MARKERr\Ú
extractallr>)rOrSrNr]Z whl_basenameZwhl_fileZzipfZ    dist_inforrrrR—s  
 
rRcCsl|sdStj |¡}tj t|tƒ¡s*dSttj |d¡ƒ}|sLtdƒdSt    |ƒdkrdtdƒdS|dS)zHCheck for a wheel already built during the get_wheel_metadata hook.
    Nz*.whlz+Found wheel built marker, but no .whl filesézHFound multiple .whl files; unspecified behaviour. Will call build_wheel.r)
r-rÚdirnameÚisfileÚpjoinrbrrÚprintÚlen)rSZmetadata_parentZ    whl_filesrrrÚ_find_already_built_wheelªs  rjcCs4t|ƒ}|r$t ||¡tj |¡Stƒ |||¡S)z»Invoke the mandatory build_wheel hook.
 
    If a wheel was already built in the
    prepare_metadata_for_build_wheel fallback, this
    will copy it rather than rebuilding the wheel.
    )rjÚshutilÚcopy2r-rÚbasenamerIra)Úwheel_directoryrNrSZ prebuilt_whlrrrraÀs  
ÿracCs6tƒ}z
|j}Wntk
r(gYSX||ƒSdSrJ)rIÚget_requires_for_build_sdistrLrMrrrroÐs 
 
roc@seZdZdZdS)Ú_DummyExceptionz(Nothing should ever raise this exceptionNr,rrrrrpÞsrpc@seZdZdZdd„ZdS)ÚGotUnsupportedOperationz9For internal use when backend raises UnsupportedOperationcCs
||_dSrrr!rrrr#äsz GotUnsupportedOperation.__init__Nr$rrrrrqâsrqc CsBtƒ}z| ||¡WSt|dtƒk
r<tt ¡ƒ‚YnXdS)z&Invoke the mandatory build_sdist hook.ÚUnsupportedOperationN)rIÚ build_sdistrErprqr rC)Úsdist_directoryrNrOrrrrsès
rsc
CsJttjƒdkrt d¡tjd}tjd}|tkrBt d|¡tƒ|}tt|dƒƒ}dddœ}z|f|d    Ž|d
<Wn¶tk
r®}zd |d <|j    |d <W5d}~XYn„t
k
rà}zd |d<|j |d<W5d}~XYnRt k
r}zd |d<|j    |d <W5d}~XYnt k
r0d |d<YnXt|t|dƒdddS)Nrz"Needs args: hook_name, control_dirrdézUnknown hook: %sz
input.jsonF)Ú unsupportedÚ
return_valrrwTÚ
no_backendr Úbackend_invalidÚ backend_errorrvÚ hook_missingz output.json)Úindent)rir@ÚargvÚexitÚ
HOOK_NAMESÚglobalsrrgrr r)r*rqr+r)Ú    hook_nameZ control_dirrPÚ
hook_inputZjson_outÚerrrÚmainús.
 
 
 
 
r„Ú__main__)N)$r(rÚ    importlibrr r-Úos.pathrrgrVrkr@r Ú version_inforrrYrr)r+r3rIrKrQrbr\rRrjrarorprqrsrr„r%rrrrÚ<module>sP   
 
 
û