diff --git a/dvc/__init__.py b/dvc/__init__.py index 5ffb838c8..53b12fc76 100644 --- a/dvc/__init__.py +++ b/dvc/__init__.py @@ -5,7 +5,8 @@ Make your data science projects reproducible and shareable. """ import os -__version__ = '0.9.6' +VERSION_BASE = '0.9.6' +__version__ = VERSION_BASE PACKAGEPATH = os.path.abspath(os.path.dirname(__file__)) HOMEPATH = os.path.dirname(PACKAGEPATH) diff --git a/dvc/check_updates.py b/dvc/check_updates.py new file mode 100644 index 000000000..e113d8061 --- /dev/null +++ b/dvc/check_updates.py @@ -0,0 +1,30 @@ +from github import Github + +from dvc import VERSION_BASE +from dvc.logger import Logger + +GITHUB_USER = 'dataversioncontrol' +GITHUB_REPO = 'dvc' + +def check_updates(): + current = VERSION_BASE + + try: + gh = Github() + user = gh.get_user(GITHUB_USER) + repo = user.get_repo(GITHUB_REPO) + latest = repo.get_latest_release().title + except Exception as exc: + Logger.debug('Failed to obtain latest version: {}'.format(str(exc))) + return + + l_major, l_minor, l_patch = latest.split('.') + c_major, c_minor, c_patch = current.split('.') + + if l_major <= c_major and \ + l_minor <= c_minor and \ + l_patch <= c_patch: + return + + msg = 'You are using dvc version {}, however version {} is available. Consider upgrading.' + Logger.warn(msg.format(current, latest)) diff --git a/dvc/project.py b/dvc/project.py index 2c8e521c0..6c151f527 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -17,6 +17,7 @@ from dvc.scm import SCM, Base from dvc.cache import Cache from dvc.cloud.data_cloud import DataCloud from dvc.system import System +from dvc.check_updates import check_updates class InitError(DvcException): @@ -52,6 +53,8 @@ class Project(object): self.logger = Logger(self.config._config[Config.SECTION_CORE].get(Config.SECTION_CORE_LOGLEVEL, None)) self.cloud = DataCloud(cache=self.cache, config=self.config._config) + check_updates() + @staticmethod def init(root_dir=os.curdir, no_scm=False): """ diff --git a/requirements.txt b/requirements.txt index 2dbfd783e..eaed5ed0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,3 +20,4 @@ paramiko>=2.4.1 binaryornot==0.4.4 jsonpath-rw==1.4.0 reflink==0.2.0 +PyGithub>=1.39 diff --git a/setup.py b/setup.py index 3d5fa9e87..767c7c14f 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ install_requires = [ "binaryornot==0.4.4", "jsonpath-rw==1.4.0", "reflink==0.2.0", + "PyGithub>=1.39", ] setup(