diff --git a/pyproject.toml b/pyproject.toml index c5ab0e5edcee..7fe1ef7843d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,7 @@ pycryptodome = "^3.18.0" iterators = "^0.0.2" typer = { version = "^0.9.0", extras=["all"] } tomli = "^2.0.1" +tomli-w = "^1.0.0" pathspec = "^0.12.1" # Optional dependencies (Simulation Engine) ray = { version = "==2.10.0", optional = true, python = ">=3.8,<3.12" } diff --git a/src/py/flwr/cli/build.py b/src/py/flwr/cli/build.py index 670b8bd64908..1f7f75d36184 100644 --- a/src/py/flwr/cli/build.py +++ b/src/py/flwr/cli/build.py @@ -20,6 +20,7 @@ from typing import Optional import pathspec +import tomli_w import typer from typing_extensions import Annotated @@ -93,15 +94,28 @@ def build( allowed_extensions = {".py", ".toml", ".md"} + # Remove the 'federations' field from 'tool.flwr' if it exists + if ( + "tool" in conf + and "flwr" in conf["tool"] + and "federations" in conf["tool"]["flwr"] + ): + del conf["tool"]["flwr"]["federations"] + + toml_contents = tomli_w.dumps(conf) + with zipfile.ZipFile(fab_filename, "w", zipfile.ZIP_DEFLATED) as fab_file: + fab_file.writestr("pyproject.toml", toml_contents) + + # Continue with adding other files for root, _, files in os.walk(directory, topdown=True): - # Filter directories and files based on .gitignore files = [ f for f in files if not ignore_spec.match_file(Path(root) / f) and f != fab_filename and Path(f).suffix in allowed_extensions + and f != "pyproject.toml" # Exclude the original pyproject.toml ] for file in files: diff --git a/src/py/flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl index 5934a258564b..507b5d50b843 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets>=0.1.0,<1.0.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.hf.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.hf.toml.tpl index 59f41f062af4..7a63e1ab5368 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.hf.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.hf.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets>=0.0.2,<1.0.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.jax.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.jax.toml.tpl index 27f4b30ec3b8..297784a4d2d8 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.jax.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.jax.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = {text = "Apache License (2.0)"} +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "jax==0.4.26", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.mlx.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.mlx.toml.tpl index 9c8905a0e8e5..fb55f6628cea 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.mlx.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets[vision]>=0.0.2,<1.0.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.numpy.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.numpy.toml.tpl index 38bfa1888c4c..ae88472647dc 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.numpy.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "numpy>=1.21.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl index 2fd366d8e350..2dd49a25fd90 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets[vision]>=0.0.2,<1.0.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl index 143c3756858c..8458fa64ea2d 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets[vision]>=0.0.2,<1.0.0", diff --git a/src/py/flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl b/src/py/flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl index 964bef58c498..2bf0e7d5642c 100644 --- a/src/py/flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +++ b/src/py/flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "$package_name" version = "1.0.0" description = "" -license = { text = "Apache License (2.0)" } +license = "Apache-2.0" dependencies = [ "flwr[simulation]>=1.9.0,<2.0", "flwr-datasets[vision]>=0.0.2,<1.0.0",