Skip pip installation for unsupported versions of python.

This will generate a warning, but won't fail unless the pip dependencies are actually used by Bazel runs.

PiperOrigin-RevId: 492485607
pull/13171/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 7fc5a881ee
commit ee56471047
  1. 10
      bazel/system_python.bzl

@ -176,25 +176,29 @@ def _get_python_path(repository_ctx):
def _populate_package(ctx, path, python3, python_version):
ctx.symlink(path, "python")
support = "Supported"
supported = True
for idx, v in enumerate(ctx.attr.minimum_python_version.split(".")):
if int(python_version[idx]) < int(v):
support = "Unsupported"
supported = False
break
build_file = _build_file.format(
interpreter = python3,
support = support,
support = "Supported" if supported else "Unsupported",
)
ctx.file("interpreter", "exec {} \"$@\"".format(python3))
ctx.file("BUILD.bazel", build_file)
ctx.file("version.bzl", "SYSTEM_PYTHON_VERSION = '{}{}'".format(python_version[0], python_version[1]))
ctx.file("register.bzl", _register.format(ctx.attr.name))
if supported:
ctx.file("pip.bzl", _alias_pip.format(
python_version = ".".join(python_version),
repo = ctx.attr.name,
))
else:
# PIP dependencies are unlikely to be satisfiable for unsupported versions of python.
ctx.file("pip.bzl", _mock_pip)
def _populate_empty_package(ctx):
# Mock out all the entrypoints we need to run from WORKSPACE. Targets that

Loading…
Cancel
Save