Skip to content

Library manager: Library dependencies #5795

Closed
@Avamander

Description

@Avamander

Is there a possibility that in the future versions of Arduino IDE library could define it's dependencies thus making sure it will work.

Something like this:

  1. Library has a line something similar to requires=<other library's name>:<optional minimum version> and/or requiresIDE=<version> in it's library.properties
  2. User presses download but it does not have a required library installed, there is one installed but without library.properties or the library is outdated (with requiresIDE the IDE's version incompatibility is also warned about)
  3. User is prompted to download or update all the required libraries

This would definetly for example improve how people use libraries like RF24, RF24Network and RF24Mesh (I am sure there are more) making sure both the library and it's dependencies are up-to-date when any of those are downloaded.

Activity

carlosperate

carlosperate commented on Apr 14, 2017

@carlosperate
Contributor

It would also be quite useful if a library could have an Arduino core dependency (ideally a list with all compatible Arduino cores), as some libraries might be processor-specific.

s-celles

s-celles commented on Jan 4, 2019

@s-celles

Library has a line something similar to requires=<other library's name>: and/or requiresIDE= in it's library.properties

@Avamander specifying optionally minimum version may not be enough because if API of a library have some breaking changes you will also need to restrict library version with a maximum version to use latest previous major version

We could need to specify for example:

ArduinoJson<6.0.0,>=5.0.0

But I'm wondering if all registered Arduino libraries uses semantic versioning. Because we need to be able to order version numbering without error / uncertainty.

Related arduino/arduino-cli#105

per1234

per1234 commented on Jan 4, 2019

@per1234
Collaborator

I'm wondering if all registered Arduino libraries uses semantic versioning.

They don't. There is a required version format, which includes semver, but also allows non-semver compliant version numbers.

From https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

version - version of the library. Version should be semver compliant. 1.2.0 is correct; 1.2 is accepted; r5, 003, 1.1c are invalid

I think this is a programmatic definition of the requirement:
https://github.com/bugst/relaxed-semver

njlr

njlr commented on Feb 4, 2019

@njlr

Hi! 👋

One of the authors of Buckaroo here.

I had a look at the library.json format and I think it will be feasible to add native support for this in Buckaroo. From the looks of things, these libraries will build very cleanly! 👍

However, I could not see any dependency information in the library files that I found.

Is the dependency information encoded anywhere?

I am looking for something like:

This library depends on package X, which can be found at github.com/a/x

s-celles

s-celles commented on Feb 4, 2019

@s-celles

Thanks @njlr for coming here to help us.

I wonder if this kind of information shouldn't be available (first) in library.properties (or somewhere else). It's currently not the case.

I think this file should contain dependencies for compiling a sketch ie you need for example LibraryXYZ latest registered version.

But there is differents cases to manage.

Is LibraryXYZ a "registered" library or not?

If it's a registered library library_index.json could (partially) help (to know where to download it)

Version number restriction could also be required for installing some libraries (because sometimes, installing latest version of a library doesn't work because API of a library changed)

Being able to install an (unregistered) library from a Git repository at a given commit, or a given branch should also be considered.

I opened some days ago issues to manage this with arduino-cli

but the main problem here is to first define new data file to define dependencies.

Is adding new fields to library.properties a good idea? should we have a separate file (a YAML or a JSON file) to manage only dependencies?

I don't really know where the Arduino team want to go with this but from my perspective I will use a separate human readable file for this (and I think that YAML file is great for this).

We should be aware that some examples of a library could need more dependencies that a library itself so we should have a mechanism to override this config file for a given directory. (this problem is quite comparable to https://github.com/ianfixes/arduino_ci/issues/109 )

njlr

njlr commented on Feb 4, 2019

@njlr

Hi @scls19fr thanks for the response.

If it's a registered library library.json could (partially) help (to know where to download it)

By "registered" I assume you mean registered on https://www.arduinolibraries.info?

Being able to install an (unregistered) library from a Git repository at a given commit, or a given branch should also be considered.

Buckaroo already works directly on GitHub (or any Git) repositories, so there are no issues there 👍

but the main problem here is to first define new data file to define dependencies.

Is adding new fields to library.properties a good idea? should we have a separate file (a YAML or a JSON file) to manage only dependencies?

Buckaroo has a TOML file (similar benefits to YAML) to define this.

Here is what it might look like:

[[dependency]]
package = "github.com/bblanchon/ArduinoJson"
version = "6.8.0"

[[dependency]]
package = "github.com/arduino-libraries/ArduinoHttpClient"
version = "revision=b6424e430db57fa0c67f82333e80d58b1521a97b"

Buckaroo supports sem-ver ranges, branches, tags and even commits.

It will examine each dependency it finds and recursively fetch its dependencies, assuming there is a TOML file.

The big question is how to integrate this with the Arduino workflow. Currently, Buckaroo puts dependencies into ./buckaroo and wires them together using Buck (Buck is a build system similar to Make, but more powerful). We could add Arduino as an additional back-end option.

I saw in the IDE that packages are put into ./libraries. However, using ino at the command-line, libraries seem to go inside ./lib.

  • Do you know how most users are building their Arduino projects?

  • Can you point to any large open-source Arduino projects that I can examine?

11 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Library manager: Library dependencies · Issue #5795 · arduino/Arduino