module documentation

Helpers for normalization as expected in wheel/sdist/module file names and core metadata

Function best_effort_version Convert an arbitrary string into a version-like string. >>> best_effort_version("v0.2 beta") '0.2b0'
Function filename_component 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_identifier 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_name 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_version 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_best_effort_version Like ``best_effort_version`` but can be used as filename component for wheel
Function safer_name Like ``safe_name`` but can be used as filename component for wheel
Constant _UNSAFE_NAME_CHARS Undocumented
Constant _VALID_NAME Undocumented
Type Alias _Path Undocumented
def best_effort_version(version: str) -> str: (source)

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'

def filename_component(value: str) -> str: (source)

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'

def safe_identifier(name: str) -> str: (source)

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'

def safe_name(component: str) -> str: (source)

Escape a component used as a project name according to Core Metadata. >>> safe_name("hello world") 'hello-world' >>> safe_name("hello?world") 'hello-world'

def safe_version(version: str) -> str: (source)

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'

def safer_best_effort_version(value: str) -> str: (source)

Like ``best_effort_version`` but can be used as filename component for wheel

def safer_name(value: str) -> str: (source)

Like ``safe_name`` but can be used as filename component for wheel

_UNSAFE_NAME_CHARS = (source)

Undocumented

Value
re.compile(r'[^A-Z0-9\.]+',
           re.I)
_VALID_NAME = (source)

Undocumented

Value
re.compile(r'^([A-Z0-9]|[A-Z0-9\._-]*[A-Z0-9])$',
           re.I)

Undocumented

Value
Union[str, Path]