Skip to content

Commit be8f842

Browse files
committed
Automatically install dependencies of the local (private) libraries // Resolve #2910
1 parent fcb81ae commit be8f842

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

HISTORY.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PlatformIO Core 5
2424
* `pio pkg uninstall <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_uninstall.html>`_ - uninstall the project dependencies or custom packages
2525
* `pio pkg update <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_update.html>`__ - update the project dependencies or custom packages
2626

27+
- Automatically install dependencies of the local (private) libraries (`issue #2910 <https://github.com/platformio/platformio-core/issues/2910>`_)
2728
- Added support for dependencies declared in a "tool" type package
2829
- 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>`_)
2930
- Dropped automatic updates of global libraries and development platforms (`issue #4179 <https://github.com/platformio/platformio-core/issues/4179>`_)

platformio/package/commands/install.py

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ def _install_project_env_libraries(project_env, options):
216216
skip_dependencies=options.get("skip_dependencies"),
217217
force=options.get("force"),
218218
)
219+
# install dependencies from the priate libraries
220+
plm = LibraryPackageManager(os.path.join(config.get("platformio", "lib_dir")))
221+
for pkg in plm.get_installed():
222+
lm.install_dependencies(pkg, print_header=False)
219223
return not already_up_to_date
220224

221225

tests/commands/pkg/test_install.py

+42
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,48 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
196196
assert "Already up-to-date" in result.output
197197

198198

199+
def test_private_lib_deps(clirunner, validate_cliresult, isolated_pio_core, tmp_path):
200+
project_dir = tmp_path / "project"
201+
private_lib_dir = project_dir / "lib" / "private"
202+
private_lib_dir.mkdir(parents=True)
203+
(private_lib_dir / "library.json").write_text(
204+
"""
205+
{
206+
"name": "My Private Lib",
207+
"version": "1.0.0",
208+
"dependencies": {
209+
"bblanchon/ArduinoJson": "^6.19.2",
210+
"milesburton/DallasTemperature": "^3.9.1"
211+
}
212+
}
213+
"""
214+
)
215+
(project_dir / "platformio.ini").write_text(
216+
"""
217+
[env:private]
218+
platform = native
219+
"""
220+
)
221+
with fs.cd(str(project_dir)):
222+
result = clirunner.invoke(package_install_cmd)
223+
validate_cliresult(result)
224+
config = ProjectConfig()
225+
installed_lib_pkgs = LibraryPackageManager(
226+
os.path.join(config.get("platformio", "lib_dir"))
227+
).get_installed()
228+
assert pkgs_to_specs(installed_lib_pkgs) == [
229+
PackageSpec("My Private Lib@1.0.0")
230+
]
231+
installed_libdeps_pkgs = LibraryPackageManager(
232+
os.path.join(config.get("platformio", "libdeps_dir"), "private")
233+
).get_installed()
234+
assert pkgs_to_specs(installed_libdeps_pkgs) == [
235+
PackageSpec("ArduinoJson@6.19.3"),
236+
PackageSpec("DallasTemperature@3.9.1"),
237+
PackageSpec("OneWire@2.3.6"),
238+
]
239+
240+
199241
def test_unknown_project_dependencies(
200242
clirunner, validate_cliresult, isolated_pio_core, tmp_path
201243
):

0 commit comments

Comments
 (0)