spateo.get_version#

A minimalistic version helper in the spirit of versioneer, that is able to run without build step using pkg_resources. Developed by P Angerer, see https://github.com/flying-sheep/get_version.

Module Contents#

Classes#

Version

Typed version of namedtuple.

Functions#

match_groups(regex, target)

get_version_from_dirname(name, parent)

Extracted sdist

get_version_from_git(parent)

get_version_from_metadata(name[, parent])

get_version(→ str)

Get the version of a package or module

get_all_dependencies_version([display])

Adapted from answer 2 in

Attributes#

spateo.get_version.RE_VERSION = '([\\d.]+?)(?:\\.dev(\\d+))?(?:[_+-]([0-9a-zA-Z.]+))?'[source]#
spateo.get_version.RE_GIT_DESCRIBE = 'v?(?:([\\d.]+)-(\\d+)-g)?([0-9a-f]{7})(-dirty)?'[source]#
spateo.get_version.ON_RTD[source]#
spateo.get_version.match_groups(regex, target)[source]#
class spateo.get_version.Version[source]#

Bases: NamedTuple

Typed version of namedtuple.

Usage in Python versions >= 3.6:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:

Employee = NamedTuple('Employee', name=str, id=int)

In Python versions <= 3.5 use:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
release: str[source]#
dev: str | None[source]#
labels: List[str][source]#
static parse(ver)[source]#
__str__()[source]#

Return str(self).

spateo.get_version.get_version_from_dirname(name, parent)[source]#

Extracted sdist

spateo.get_version.get_version_from_git(parent)[source]#
spateo.get_version.get_version_from_metadata(name: str, parent: pathlib.Path | None = None)[source]#
spateo.get_version.get_version(package: pathlib.Path | str) str[source]#

Get the version of a package or module Pass a module path or package name. The former is recommended, since it also works for not yet installed packages. Supports getting the version from #. The directory name (as created by setup.py sdist) #. The output of git describe #. The package metadata of an installed package

(This is the only possibility when passing a name)

Parameters:
package

package name or module path (…/module.py or …/module/__init__.py)

spateo.get_version.get_all_dependencies_version(display=True)[source]#

Adapted from answer 2 in https://stackoverflow.com/questions/40428931/package-for-listing-version-of-packages-used-in-a-jupyter-notebook

spateo.get_version.__version__[source]#