setup: change define __version__ (#2592)

* setup: change define __version__

* setup: run pre-commit install, black, adn flake8
This commit is contained in:
Irchan Bani
2019-10-10 14:21:16 +03:00
committed by Ruslan Kuprieiev
parent f254004fae
commit 711dc2ea9a
2 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ _BASE_VERSION = "0.62.0"
def _generate_version(base_version):
"""Generate a version with information about the git repository"""
pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if not _is_git_repo(pkg_dir) or not _have_git():
return base_version
+12 -5
View File
@@ -10,13 +10,20 @@ import fastentrypoints # noqa: F401
# https://packaging.python.org/guides/single-sourcing-package-version/
pkg_dir = os.path.dirname(__file__)
pkg_dir = os.path.dirname(os.path.abspath(__file__))
version_path = os.path.join(pkg_dir, "dvc", "version.py")
if sys.version_info[0] == 2:
import imp
# This will define __version__ implicitly
with open(os.path.join(pkg_dir, "dvc", "version.py")) as fobj:
exec(fobj.read())
dvc_version = imp.load_source("dvc.version", version_path)
else:
import importlib.util
version = __version__ # noqa: F821
spec = importlib.util.spec_from_file_location("dvc.version", version_path)
dvc_version = importlib.util.module_from_spec(spec)
spec.loader.exec_module(dvc_version)
version = dvc_version.__version__ # noqa: F821
# To achieve consistency between the build version and the one provided