diff --git a/src/py/flwr/cli/build.py b/src/py/flwr/cli/build.py index 5a8ac2d1fd9..e86f4bb762b 100644 --- a/src/py/flwr/cli/build.py +++ b/src/py/flwr/cli/build.py @@ -19,18 +19,14 @@ import shutil import tempfile import zipfile -from logging import DEBUG, ERROR from pathlib import Path from typing import Annotated, Any, Optional, Union import pathspec import tomli_w import typer -from hatchling.builders.wheel import WheelBuilder -from hatchling.metadata.core import ProjectMetadata from flwr.common.constant import FAB_ALLOWED_EXTENSIONS, FAB_DATE, FAB_HASH_TRUNCATION -from flwr.common.logger import log from .config_utils import load_and_validate from .utils import is_valid_project_name @@ -55,27 +51,6 @@ def get_fab_filename(conf: dict[str, Any], fab_hash: str) -> str: return f"{publisher}.{name}.{version}.{fab_hash_truncated}.fab" -def _build_app_wheel(app: Path) -> Path: - """Build app as a wheel and return its path.""" - # Path to your project directory - app_dir = str(app.resolve()) - try: - - # Initialize the WheelBuilder - builder = WheelBuilder( - app_dir, metadata=ProjectMetadata(root=app_dir, plugin_manager=None) - ) - - # Build - whl_path = Path(next(builder.build(directory=app_dir))) - log(DEBUG, "Wheel succesfully built: %s", str(whl_path)) - except Exception as ex: - log(ERROR, "Exception encountered when building wheel.", exc_info=ex) - raise typer.Exit(code=1) from ex - - return whl_path - - # pylint: disable=too-many-locals, too-many-statements def build( app: Annotated[ @@ -131,12 +106,6 @@ def build( bold=True, ) - # Build wheel - whl_path = _build_app_wheel(app) - - # Add path to .whl to `[tool.flwr.app]` - conf["tool"]["flwr"]["app"]["whl"] = str(whl_path.name) - # Load .gitignore rules if present ignore_spec = _load_gitignore(app) @@ -168,9 +137,6 @@ def build( and f.name != "pyproject.toml" # Exclude the original pyproject.toml ] - # Include FAB .whl - all_files.append(whl_path) - for file_path in all_files: # Read the file content manually with open(file_path, "rb") as f: @@ -187,9 +153,6 @@ def build( # Add CONTENT and CONTENT.jwt to the zip file write_to_zip(fab_file, ".info/CONTENT", list_file_content) - # Erase FAB .whl in app directory - whl_path.unlink() - # Get hash of FAB file content = Path(temp_filename).read_bytes() fab_hash = hashlib.sha256(content).hexdigest() diff --git a/src/py/flwr/cli/install.py b/src/py/flwr/cli/install.py index 00f97b7ed70..c2dd7b1585f 100644 --- a/src/py/flwr/cli/install.py +++ b/src/py/flwr/cli/install.py @@ -16,7 +16,6 @@ import hashlib import shutil -import subprocess import tempfile import zipfile from io import BytesIO @@ -188,25 +187,8 @@ def validate_and_install( else: shutil.copy2(item, install_dir / item.name) - whl_file = config["tool"]["flwr"]["app"]["whl"] - install_whl = install_dir / whl_file - try: - subprocess.run( - ["pip", "install", "--no-deps", install_whl], - capture_output=True, - text=True, - check=True, - ) - except subprocess.CalledProcessError as e: - typer.secho( - f"❌ Failed to install {project_name}:\n{e.stderr}", - fg=typer.colors.RED, - bold=True, - ) - raise typer.Exit(code=1) from e - typer.secho( - f"🎊 Successfully installed {project_name}.", + f"🎊 Successfully installed {project_name} to {install_dir}.", fg=typer.colors.GREEN, bold=True, )