Skip to content

Commit 87db506

Browse files
authored
Cherrypick the release script fix for RC. (#18082)
1 parent a51c89a commit 87db506

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pip_build.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def build_pip_package(
338338
src_directory,
339339
dist_directory,
340340
is_nightly=False,
341+
rc=None,
341342
):
342343
# Build Keras with Bazel to get the protobuf .py files
343344
os.chdir(keras_root_directory)
@@ -383,6 +384,8 @@ def build_pip_package(
383384
if is_nightly:
384385
date = datetime.datetime.now()
385386
version += f".dev{date.strftime('%Y%m%d%H')}"
387+
elif rc:
388+
version += rc
386389
with open(os.path.join(package_directory, "__init__.py")) as f:
387390
init_contents = f.read()
388391
with open(os.path.join(package_directory, "__init__.py"), "w") as f:
@@ -455,8 +458,14 @@ def test_wheel(wheel_path, expected_version, requirements_path):
455458
action="store_true",
456459
help="Whether this is for the `keras-nightly` package.",
457460
)
461+
parser.add_argument(
462+
"--RC",
463+
type=str,
464+
help="Whether this is for the release candidate.",
465+
)
458466
args = parser.parse_args()
459467
is_nightly = args.nightly
468+
rc = args.RC
460469

461470
build_directory = os.path.join(tempfile.gettempdir(), TMP_BUILD_DIRNAME)
462471
keras_root_directory = pathlib.Path(__file__).parent.resolve()
@@ -472,6 +481,7 @@ def test_wheel(wheel_path, expected_version, requirements_path):
472481
f"package_directory={package_directory}\n"
473482
f"src_directory={src_directory}\n"
474483
f"is_nightly={is_nightly}"
484+
f"rc={rc}"
475485
)
476486
if os.path.exists(build_directory):
477487
raise ValueError(f"Directory already exists: {build_directory}")
@@ -487,6 +497,7 @@ def test_wheel(wheel_path, expected_version, requirements_path):
487497
src_directory,
488498
dist_directory,
489499
is_nightly,
500+
rc,
490501
)
491502
wheel_filename = [f for f in saved_filenames if f.endswith(".whl")][0]
492503
if VERBOSE:
@@ -504,4 +515,4 @@ def test_wheel(wheel_path, expected_version, requirements_path):
504515
# Clean up: remove the build directory (no longer needed)
505516
if VERBOSE:
506517
print(f"Deleting temp build directory at {build_directory}...")
507-
shutil.rmtree(build_directory)
518+
shutil.rmtree(build_directory)

0 commit comments

Comments
 (0)