From f45717d216daad269629bc4b56ac4231b880175b Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 18 Apr 2018 14:54:59 +0300 Subject: [PATCH 1/3] Add version check on main script for legecy Python --- tasks/generate.py | 18 ++++++++++++++++-- templates/default.py | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tasks/generate.py b/tasks/generate.py index a4cdf16d..96bc22f9 100644 --- a/tasks/generate.py +++ b/tasks/generate.py @@ -16,6 +16,18 @@ PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +VERSION_CHECK = ''' +PY_VERSION = sys.version_info[:2] + +if PY_VERSION in [(2, 6), (3, 2), (3, 3)]: + raise RuntimeError("""This script does not support Python {0}.{1}. + +Please install the legacy version: + + $ curl https://bootstrap.pypa.io/{0}.{1}/get-pip.py | python{0}.{1} +""".format(PY_VERSION[0], PY_VERSION[1])) +''' + def _path(pyversion=None): parts = [PROJECT_ROOT, pyversion, "get-pip.py"] @@ -29,7 +41,8 @@ def _template(name="default.py"): @invoke.task def installer(ctx, pip_version=None, wheel_version=None, setuptools_version=None, - installer_path=_path(), template_path=_template()): + installer_path=_path(), template_path=_template(), + version_check=""): print("[generate.installer] Generating installer {} (using {})".format( os.path.relpath(installer_path, PROJECT_ROOT), @@ -105,6 +118,7 @@ def installer(ctx, "" if setuptools_version is None else setuptools_version), installed_version=latest, zipfile="\n".join(chunked), + version_check=version_check, ), ) @@ -119,7 +133,7 @@ def installer(ctx, @invoke.task( default=True, pre=[ - invoke.call(installer), + invoke.call(installer, version_check=VERSION_CHECK), invoke.call(installer, installer_path=_path("2.6"), template_path=_template("pre-10.py"), pip_version="<10", diff --git a/templates/default.py b/templates/default.py index 9991ffcb..a07bbcc4 100644 --- a/templates/default.py +++ b/templates/default.py @@ -31,6 +31,8 @@ PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 +{version_check} + if PY3: iterbytes = iter else: From c512f17b8a013a9c16ead3c31f530906d03b6e74 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 18 Apr 2018 14:55:27 +0300 Subject: [PATCH 2/3] Regenerate installers --- 3.3/get-pip.py | 2 ++ get-pip.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/3.3/get-pip.py b/3.3/get-pip.py index a5d20a15..0e28e130 100755 --- a/3.3/get-pip.py +++ b/3.3/get-pip.py @@ -31,6 +31,8 @@ PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 + + if PY3: iterbytes = iter else: diff --git a/get-pip.py b/get-pip.py index 797bab0b..3802e214 100755 --- a/get-pip.py +++ b/get-pip.py @@ -31,6 +31,18 @@ PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 + +PY_VERSION = sys.version_info[:2] + +if PY_VERSION in [(2, 6), (3, 2), (3, 3)]: + raise RuntimeError("""This script does not support Python {0}.{1}. + +Please install the legacy version: + + $ curl https://bootstrap.pypa.io/{0}.{1}/get-pip.py | python{0}.{1} +""".format(PY_VERSION[0], PY_VERSION[1])) + + if PY3: iterbytes = iter else: From bd3884eabb3112d411b0c9a351e5367847444823 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 29 Jul 2020 21:34:31 +0300 Subject: [PATCH 3/3] This script also does not support Python 3.4 Co-authored-by: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com> --- tasks/generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/generate.py b/tasks/generate.py index 96bc22f9..4eab8bd3 100644 --- a/tasks/generate.py +++ b/tasks/generate.py @@ -19,7 +19,7 @@ VERSION_CHECK = ''' PY_VERSION = sys.version_info[:2] -if PY_VERSION in [(2, 6), (3, 2), (3, 3)]: +if PY_VERSION in [(2, 6), (3, 2), (3, 3), (3, 4)]: raise RuntimeError("""This script does not support Python {0}.{1}. Please install the legacy version: