Automatically install dependencies of the local (private) libraries // Resolve #2910

This commit is contained in:
Ivan Kravets
2022-03-31 19:25:44 +03:00
parent fcb81ae074
commit be8f842061
3 changed files with 47 additions and 0 deletions

View File

@ -24,6 +24,7 @@ PlatformIO Core 5
* `pio pkg uninstall <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_uninstall.html>`_ - uninstall the project dependencies or custom packages
* `pio pkg update <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_update.html>`__ - update the project dependencies or custom packages
- Automatically install dependencies of the local (private) libraries (`issue #2910 <https://github.com/platformio/platformio-core/issues/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 <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_pack.html>`__ command (`issue #4188 <https://github.com/platformio/platformio-core/issues/4188>`_)
- Dropped automatic updates of global libraries and development platforms (`issue #4179 <https://github.com/platformio/platformio-core/issues/4179>`_)

View File

@ -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

View File

@ -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
):