Skip to content

Commit 78c9c9e

Browse files
committed
Install each Library Manager sourced library separately
`arduino-cli lib install` fails if one of the libraries in the list has a dependency on another, but an earlier version of the dependency is specified in the list. For example, the following command doesn't install any libraries and returns exit status 1: $ arduino-cli lib install [email protected] ArduinoIoTCloud [email protected] depends on [email protected] [email protected] depends on [email protected] [email protected] depends on [email protected] [email protected] depends on [email protected] [email protected] depends on [email protected] [email protected] depends on [email protected] [email protected] depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] ArduinoIoTCloud depends on [email protected] The library Arduino_ConnectionHandler is required in two different versions: 0.4.9 and 0.4.8 The solution is to install one library at a time (even though `arduino-cli lib install` supports installing multiple libraries at once). This also allows the user to control which version of the library is installed in the end by the order of the list passed via the libraries input.
1 parent 8145959 commit 78c9c9e

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

compilesketches/compilesketches.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,15 @@ def install_libraries_from_library_manager(self, library_list):
706706
Keyword arguments:
707707
library_list -- list of dictionaries defining the dependencies
708708
"""
709-
lib_install_command = ["lib", "install"]
710-
lib_install_command.extend([self.get_manager_dependency_name(library) for library in library_list])
711-
self.run_arduino_cli_command(command=lib_install_command, enable_output=self.get_run_command_output_level())
709+
lib_install_base_command = ["lib", "install"]
710+
# `arduino-cli lib install` fails if one of the libraries in the list has a dependency on another, but an
711+
# earlier version of the dependency is specified in the list. The solution is to install one library at a time
712+
# (even though `arduino-cli lib install` supports installing multiple libraries at once). This also allows the
713+
# user to control which version is installed in the end by the order of the list passed via the libraries input.
714+
for library in library_list:
715+
lib_install_command = lib_install_base_command.copy()
716+
lib_install_command.append(self.get_manager_dependency_name(library))
717+
self.run_arduino_cli_command(command=lib_install_command, enable_output=self.get_run_command_output_level())
712718

713719
def install_libraries_from_path(self, library_list):
714720
"""Install libraries from local paths

compilesketches/tests/test_compilesketches.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,22 @@ def test_install_libraries_from_library_manager(mocker):
926926

927927
compile_sketches.install_libraries_from_library_manager(library_list=library_list)
928928

929-
lib_install_command = ["lib", "install"] + [library["name"] for library in library_list]
930-
compile_sketches.run_arduino_cli_command.assert_called_once_with(compile_sketches,
931-
command=lib_install_command,
932-
enable_output=run_command_output_level)
929+
lib_install_base_command = ["lib", "install"]
930+
931+
run_arduino_cli_command_calls = []
932+
for library in library_list:
933+
lib_install_command = lib_install_base_command.copy()
934+
lib_install_command.append(library["name"])
935+
run_arduino_cli_command_calls.append(
936+
unittest.mock.call(
937+
compile_sketches,
938+
command=lib_install_command,
939+
enable_output=run_command_output_level
940+
)
941+
)
942+
943+
# noinspection PyUnresolvedReferences
944+
compile_sketches.run_arduino_cli_command.assert_has_calls(calls=run_arduino_cli_command_calls)
933945

934946

935947
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)