Python setuptools_scm.get_version() Examples
The following are 22
code examples of setuptools_scm.get_version().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
setuptools_scm
, or try the search function
.
Example #1
Source File: buildmeta.py From edgedb with Apache License 2.0 | 6 votes |
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
Example #2
Source File: _version.py From tropycal with MIT License | 5 votes |
def get_version(): r"""Get the latest version of tropycal.""" try: from setuptools_scm import get_version return get_version(root='..', relative_to=__file__, version_scheme='post-release', local_scheme='dirty-tag') except (ImportError, LookupError): from pkg_resources import get_distribution return get_distribution(__package__).version
Example #3
Source File: setup.py From allure-python with Apache License 2.0 | 5 votes |
def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) install_requires.append("allure-python-commons=={version}".format(version=version)) return configuration
Example #4
Source File: setup.py From allure-python with Apache License 2.0 | 5 votes |
def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) install_requires.append("allure-python-commons=={version}".format(version=version)) return configuration
Example #5
Source File: setup.py From allure-python with Apache License 2.0 | 5 votes |
def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) install_requires.append("allure-python-commons=={version}".format(version=version)) return configuration
Example #6
Source File: setup.py From allure-python with Apache License 2.0 | 5 votes |
def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) install_requires.append("allure-python-commons=={version}".format(version=version)) return configuration
Example #7
Source File: __init__.py From archook with GNU General Public License v2.0 | 5 votes |
def get_version(): try: from setuptools_scm import get_version return get_version(root='..', relative_to=__file__, fallback_version = '1.3.0-dev') except (ImportError, LookupError): from pkg_resources import get_distribution return get_distribution(__package__).version
Example #8
Source File: versiontools.py From create-aio-app with MIT License | 5 votes |
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'
Example #9
Source File: setup.py From pyAFQ with BSD 2-Clause "Simplified" License | 5 votes |
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 ""
Example #10
Source File: __main__.py From safrs with GNU General Public License v3.0 | 5 votes |
def main(): _warn_if_setuptools_outdated() print('Guessed Version', get_version()) if 'ls' in sys.argv: for fname in find_files('.'): print(fname)
Example #11
Source File: setup.py From setuptools_scm with MIT License | 5 votes |
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))
Example #12
Source File: test_regressions.py From setuptools_scm with MIT License | 5 votes |
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"
Example #13
Source File: conftest.py From setuptools_scm with MIT License | 5 votes |
def version(self): __tracebackhide__ = True return self.get_version()
Example #14
Source File: conftest.py From setuptools_scm with MIT License | 5 votes |
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
Example #15
Source File: test_basic_api.py From setuptools_scm with MIT License | 5 votes |
def test_parse_plain_fails(recwarn): def parse(root): return "tricked you" with pytest.raises(TypeError): setuptools_scm.get_version(parse=parse)
Example #16
Source File: test_basic_api.py From setuptools_scm with MIT License | 5 votes |
def test_pretended(version, monkeypatch): monkeypatch.setenv(setuptools_scm.PRETEND_KEY, version) assert setuptools_scm.get_version() == version
Example #17
Source File: test_basic_api.py From setuptools_scm with MIT License | 5 votes |
def test_root_parameter_pass_by(monkeypatch, tmpdir): assert_root(monkeypatch, tmpdir) setuptools_scm.get_version(root=tmpdir.strpath)
Example #18
Source File: test_basic_api.py From setuptools_scm with MIT License | 5 votes |
def test_root_parameter_creation(monkeypatch): assert_root(monkeypatch, os.getcwd()) setuptools_scm.get_version()
Example #19
Source File: test_basic_api.py From setuptools_scm with MIT License | 5 votes |
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"
Example #20
Source File: __main__.py From setuptools_scm with MIT License | 5 votes |
def main(): _warn_if_setuptools_outdated() print("Guessed Version", get_version()) if "ls" in sys.argv: for fname in find_files("."): print(fname)
Example #21
Source File: buildmeta.py From edgedb with Apache License 2.0 | 5 votes |
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
Example #22
Source File: build.py From cloud-inquisitor with Apache License 2.0 | 4 votes |
def build(bucket_name, version, force, verbose): """Build and upload a new tarball Args: bucket_name (str): Name of the bucket to upload to version (str): Override build version. Defaults to using SCM based versioning (git tags) force (bool): Overwrite existing files in S3, if present verbose (bool): Verbose output """ if verbose: log.setLevel('DEBUG') if not version: version = setuptools_scm.get_version() release = "dev" if "dev" in version else "release" tarball = TARBALL_FORMAT.format(version) tarball_path = os.path.join(tempfile.gettempdir(), tarball) s3_key = os.path.join(release, tarball) try: run('npm i') run('./node_modules/.bin/gulp build.prod') except ExecutionError: log.exception('Failed executing command') return log.debug('Creating archive') tar = tarfile.open(tarball_path, "w:gz") for root, dirnames, filenames in os.walk('dist'): for f in filenames: tar.add(os.path.join(root, f), recursive=False, filter=strip_path) tar.close() log.debug('Uploading {} to s3://{}/{}'.format(tarball, bucket_name, s3_key)) try: bucket = get_bucket_resource(bucket_name) if s3_file_exists(bucket, s3_key) and not force: log.error('File already exists in S3, use --force to overwrite') return bucket.upload_file(tarball_path, os.path.join(release, tarball)) except ClientError: log.exception('AWS API failure')