Skip to content

Commit 6e1f060

Browse files
Merge pull request #25527 from vfdev-5:single-python-version-build-py
PiperOrigin-RevId: 713365267
2 parents d99a637 + 70e06c2 commit 6e1f060

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

build/build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def add_global_arguments(parser: argparse.ArgumentParser):
6969
parser.add_argument(
7070
"--python_version",
7171
type=str,
72-
choices=["3.10", "3.11", "3.12", "3.13"],
7372
default=f"{sys.version_info.major}.{sys.version_info.minor}",
7473
help=
7574
"""
@@ -390,6 +389,14 @@ async def main():
390389
bazel_command_base.append("run")
391390

392391
if args.python_version:
392+
# Do not add --repo_env=HERMETIC_PYTHON_VERSION with default args.python_version
393+
# if bazel_options override it
394+
python_version_opt = "--repo_env=HERMETIC_PYTHON_VERSION="
395+
if any([python_version_opt in opt for opt in args.bazel_options]):
396+
raise RuntimeError(
397+
"Please use python_version to set hermetic python version instead of "
398+
"setting --repo_env=HERMETIC_PYTHON_VERSION=<python version> bazel option"
399+
)
393400
logging.debug("Hermetic Python version: %s", args.python_version)
394401
bazel_command_base.append(
395402
f"--repo_env=HERMETIC_PYTHON_VERSION={args.python_version}"

0 commit comments

Comments
 (0)