3 ig}@sdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z dgZ ejdZd d Zd d ZGd ddeZddZeZ[eZdddZdS)zG Parser for the environment markers micro-language defined in PEP 508. N) string_types)in_venv parse_marker)NormalizedVersion interpretz<((\d+(\.\d+)*\w*)|\'(\d+(\.\d+)*\w*)\'|\"(\d+(\.\d+)*\w*)\")cCs"t|t s| rdS|ddkS)NFrz'") isinstancer)or :/tmp/pip-build-88gy_88q/pip/pip/_vendor/distlib/markers.py _is_literalsr cCs6g}x(tj|D]}|jt|jdqWt|S)Nr)_VERSION_PATTERNfinditerappendNVgroupsset)sresultmr r r _get_versions!src @sfeZdZdZddddddddddddd dd dd dd dd dddd ZddZdS) Evaluatorz; This class is used to evaluate marker expessions. cCs||kS)Nr )xyr r r -szEvaluator.cCs||kS)Nr )rrr r r r.scCs||kp||kS)Nr )rrr r r r/scCs||kS)Nr )rrr r r r0scCs||kS)Nr )rrr r r r1scCs||kp||kS)Nr )rrr r r r2scCs||kS)Nr )rrr r r r3scCs||kp||kS)Nr )rrr r r r4scCs|o|S)Nr )rrr r r r5scCs|p|S)Nr )rrr r r r6scCs||kS)Nr )rrr r r r7scCs||kS)Nr )rrr r r r8s) z==z===z~=z!=z>=andorinznot inc Cs"t|trB|ddkr$|dd}n||kr8td|||}nt|tsPt|d}||jkrntd||d}|d}t|drt|drtd |||f|j||}|j||}|d ks|d kr|dkrt |}t |}n$|d kr|dkrt |}t |}|j|||}|S)z Evaluate a marker expression returned by the :func:`parse_requirement` function in the specified context. rz'"rzunknown variable: %sopzop not implemented: %slhsrhszinvalid comparison: %s %s %spython_versionr<=r>======!=~=rnot in)rr$rr%r&r'r(r))rr*) rr SyntaxErrordictAssertionError operationsNotImplementedErrorr evaluaterr) selfexprcontextrr ZelhsZerhsr!r"r r r r1;s2         zEvaluator.evaluateN)__name__ __module__ __qualname____doc__r/r1r r r r r's rc Csdd}ttdr(|tjj}tjj}nd}d}||tjtjtjtj tj tjt t tj tj ddtjd }|S)NcSs<d|j|j|jf}|j}|dkr8||dt|j7}|S)Nz%s.%s.%sfinalr)majorminormicro releaselevelstrserial)infoversionkindr r r format_full_version^s z,default_context..format_full_versionimplementation0) implementation_nameimplementation_versionos_nameplatform_machineplatform_python_implementationplatform_releaseplatform_systemplatform_versionZplatform_in_venvpython_full_versionr# sys_platform)hasattrsysrDrAnameosplatformmachinepython_implementationreleasesystemr>rr#)rCrIrHrr r r default_context]s&    r[cCsyt|\}}Wn2tk rB}ztd||fWYdd}~XnX|rd|ddkrdtd||ftt}|rz|j|tj||S)z Interpret a marker and return a result depending on environment. :param marker: The marker to interpret. :type marker: str :param execution_context: The context used for name lookup. :type execution_context: mapping z)Unable to interpret marker syntax: %s: %sNr#z*unexpected trailing data in marker: %s: %s)r Exceptionr,r-DEFAULT_CONTEXTupdate evaluatorr1)markerZexecution_contextr3rester4r r r rs " )N)r8rUrerSrVcompatrutilrrrArr__all__compiler r robjectrr[r^r`rr r r r  s"   6