Check installed bazel version is between min_version and max_version. Args: min_version: string for minimum bazel version (must exist!). max_version: string for maximum bazel version (must exist!). Returns: The bazel version detected.
(min_version, max_version)
| 460 | |
| 461 | |
| 462 | def check_bazel_version(min_version, max_version): |
| 463 | """Check installed bazel version is between min_version and max_version. |
| 464 | |
| 465 | Args: |
| 466 | min_version: string for minimum bazel version (must exist!). |
| 467 | max_version: string for maximum bazel version (must exist!). |
| 468 | |
| 469 | Returns: |
| 470 | The bazel version detected. |
| 471 | """ |
| 472 | if which('bazel') is None: |
| 473 | print('Cannot find bazel. Please install bazel.') |
| 474 | sys.exit(1) |
| 475 | |
| 476 | stderr = open(os.devnull, 'wb') |
| 477 | curr_version = run_shell(['bazel', '--version'], |
| 478 | allow_non_zero=True, |
| 479 | stderr=stderr) |
| 480 | if curr_version.startswith('bazel '): |
| 481 | curr_version = curr_version.split('bazel ')[1] |
| 482 | |
| 483 | min_version_int = convert_version_to_int(min_version) |
| 484 | curr_version_int = convert_version_to_int(curr_version) |
| 485 | max_version_int = convert_version_to_int(max_version) |
| 486 | |
| 487 | # Check if current bazel version can be detected properly. |
| 488 | if not curr_version_int: |
| 489 | print('WARNING: current bazel installation is not a release version.') |
| 490 | print('Make sure you are running at least bazel %s' % min_version) |
| 491 | return curr_version |
| 492 | |
| 493 | print('You have bazel %s installed.' % curr_version) |
| 494 | |
| 495 | if curr_version_int < min_version_int: |
| 496 | print('Please upgrade your bazel installation to version %s or higher to ' |
| 497 | 'build TensorFlow!' % min_version) |
| 498 | sys.exit(1) |
| 499 | if (curr_version_int > max_version_int and |
| 500 | 'TF_IGNORE_MAX_BAZEL_VERSION' not in os.environ): |
| 501 | print('Please downgrade your bazel installation to version %s or lower to ' |
| 502 | 'build TensorFlow! To downgrade: download the installer for the old ' |
| 503 | 'version (from https://github.com/bazelbuild/bazel/releases) then ' |
| 504 | 'run the installer.' % max_version) |
| 505 | sys.exit(1) |
| 506 | return curr_version |
| 507 | |
| 508 | |
| 509 | def set_cc_opt_flags(environ_cp): |
no test coverage detected