Skip to content
Snippets Groups Projects
Commit 88901421 authored by Gökçen Nurlu's avatar Gökçen Nurlu Committed by Jürg Billeter
Browse files

Get version number w/o pkg_resources

This removes most of the usages of pkg_resources from the codebase, helping
the goal of getting rid of that completely.

With this change, version number is generated during install and embedded into
`__version__` which is then imported by root level `__init__`. From there,
it is used by other parts of the codebase when needed.

Generated `__version__` file is ignored and not tracked by git to prevent
unnecessary 'changes' messages and accidental commits of that file.
parent 43046114
No related branches found
No related tags found
Loading
Pipeline #
......@@ -16,3 +16,6 @@ tmp
# Integration test results
/integration-tests/*results/
# Generated version file
buildstream/__version__.py
\ No newline at end of file
......@@ -19,6 +19,7 @@
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
# Plugin author facing APIs
from .__version__ import __version__
from .utils import UtilError, ProgramNotFoundError
from .sandbox import Sandbox, SandboxFlags
from .plugin import Plugin
......
......@@ -20,7 +20,6 @@
import os
import sys
import click
import pkg_resources # From setuptools
from contextlib import contextmanager
from blessings import Terminal
from click import UsageError
......@@ -37,14 +36,12 @@ from .._pipeline import Pipeline, PipelineError
from .._scheduler import Scheduler
from .._profile import Topics, profile_start, profile_end
from .. import _yaml
from .. import __version__ as build_stream_version
# Import frontend assets
from . import Profile, LogLine, Status
from .complete import main_bashcomplete, complete_path, CompleteUnhandled
# Some globals resolved for default arguments in the cli
build_stream_version = pkg_resources.require("buildstream")[0].version
# Intendation for all logging
INDENT = 4
......
......@@ -24,12 +24,12 @@ from contextlib import ExitStack
from mmap import mmap
import click
import pkg_resources
from ruamel import yaml
from . import Profile
from .. import Element, Scope, Consistency
from .. import _yaml
from .. import __version__ as bst_version
from .._exceptions import ImplError
from .._message import MessageType
from ..plugin import _plugin_lookup
......@@ -432,12 +432,11 @@ class LogLine(Widget):
context = pipeline.context
project = pipeline.project
starttime = datetime.datetime.now()
bst = pkg_resources.require("buildstream")[0]
text = ''
# Main invocation context
text += '\n'
text += self.content_profile.fmt("BuildStream Version {}\n".format(bst.version), bold=True)
text += self.content_profile.fmt("BuildStream Version {}\n".format(bst_version), bold=True)
values = OrderedDict()
values["Session Start"] = starttime.strftime('%A, %d-%m-%Y at %H:%M:%S')
values["Project"] = "{} ({})".format(project.name, project.directory)
......
......@@ -36,9 +36,9 @@ import tempfile
import itertools
from contextlib import contextmanager
import pkg_resources
import psutil
from . import __version__
from . import _signals
from ._exceptions import BstError, ErrorDomain
......@@ -455,8 +455,7 @@ def get_bst_version():
(int): The major version
(int): The minor version
"""
package = pkg_resources.require("buildstream")[0]
versions = package.version.split('.')[:2]
versions = __version__.split('.')[:2]
return (int(versions[0]), int(versions[1]))
......
......@@ -133,6 +133,12 @@ if not os.environ.get('BST_ARTIFACTS_ONLY', ''):
'bst = buildstream._frontend:cli'
]
_version_template = """\
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = {version!r}
"""
#####################################################
# Monkey-patching setuptools for performance #
......@@ -176,7 +182,10 @@ ScriptWriter.get_args = get_args
setup(name='BuildStream',
description='A framework for modelling build pipelines in YAML',
license='LGPL',
use_scm_version=True,
use_scm_version={
'write_to': "buildstream/__version__.py",
'write_to_template': _version_template,
},
packages=find_packages(),
package_data={'buildstream': ['plugins/*/*.py', 'plugins/*/*.yaml',
'data/*.yaml', 'data/*.sh.in']},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment