def version_from_git(): try: choice = _dunamai.Version.from_any_vcs version = _dunamai.get_version("spellbot", first_choice=choice).serialize() return version if version is not None and version != "0.0.0" else None except RuntimeError: return None
def version_from_git() -> Optional[str]: try: choice = _dunamai.Version.from_any_vcs version = _dunamai.get_version("spellbot", first_choice=choice).serialize() return version if version is not None and version != "0.0.0" else None except Exception: return None
def version_from_package(): try: choice = _dunamai.Version.from_any_vcs version = _dunamai.get_version("turbot", third_choice=choice).serialize() return version if version is not None and version != "0.0.0" else None except RuntimeError: return None
def test__get_version__fallback() -> None: assert get_version("dunamai_nonexistent_test") == Version("0.0.0")
def test__get_version__third_choice() -> None: assert get_version("dunamai_nonexistent_test", third_choice=lambda: Version("3")) == Version("3")
def test__get_version__first_choice() -> None: assert get_version("dunamai", first_choice=lambda: Version("1")) == Version("1")
def test__get_version__from_name() -> None: assert get_version("dunamai") == Version( pkg_resources.get_distribution("dunamai").version)
import dunamai as _dunamai __version__ = _dunamai.get_version('pypbl').serialize()
{% if cookiecutter.tool == 'pbr' -%} from pkg_resources import get_distribution try: __version__ = get_distribution('{{ cookiecutter.project_slug }}').version except Exception: __version__ = 'Version not found.' {% else -%} import dunamai as _dunamai __version__ = _dunamai.get_version( __name__, first_choice=_dunamai.Version.from_any_vcs ).serialize(style=_dunamai.Style.Pep440, bump=True) {%- endif %}
"--upgrade-minor", action="store_true", default=False) parser.add_argument("-p", "--upgrade-patch", action="store_true", default=False) parser.add_argument("-P", "--print-version", action="store_true", default=False) parser.add_argument("-b", "--build-string") arguments = parser.parse_args() if (arguments.upgrade_major or arguments.upgrade_minor or arguments.upgrade_patch): version = dunamai.get_version( "gauge", first_choice=lambda: from_file(file=VERSION_FILE)) else: version = dunamai.get_version( "gauge", first_choice=lambda: dunamai.Version.from_any_vcs(pattern= SEMVER_PATTERN), ) base = dict( zip_longest( ("major", "minor", "patch"), map(int, version.base.split(".")), fillvalue=0, )) if arguments.upgrade_major: base["major"] += 1 if arguments.upgrade_minor: