_dz2dZddlZddlmZddlmZddlmZddlm Z ee efZ ejdejZejd ejZd e d e fd Zd e d e fdZde d e fdZde d e fdZde d e fdZde d e fdZde d e fdZy)zZ Helpers for normalization as expected in wheel/sdist/module file names and core metadata N)Path)Union) packaging)SetuptoolsDeprecationWarningz)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$z [^A-Z0-9.]+namereturncXtjdd|}|jsJ|S)zMake a string safe to be used as Python identifier. >>> safe_identifier("12abc") '_12abc' >>> safe_identifier("__editable__.myns.pkg-78.9.3_local") '__editable___myns_pkg_78_9_3_local' z \W|^(?=\d)_)resub isidentifier)rsafes ;/usr/lib/python3/dist-packages/setuptools/_normalization.pysafe_identifierrs- 66-d +D      K componentc.tjd|S)zEscape a component used as a project name according to Core Metadata. >>> safe_name("hello world") 'hello-world' >>> safe_name("hello?world") 'hello-world' -)_UNSAFE_NAME_CHARSr )rs r safe_namers  ! !#y 11rversionc:|jdd} ttjj |S#tjj $rAt jd|}ttjj |cYSwxYw)aConvert an arbitrary string into a valid version string. >>> safe_version("1988 12 25") '1988.12.25' >>> safe_version("v0.2.1") '0.2.1' >>> safe_version("v0.2?beta") '0.2b0' >>> safe_version("v0.2 beta") '0.2b0' >>> safe_version("ubuntu lts") Traceback (most recent call last): ... setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'ubuntu.lts'  .r)replacestrrrVersionInvalidVersionrr )rvattempts r safe_versionr"*s~ S!A79$$,,Q/00    + +7$((a09$$,,W5667s'<ABBc t|S#tjj$rAt j d|dd|ddd|j dd}t|cYSwxYw) aConvert an arbitrary string into a version-like string. >>> best_effort_version("v0.2 beta") '0.2b0' >>> import warnings >>> warnings.simplefilter("ignore", category=SetuptoolsDeprecationWarning) >>> best_effort_version("ubuntu lts") 'ubuntu.lts' zInvalid version: rz Version z is not valid according to PEP 440. Please make sure to specify a valid version for your package. Also note that future releases of setuptools may halt the build process if an invalid version is given. z!https://peps.python.org/pep-0440/)i )see_urldue_dater)r"rrrremitrr)rr s rbest_effort_versionr)AsG$$    + +$)){! ,K  8"  OOC %|s AA+*A+valuecD|jddjdS)zNormalize each component of a filename (e.g. distribution/version part of wheel) Note: ``value`` needs to be already normalized. >>> filename_component("my-pkg") 'my_pkg' rr )rstripr*s rfilename_componentr._s ==c " ( ( --rc*tt|S)zBLike ``safe_name`` but can be used as filename component for wheel)r.rr-s r safer_namer0hs i. //rc*tt|S)zLLike ``best_effort_version`` but can be used as filename component for wheel)r.r)r-s rsafer_best_effort_versionr2ns 1%8 99r)__doc__r pathlibrtypingrexternrwarningsrr_PathcompileI _VALID_NAMErrrr"r)r.r0r2rrr=s 2 c4ibjjErttL RZZ5 # # 2227#7#7.<.c.c.0c0c0 :S:S:r