Helpers for normalization as expected in wheel/sdist/module file names and core metadata
Function | best |
Convert an arbitrary string into a version-like string. >>> best_effort_version("v0.2 beta") '0.2b0' |
Function | filename |
Normalize 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' |
Function | safe |
Make 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' |
Function | safe |
Escape a component used as a project name according to Core Metadata. >>> safe_name("hello world") 'hello-world' >>> safe_name("hello?world") 'hello-world' |
Function | safe |
Convert 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... |
Function | safer |
Like ``best_effort_version`` but can be used as filename component for wheel |
Function | safer |
Like ``safe_name`` but can be used as filename component for wheel |
Constant | _UNSAFE |
Undocumented |
Constant | _VALID |
Undocumented |
Type Alias | _ |
Undocumented |
Convert 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'
Normalize 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'
Make 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'
Escape a component used as a project name according to Core Metadata. >>> safe_name("hello world") 'hello-world' >>> safe_name("hello?world") 'hello-world'
Convert 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'