0i4,ddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZmZddlZddlmZmZddlmZddlmZmZmZmZdd lmZmZmZmZdd l m!Z!m"Z"ed d Z#ddgdZ$ddZ%ddZ&ddZ'ddZ(ddZ)Gdd Z*y)) annotationsN)IteratorMappingSequence)AnyTypeVar)_ctxenv)tomllib)BuildBackendExceptionBuildExceptionBuildSystemTableValidationError TypoWarning)ConfigSettings DistributionStrPathSubprocessRunner)check_dependencyparse_wheel_filename_TProjectBuilderProjectBuilder)boundz setuptools.build_meta:__legacy__zsetuptools >= 40.8.0) build-backendrequiresc|D]N}tjd||jdk\s,tjd|d|dt dPy)Ng?zFound 'z#' in pyproject.toml, did you mean 'z'?) stacklevel)difflibSequenceMatcherratiowarningswarnr) dictionaryexpectedobjs =/opt/hc_python/lib/python3.12/site-packages/build/_builder.py _find_typor('sQ  " "43 7 = = ?3 F MM#A(2N ctjj|sd|d}t|tjj |d}tjj |d}tjj |s1tjj |sd|d}t|yy)NzSource z is not a directorypyproject.tomlzsetup.pyzF does not appear to be a Python project: no pyproject.toml or setup.py)ospathisdirrjoinexists) source_dirmsgpyproject_tomlsetup_pys r'_validate_source_directoryr51s 77== $ |#67S!!WW\\*.>?Nww||J 3H 77>>. )"''..2J |#ijS!!3K )r)c t|d5}tj|jj cdddS#1swYyxYw#t $ricYSt $r-}|jd|jd}t|dd}~wtj$r}d|d|d}t|dd}~wwxYw)Nrbz: 'z' zFailed to parse z:  ) openr loadsreaddecodeFileNotFoundErrorPermissionErrorstrerrorfilenamerTOMLDecodeError)r-fer2s r'_read_pyproject_tomlrD<s , $ ==!23    , C |2.S!t+  " ", b1-S!t+,sE A1A  A AAA C"C*(BC(B==CcJd|vrt|dtSt|d}d|vrt|dd}t|t |dt rt d|dDs d}t|d|vrt|dtd|d<n t |dts d}t|d|vr5t |dt rt d |dDs d }t||jhd z }|rd d j|}t||S)Nz build-systemrz!`requires` is a required propertyc3<K|]}t|tywN isinstancestr.0is r' z,_parse_build_system_table..XsI$Bq 1c$Bz&`requires` must be an array of stringsrz `build-backend` must be a string backend-pathc3<K|]}t|tywrGrHrKs r'rNz,_parse_build_system_table..isR/Q!:a%/QrOz*`backend-path` must be an array of strings>rrPrzUnknown properties: z, ) r(_DEFAULT_BACKENDdictrrIlistallrJkeysr/)r3build_system_tabler2 unknown_propss r'_parse_build_system_tablerYJsQ^+>>2n^<=++%z21-c22 *:6 =SI$6z$BIF7-c2200%7/?.O?+ *?;S A0-c22++ ).94 @R/A./QRR:-c22&++-0]]M$TYY}%=$>?-c22 r)c* d dfd }|S)NcP||ijxsi|xsiyrG)make_extra_environ)cmdcwd extra_environr runners r'_invoke_wrapped_runnerz7_wrap_subprocess_runner.._invoke_wrapped_runnerws3 sCV3S335;VATRTVWr)NN)r]z Sequence[str]r^ str | Noner_zMapping[str, str] | NonereturnNone)r`r ras`` r'_wrap_subprocess_runnerrgvs8^bX X!+XC[X X "!r)cxeZdZdZej ejf ddZe ejf ddZ e ddZ e ddZ e ddZ d ddZ d dd Z d dd Z d dd Zdd Z d dd Zej,ddZy)rz# The PEP 517 consumer API. ctjj||_t |||_||_tjj|d}tt||_ |jd|_ tj|j|j|jjd|j |j |_y)aA :param source_dir: The source directory :param python_executable: The python executable where the backend lives :param runner: Runner for backend subprocesses The ``runner``, if provided, must accept the following arguments: - ``cmd``: a list of strings representing the command and arguments to execute, as would be passed to e.g. 'subprocess.check_call'. - ``cwd``: a string representing the working directory that must be used for the subprocess. Corresponds to the provided source_dir. - ``extra_environ``: a dict mapping environment variable names to values which must be set for the subprocess execution. The default runner simply calls the backend hooks in a subprocess, writing backend output to stdout/stderr. r+rrP) backend_pathpython_executabler`N)r,r-abspath _source_dirr5_python_executable_runnerr/rYrD _build_system_backendpyproject_hooksBuildBackendHookCallerget_hook)selfr1rkr`pyproject_toml_paths r'__init__zProjectBuilder.__init__s.!# ;":."3  ggll:7GH67KL_7`a**?; $;;    MM++//?"55<<   r)c@|||jt||S)N)r1rkr`)rkrg)clsr r1r`s r'from_isolated_envz ProjectBuilder.from_isolated_envs'!!33*637  r)c|jS)zProject source directory.)rmrvs r'r1zProjectBuilder.source_dirsr)c|jS)zC The Python executable used to invoke the backend. )rnr}s r'rkz ProjectBuilder.python_executables &&&r)c2t|jdS)z The dependencies defined in the ``pyproject.toml``'s ``build-system.requires`` field or the default build dependencies if ``pyproject.toml`` is missing or ``build-system`` is undefined. r)setrpr}s r'build_system_requiresz$ProjectBuilder.build_system_requiress4%%j122r)Nctjd|dd|}t|j|}|j |5t ||cdddS#1swYyxYw)a@ Return the dependencies defined by the backend in addition to :attr:`build_system_requires` for a given distribution. :param distribution: Distribution to get the dependencies of (``sdist`` or ``wheel``) :param config_settings: Config settings for the build backend zGetting build dependencies for ...get_requires_for_build_N)r loggetattrru_handle_backendr)rv distributionconfig_settings hook_name get_requiress r'get_requires_for_buildz%ProjectBuilder.get_requires_for_builds] 2<.DE-l^< tzz95  ! !) ,|O45- , ,s A!!A*c|j||j|j}|Dchc]}t|D]}|c}}Scc}}w)a Return the dependencies which are not satisfied from the combined set of :attr:`build_system_requires` and :meth:`get_requires_for_build` for a given distribution. :param distribution: Distribution to check (``sdist`` or ``wheel``) :param config_settings: Config settings for the build backend :returns: Set of variable-length unmet dependency tuples )runionrr)rvrr dependenciesdus r'check_dependenciesz!ProjectBuilder.check_dependenciessO22<QWWX\XrXrs 'E.?sWlFf6G6G 6Vls!!) rrrr,r-basename ValueErrorzipfileZipFile extractallnamelistr/) rvrmetadatarmatchr2distinfowrs @r' metadata_pathzProjectBuilder.metadata_path%s<<)9:  O 7$45$RWW%5%5e%<=!CS/ !N+,AeI.>-?zJ#*A __U #q LL WajjlW $ ww||,h77 $ #s *CC$c tjj|}t|j|}tjj |r0tjj |s&d|d}t|tj||j|5|||fi|}dddtjj|S#1swY)xYw)Nz Build path 'z' exists and is not a directory) r,r-rlrrur0r.rmakedirsrr/)rvroutdirrrcallbackr2rs r'rzProjectBuilder._call_backendCs(4::y1 77>>& !77==($VH,KL$S)) KK   ! !) ,$V_GGH-ww||FH--- ,s + CC'c#LK dy#tj$r3}t|d|jdt j dd}~wt j$r}t|d|dd}~wt$r%}t|t j dd}~wwxYww)Nz Backend 'z' is not available.z0Backend subprocess exited when trying to invoke )exc_info) rrBackendUnavailabler rqsysr subprocessCalledProcessError Exception)rvhookrs r'rzProjectBuilder._handle_backendVs V 11 'DMM?*=>    ,, x' 5efjek3lmsw w V' CLLNKQU U Vs<B$ B$B!.A  B! A00 B!< BB!!B$)r1rrkrJr`rrdre) rzztype[_TProjectBuilder]r env.IsolatedEnvr1rr`rrdr)rdrJ)rdset[str]rG)rrrConfigSettings | Nonerdr)rrrrrdzset[tuple[str, ...]])rrrrrrrdrcrb) rrrrrrrrcrdrJ)rrrdrJ) rrJrrrrrrrdrJ)rrJrdzIterator[None])__name__ __module__ __qualname____doc__r executablerrdefault_subprocess_runnerrx classmethodr{propertyr1rkrrrrrrr contextlibcontextmanagerrrfr)r'rrs"%#2#L#L ( ( ( ! (  ( T $3#L#L  #      !        '' 33266"6/6  6.26F"F/F  F*26 ""/   >26)- h"h"h/ h ' h h*8>Y]..&-.@U.hk. .& V Vr))r$zMapping[str, str]r%rJrdre)r1rrdre)r-rrdMapping[str, Any])r3rrdr)r`rr rrdr)+ __future__rrrr,rrr"rcollections.abcrrrtypingrrrrr r _compatr _exceptionsr rrr_typesrrrr_utilrrrrRr(r5rDrYrgrrfr)r'rs#  77 LK9-5EF8'( " ,)X"dVdVr)