本文整理汇总了Python中setuptools_scm.get_version方法的典型用法代码示例。如果您正苦于以下问题:Python setuptools_scm.get_version方法的具体用法?Python setuptools_scm.get_version怎么用?Python setuptools_scm.get_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools_scm
的用法示例。
在下文中一共展示了setuptools_scm.get_version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_version
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def get_version() -> Version:
if devmode.is_in_dev_mode():
if pkg_resources is None:
raise MetadataError(
'cannot determine build version: no pkg_resources module')
if setuptools_scm is None:
raise MetadataError(
'cannot determine build version: no setuptools_scm module')
version = setuptools_scm.get_version(
root='../..', relative_to=__file__)
pv = pkg_resources.parse_version(version)
version = parse_version(pv)
else:
vertuple: List[Any] = list(get_build_metadata_value('VERSION'))
vertuple[2] = VersionStage(vertuple[2])
version = Version(*vertuple)
return version
示例2: get_version_dict
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def get_version_dict() -> immu.Map[str, Any]:
global _version_dict
if _version_dict is None:
ver = get_version()
_version_dict = immu.Map({
'major': ver.major,
'minor': ver.minor,
'stage': ver.stage.name.lower(),
'stage_no': ver.stage_no,
'local': tuple(ver.local) if ver.local else (),
})
return _version_dict
示例3: main
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def main():
_warn_if_setuptools_outdated()
print("Guessed Version", get_version())
if "ls" in sys.argv:
for fname in find_files("."):
print(fname)
示例4: test_version_from_pkginfo
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_version_from_pkginfo(wd, monkeypatch):
wd.write("PKG-INFO", "Version: 0.1")
assert wd.version == "0.1"
# replicate issue 167
assert wd.get_version(version_scheme="1.{0.distance}.0".format) == "0.1"
示例5: test_root_parameter_creation
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_root_parameter_creation(monkeypatch):
assert_root(monkeypatch, os.getcwd())
setuptools_scm.get_version()
示例6: test_root_parameter_pass_by
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_root_parameter_pass_by(monkeypatch, tmpdir):
assert_root(monkeypatch, tmpdir)
setuptools_scm.get_version(root=tmpdir.strpath)
示例7: test_pretended
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_pretended(version, monkeypatch):
monkeypatch.setenv(setuptools_scm.PRETEND_KEY, version)
assert setuptools_scm.get_version() == version
示例8: test_parse_plain_fails
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_parse_plain_fails(recwarn):
def parse(root):
return "tricked you"
with pytest.raises(TypeError):
setuptools_scm.get_version(parse=parse)
示例9: get_version
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def get_version(self, **kw):
__tracebackhide__ = True
from setuptools_scm import get_version
version = get_version(root=str(self.cwd), fallback_root=str(self.cwd), **kw)
print(version)
return version
示例10: version
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def version(self):
__tracebackhide__ = True
return self.get_version()
示例11: test_pip_egg_info
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def test_pip_egg_info(tmpdir, monkeypatch):
"""if we are indeed a sdist, the root does not apply"""
# we should get the version from pkg-info if git is broken
p = tmpdir.ensure("sub/package", dir=1)
tmpdir.mkdir(".git")
p.join("setup.py").write(
"from setuptools import setup;" 'setup(use_scm_version={"root": ".."})'
)
with pytest.raises(LookupError):
get_version(root=p.strpath, fallback_root=p.strpath)
p.ensure("pip-egg-info/random.egg-info/PKG-INFO").write("Version: 1.0")
assert get_version(root=p.strpath, fallback_root=p.strpath) == "1.0"
示例12: scm_config
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def scm_config():
here = os.path.dirname(os.path.abspath(__file__))
src = os.path.join(here, "src")
egg_info = os.path.join(src, "setuptools_scm.egg-info")
has_entrypoints = os.path.isdir(egg_info)
import pkg_resources
sys.path.insert(0, src)
pkg_resources.working_set.add_entry(src)
# FIXME: remove debug
print(src)
print(pkg_resources.working_set)
from setuptools_scm.hacks import parse_pkginfo
from setuptools_scm.git import parse as parse_git
from setuptools_scm.version import guess_next_dev_version, get_local_node_and_date
def parse(root):
try:
return parse_pkginfo(root)
except IOError:
return parse_git(root)
config = dict(
version_scheme=guess_next_dev_version, local_scheme=get_local_node_and_date
)
if has_entrypoints:
return dict(use_scm_version=config)
else:
from setuptools_scm import get_version
return dict(version=get_version(root=here, parse=parse, **config))
示例13: main
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def main():
_warn_if_setuptools_outdated()
print('Guessed Version', get_version())
if 'ls' in sys.argv:
for fname in find_files('.'):
print(fname)
示例14: local_version
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def local_version(version):
"""
Patch in a version that can be uploaded to test PyPI
"""
scm_version = get_version()
if "dev" in scm_version:
gh_in_int = []
for char in version.node:
if char.isdigit():
gh_in_int.append(str(char))
else:
gh_in_int.append(str(string.ascii_letters.find(char)))
return "".join(gh_in_int)
else:
return ""
示例15: get_version_from_scm_tag
# 需要导入模块: import setuptools_scm [as 别名]
# 或者: from setuptools_scm import get_version [as 别名]
def get_version_from_scm_tag(
*,
root: str = '.',
relative_to: Optional[str] = None,
local_scheme: Union[Callable, str] = 'node-and-date',
) -> str:
"""Retrieve the version from SCM tag in Git or Hg."""
try:
return get_version(
root=root,
relative_to=relative_to,
local_scheme=local_scheme,
)
except LookupError:
return 'unknown'