From 8f8579ad414ff7ab2985ea6fb138bc575b8fa6fe Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 19:48:26 -0400 Subject: [PATCH 1/4] rely on background Signed-off-by: Kenneth Reitz --- Pipfile | 4 ++++ Pipfile.lock | 21 ++++++++++++++++++++- setup.py | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index 31cb0e1d..723567f8 100644 --- a/Pipfile +++ b/Pipfile @@ -11,6 +11,10 @@ pew = ">=0.1.26" pep8 = "*" pytest = "*" pip-tools = "*" +background = "*" [requires] python_version = "3.6" + +[packages.requests] +extras = [ "security",] diff --git a/Pipfile.lock b/Pipfile.lock index ff21f656..f1c03154 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,8 +1,9 @@ { "_meta": { "hash": { - "sha256": "76e3894ec377275576c53e478d0ecc005d0886027f0bb2962bc14faee96bb0e1" + "sha256": "bd2336c28dabc3c3cadf760e0f49a28b6403e13ff6d2623694879836fe29e56b" }, + "pipfile-spec": 1, "requires": { "python_version": "3.6" }, @@ -14,15 +15,27 @@ ] }, "default": { + "asn1crypto": { + "version": "==0.22.0" + }, + "background": { + "version": "==0.1.0" + }, "certifi": { "version": "==2017.7.27.1" }, + "cffi": { + "version": "==1.10.0" + }, "chardet": { "version": "==3.0.4" }, "click": { "version": "==6.7" }, + "cryptography": { + "version": "==2.0.3" + }, "first": { "version": "==2.0.1" }, @@ -41,6 +54,12 @@ "py": { "version": "==1.4.34" }, + "pycparser": { + "version": "==2.18" + }, + "pyopenssl": { + "version": "==17.2.0" + }, "pytest": { "version": "==3.2.1" }, diff --git a/setup.py b/setup.py index 8853bcb1..759e527c 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,8 @@ required = [ 'pew>=0.1.26', 'pip', 'pip-tools>=1.9.0', - 'setuptools>=36.3.0' + 'setuptools>=36.3.0', + 'background' ] if sys.version_info < (2, 7): From ceedd199435cbc89196b701a15ace847b40e3dc5 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 20:09:43 -0400 Subject: [PATCH 2/4] upgrade message Signed-off-by: Kenneth Reitz --- Pipfile | 1 + Pipfile.lock | 5 ++++- pipenv/cli.py | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 723567f8..a5e48c31 100644 --- a/Pipfile +++ b/Pipfile @@ -12,6 +12,7 @@ pep8 = "*" pytest = "*" pip-tools = "*" background = "*" +semver = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index f1c03154..52f20bd7 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "bd2336c28dabc3c3cadf760e0f49a28b6403e13ff6d2623694879836fe29e56b" + "sha256": "38b59dc070cded14f6a19f827b3423f34761232e0563da9e0c733e650bc0423c" }, "pipfile-spec": 1, "requires": { @@ -72,6 +72,9 @@ "resumable-urlretrieve": { "version": "==0.1.5" }, + "semver": { + "version": "==2.7.8" + }, "six": { "version": "==1.10.0" }, diff --git a/pipenv/cli.py b/pipenv/cli.py index 5b250fb3..b667dfc9 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -8,6 +8,7 @@ import distutils.spawn import shutil import signal +import background import click import click_completion import crayons @@ -16,6 +17,7 @@ import parse import pexpect import requests import pipfile +import semver from blindspin import spinner from requests.packages.urllib3.exceptions import InsecureRequestWarning @@ -60,6 +62,21 @@ requests.packages.urllib3.disable_warnings(InsecureRequestWarning) project = Project() +@background.task +def check_for_updates(): + try: + r = requests.get('https://pypi.python.org/pypi/pipenv/json') + latest = sorted([semver.parse_version_info(v) for v in list(r.json()['releases'].keys())])[-1] + current = semver.parse_version_info(__version__) + + if latest > current: + click.echo('{0}: {1} is now available. You get bonus points for upgrading!'.format( + crayons.green('Courtesy Notice'), + crayons.yellow('Pipenv v{v.major}.{v.minor}.{v.patch}'.format(v=latest)), + ), err=True) + except Exception: + pass + def cleanup_virtualenv(bare=True): """Removes the virtualenv directory from the system.""" @@ -790,6 +807,8 @@ def easter_egg(package_name): @click.pass_context def cli(ctx, where=False, venv=False, rm=False, bare=False, three=False, python=False, help=False): + check_for_updates() + if ctx.invoked_subcommand is None: # --where was passed... if where: From 0689d4f0826f92a1f48cdef5cad8fe42329a2bf4 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 20:10:51 -0400 Subject: [PATCH 3/4] timeout on requests Signed-off-by: Kenneth Reitz --- pipenv/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index b667dfc9..8e25e564 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -65,7 +65,7 @@ project = Project() @background.task def check_for_updates(): try: - r = requests.get('https://pypi.python.org/pypi/pipenv/json') + r = requests.get('https://pypi.python.org/pypi/pipenv/json', timeout=0.5) latest = sorted([semver.parse_version_info(v) for v in list(r.json()['releases'].keys())])[-1] current = semver.parse_version_info(__version__) From 293924bd11d4927de7862121b6c14da9e443ee9d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 20:14:52 -0400 Subject: [PATCH 4/4] fixed pipfiles Signed-off-by: Kenneth Reitz --- Pipfile | 4 +--- Pipfile.lock | 17 +---------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Pipfile b/Pipfile index a5e48c31..39de0874 100644 --- a/Pipfile +++ b/Pipfile @@ -13,9 +13,7 @@ pytest = "*" pip-tools = "*" background = "*" semver = "*" +requests = "*" [requires] python_version = "3.6" - -[packages.requests] -extras = [ "security",] diff --git a/Pipfile.lock b/Pipfile.lock index 52f20bd7..73384df5 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "38b59dc070cded14f6a19f827b3423f34761232e0563da9e0c733e650bc0423c" + "sha256": "f89bcf3e88bd0c33e5a924e59417f55eba7ff56069860f3faf1c57eaf269e979" }, "pipfile-spec": 1, "requires": { @@ -15,27 +15,18 @@ ] }, "default": { - "asn1crypto": { - "version": "==0.22.0" - }, "background": { "version": "==0.1.0" }, "certifi": { "version": "==2017.7.27.1" }, - "cffi": { - "version": "==1.10.0" - }, "chardet": { "version": "==3.0.4" }, "click": { "version": "==6.7" }, - "cryptography": { - "version": "==2.0.3" - }, "first": { "version": "==2.0.1" }, @@ -54,12 +45,6 @@ "py": { "version": "==1.4.34" }, - "pycparser": { - "version": "==2.18" - }, - "pyopenssl": { - "version": "==17.2.0" - }, "pytest": { "version": "==3.2.1" },