Skip to content

Commit

Permalink
Automatically install dependencies of the local (private) libraries //
Browse files Browse the repository at this point in the history
…Resolve #2910
  • Loading branch information
ivankravets committed Mar 31, 2022
1 parent fcb81ae commit be8f842
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`_)
Expand Down
4 changes: 4 additions & 0 deletions platformio/package/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
42 changes: 42 additions & 0 deletions tests/commands/pkg/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]")
]
installed_libdeps_pkgs = LibraryPackageManager(
os.path.join(config.get("platformio", "libdeps_dir"), "private")
).get_installed()
assert pkgs_to_specs(installed_libdeps_pkgs) == [
PackageSpec("[email protected]"),
PackageSpec("[email protected]"),
PackageSpec("[email protected]"),
]


def test_unknown_project_dependencies(
clirunner, validate_cliresult, isolated_pio_core, tmp_path
):
Expand Down

0 comments on commit be8f842

Please sign in to comment.