Skip to content

Commit

Permalink
Cherrypick the release script fix for RC. (#18082)
Browse files Browse the repository at this point in the history
  • Loading branch information
qlzh727 authored May 2, 2023
1 parent a51c89a commit 87db506
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pip_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def build_pip_package(
src_directory,
dist_directory,
is_nightly=False,
rc=None,
):
# Build Keras with Bazel to get the protobuf .py files
os.chdir(keras_root_directory)
Expand Down Expand Up @@ -383,6 +384,8 @@ def build_pip_package(
if is_nightly:
date = datetime.datetime.now()
version += f".dev{date.strftime('%Y%m%d%H')}"
elif rc:
version += rc
with open(os.path.join(package_directory, "__init__.py")) as f:
init_contents = f.read()
with open(os.path.join(package_directory, "__init__.py"), "w") as f:
Expand Down Expand Up @@ -455,8 +458,14 @@ def test_wheel(wheel_path, expected_version, requirements_path):
action="store_true",
help="Whether this is for the `keras-nightly` package.",
)
parser.add_argument(
"--RC",
type=str,
help="Whether this is for the release candidate.",
)
args = parser.parse_args()
is_nightly = args.nightly
rc = args.RC

build_directory = os.path.join(tempfile.gettempdir(), TMP_BUILD_DIRNAME)
keras_root_directory = pathlib.Path(__file__).parent.resolve()
Expand All @@ -472,6 +481,7 @@ def test_wheel(wheel_path, expected_version, requirements_path):
f"package_directory={package_directory}\n"
f"src_directory={src_directory}\n"
f"is_nightly={is_nightly}"
f"rc={rc}"
)
if os.path.exists(build_directory):
raise ValueError(f"Directory already exists: {build_directory}")
Expand All @@ -487,6 +497,7 @@ def test_wheel(wheel_path, expected_version, requirements_path):
src_directory,
dist_directory,
is_nightly,
rc,
)
wheel_filename = [f for f in saved_filenames if f.endswith(".whl")][0]
if VERBOSE:
Expand All @@ -504,4 +515,4 @@ def test_wheel(wheel_path, expected_version, requirements_path):
# Clean up: remove the build directory (no longer needed)
if VERBOSE:
print(f"Deleting temp build directory at {build_directory}...")
shutil.rmtree(build_directory)
shutil.rmtree(build_directory)

0 comments on commit 87db506

Please sign in to comment.