fix the --install arg doesn't work (#686)

Co-authored-by: Haifeng Jin <haifeng-jin@users.noreply.github.com>
This commit is contained in:
Haifeng Jin 2023-08-09 13:53:00 -07:00 committed by Francois Chollet
parent 9345cba2bb
commit b14d0c21eb

@ -156,17 +156,18 @@ def build_and_save_output(root_path, __version__):
shutil.copy(fpath, dist_directory) shutil.copy(fpath, dist_directory)
# Find the .whl file path # Find the .whl file path
whl_path = None
for fname in os.listdir(dist_directory): for fname in os.listdir(dist_directory):
if __version__ in fname and fname.endswith(".whl"): if __version__ in fname and fname.endswith(".whl"):
whl_path = os.path.abspath(os.path.join(dist_directory, fname)) whl_path = os.path.abspath(os.path.join(dist_directory, fname))
print(f"Build successful. Wheel file available at {whl_path}") print(f"Build successful. Wheel file available at {whl_path}")
return whl_path
def build(root_path): def build(root_path):
if os.path.exists(build_directory): if os.path.exists(build_directory):
raise ValueError(f"Directory already exists: {build_directory}") raise ValueError(f"Directory already exists: {build_directory}")
whl_path = None
try: try:
copy_source_to_build_directory(root_path) copy_source_to_build_directory(root_path)
run_namex_conversion() run_namex_conversion()
@ -174,11 +175,10 @@ def build(root_path):
from keras_core.src.version import __version__ # noqa: E402 from keras_core.src.version import __version__ # noqa: E402
export_version_string(__version__) export_version_string(__version__)
build_and_save_output(root_path, __version__) return build_and_save_output(root_path, __version__)
finally: finally:
# Clean up: remove the build directory (no longer needed) # Clean up: remove the build directory (no longer needed)
shutil.rmtree(build_directory) shutil.rmtree(build_directory)
return whl_path
def install_whl(whl_fpath): def install_whl(whl_fpath):