diff --git a/HISTORY.rst b/HISTORY.rst index 489b9e26ac..f4907a691d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -24,6 +24,7 @@ PlatformIO Core 5 * `pio pkg uninstall `_ - uninstall the project dependencies or custom packages * `pio pkg update `__ - update the project dependencies or custom packages + - Automatically install dependencies of the local (private) libraries (`issue #2910 `_) - Added support for dependencies declared in a "tool" type package - Ignore files according to the patterns declared in ".gitignore" when using `pio package pack `__ command (`issue #4188 `_) - Dropped automatic updates of global libraries and development platforms (`issue #4179 `_) diff --git a/platformio/package/commands/install.py b/platformio/package/commands/install.py index c8e525b4e3..248a0b404e 100644 --- a/platformio/package/commands/install.py +++ b/platformio/package/commands/install.py @@ -216,6 +216,10 @@ def _install_project_env_libraries(project_env, options): skip_dependencies=options.get("skip_dependencies"), force=options.get("force"), ) + # install dependencies from the priate libraries + plm = LibraryPackageManager(os.path.join(config.get("platformio", "lib_dir"))) + for pkg in plm.get_installed(): + lm.install_dependencies(pkg, print_header=False) return not already_up_to_date diff --git a/tests/commands/pkg/test_install.py b/tests/commands/pkg/test_install.py index e539dba368..3a2a1af8a0 100644 --- a/tests/commands/pkg/test_install.py +++ b/tests/commands/pkg/test_install.py @@ -196,6 +196,48 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path): assert "Already up-to-date" in result.output +def test_private_lib_deps(clirunner, validate_cliresult, isolated_pio_core, tmp_path): + project_dir = tmp_path / "project" + private_lib_dir = project_dir / "lib" / "private" + private_lib_dir.mkdir(parents=True) + (private_lib_dir / "library.json").write_text( + """ +{ + "name": "My Private Lib", + "version": "1.0.0", + "dependencies": { + "bblanchon/ArduinoJson": "^6.19.2", + "milesburton/DallasTemperature": "^3.9.1" + } +} +""" + ) + (project_dir / "platformio.ini").write_text( + """ +[env:private] +platform = native +""" + ) + with fs.cd(str(project_dir)): + result = clirunner.invoke(package_install_cmd) + validate_cliresult(result) + config = ProjectConfig() + installed_lib_pkgs = LibraryPackageManager( + os.path.join(config.get("platformio", "lib_dir")) + ).get_installed() + assert pkgs_to_specs(installed_lib_pkgs) == [ + PackageSpec("My Private Lib@1.0.0") + ] + installed_libdeps_pkgs = LibraryPackageManager( + os.path.join(config.get("platformio", "libdeps_dir"), "private") + ).get_installed() + assert pkgs_to_specs(installed_libdeps_pkgs) == [ + PackageSpec("ArduinoJson@6.19.3"), + PackageSpec("DallasTemperature@3.9.1"), + PackageSpec("OneWire@2.3.6"), + ] + + def test_unknown_project_dependencies( clirunner, validate_cliresult, isolated_pio_core, tmp_path ):