From b86afdf7c6945694034663d221ba7e6b3ad18fff Mon Sep 17 00:00:00 2001 From: jafermarq Date: Wed, 23 Oct 2024 23:07:39 +0100 Subject: [PATCH 1/2] init --- pyproject.toml | 1 + src/py/flwr/cli/install.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2b789fc3d623..ac1f5b93cb6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,7 @@ typer = "^0.12.5" tomli = "^2.0.1" tomli-w = "^1.0.0" pathspec = "^0.12.1" +hatchling = "^1.25.0" # Optional dependencies (Simulation Engine) ray = { version = "==2.10.0", optional = true, python = ">=3.9,<3.12" } # Optional dependencies (REST transport layer) diff --git a/src/py/flwr/cli/install.py b/src/py/flwr/cli/install.py index 7451aa3d2326..6afa42000787 100644 --- a/src/py/flwr/cli/install.py +++ b/src/py/flwr/cli/install.py @@ -189,8 +189,16 @@ def validate_and_install( shutil.copy2(item, install_dir / item.name) try: + # Build wheel subprocess.run( - ["pip", "install", "-e", install_dir, "--no-deps"], + ["python", "-m", "hatchling", "build", "-d", install_dir, "-t", "wheel"], + capture_output=True, + text=True, + check=True, + ) + # Install wheel + subprocess.run( + ["pip", "install", "-e", install_dir / "*.whl", "--no-deps"], capture_output=True, text=True, check=True, From 371a503050de3a169ea2ff6335fabd2e263fe8a4 Mon Sep 17 00:00:00 2001 From: jafermarq Date: Wed, 23 Oct 2024 23:23:26 +0100 Subject: [PATCH 2/2] fixes --- src/py/flwr/cli/install.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/py/flwr/cli/install.py b/src/py/flwr/cli/install.py index 6afa42000787..c8d79687feb3 100644 --- a/src/py/flwr/cli/install.py +++ b/src/py/flwr/cli/install.py @@ -196,9 +196,15 @@ def validate_and_install( text=True, check=True, ) + wheel_files = list(install_dir.glob("*.whl")) + if len(wheel_files) != 1: + raise RuntimeError( + f"Exactly one wheel file was expected, but {len(wheel_files)} " + "are present." + ) # Install wheel subprocess.run( - ["pip", "install", "-e", install_dir / "*.whl", "--no-deps"], + ["pip", "install", wheel_files[0], "--no-deps"], capture_output=True, text=True, check=True,