Selkies
Developer Reference

selkies

Selkies package root.

Appends the package directory to sys.path so vendored modules that use bare (top-level) imports resolve whether the code runs as an installed package or straight from a source checkout, and publishes __version__.

attribute__version__
= _read_version()
func_read_version() -> str

Resolve the version of the running package from its one source.

The installed distribution's metadata is authoritative: every channel (wheel, native package, conda package, AppImage) stamps the version of pyproject.toml into it at build time. A source checkout that is not installed has no metadata, so its pyproject.toml is read instead; anything else reports "unknown".

Source Code
def _read_version() -> str:
    """Resolve the version of the running package from its one source.

    The installed distribution's metadata is authoritative: every channel
    (wheel, native package, conda package, AppImage) stamps the version of
    pyproject.toml into it at build time. A source checkout that is not
    installed has no metadata, so its pyproject.toml is read instead;
    anything else reports "unknown".
    """
    try:
        return _distribution_version("selkies")
    except PackageNotFoundError:
        pass
    checkout = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    try:
        with open(os.path.join(checkout, "pyproject.toml"), encoding="utf-8") as f:
            match = re.search(r'^version\s*=\s*"([^"]+)"', f.read(), re.MULTILINE)
    except OSError:
        match = None
    return match.group(1) if match else "unknown"

Returns

str

On this page

No Headings
Edit on GitHub