diff --git a/scripts/west-commands.yml b/scripts/west-commands.yml index cb38653bcc..d71124ee2a 100644 --- a/scripts/west-commands.yml +++ b/scripts/west-commands.yml @@ -8,7 +8,7 @@ west-commands: - name: bridle-export class: BridleExport help: export Bridle installation as a CMake config package - + - file: scripts/west_commands/nix_update.py commands: - name: nix-update diff --git a/scripts/west_commands/nix_update.py b/scripts/west_commands/nix_update.py index 6e480beaa8..fbfdab9d11 100644 --- a/scripts/west_commands/nix_update.py +++ b/scripts/west_commands/nix_update.py @@ -30,7 +30,7 @@ def do_add_parser(self, parser_adder): return parser def do_run(self, args, unknown_args): - + ## Update Python dependencies from requirements.txt files # Get paths of requirements.txt we care about @@ -44,13 +44,13 @@ def do_run(self, args, unknown_args): # Generate nix expression based on requirements log.inf(f"Parsing python dependencies in {(', ').join(requirements_paths)}") nix_expr = generate_nix_from_paths(requirements_paths) - + # Write nix expression to file nix_expr_path = os.path.join(bridle_path, 'nix/python-dependencies.nix') log.inf(f"Writing nix expression for python dependencies into {nix_expr_path}") with open(nix_expr_path, "w") as file: file.write(nix_expr) - + ## Update workspace flake from west manifest # Generate flake contents diff --git a/scripts/west_commands/nix_update_python.py b/scripts/west_commands/nix_update_python.py index a2dc66e661..52af9ecd29 100644 --- a/scripts/west_commands/nix_update_python.py +++ b/scripts/west_commands/nix_update_python.py @@ -5,7 +5,7 @@ from packaging.requirements import Marker def python_dependencies(path: str): - + # Get raw file contents with open(path, "r") as file: contents = file.read() @@ -54,7 +54,7 @@ def filter_special_cases(names: str): "clang-format", # Included as an application directly from nixpkgs "gitlint", # Included as an application directly from nixpkgs ] - + return [n for n in names if not n in special_cases] @@ -78,15 +78,15 @@ def generate_nix_from_paths(paths: [str]): return nix_list(deps) def main(): - + # Handle arguments if len(sys.argv) < 3: print("Usage: python nix_update_python.py []") return - + output_filename = sys.argv[1] paths = sys.argv[2:] - + nix_list = generate_nix_from_paths(paths) # Format as nix expression and write to file diff --git a/scripts/west_commands/nix_update_workspace.py b/scripts/west_commands/nix_update_workspace.py index 43cab74f12..5c31a34fee 100644 --- a/scripts/west_commands/nix_update_workspace.py +++ b/scripts/west_commands/nix_update_workspace.py @@ -1,6 +1,8 @@ +import sys +import parse + from west.manifest import Manifest from west.manifest import Project -import parse def inputs_str(ps: [Project]): # Assume all our inputs are github hosted @@ -131,7 +133,7 @@ def main(): # Write output with open(output_filename, "w") as file: - file.write(flake_str(manifest)) + file.write(flake_str) return