Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error if trying to use main script on legacy Python #25

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 3.3/get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3



if PY3:
iterbytes = iter
else:
Expand Down
12 changes: 12 additions & 0 deletions get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 16 additions & 2 deletions tasks/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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), (3, 4)]:
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"]
Expand All @@ -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),
Expand Down Expand Up @@ -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,
),
)

Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions templates/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

{version_check}

if PY3:
iterbytes = iter
else:
Expand Down