question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] Direct dependencies on components

See original GitHub issue

Motivation: It is likely not too uncommon for users (myself included) to want to depend on only some components of a package, that’s what they’re there for after all. However, this has a few minor inconveniences:

  1. By declaring that you depend on the entire package, any catch-all linking grabs all components, with no way to change this. (see the cmake generator)
  2. Even if you are using a target-based approach (like CMakeDeps + CMakeToolchain), you still need to specify you are only using the given component in two places, once at the link site (e.g. CMake) and once in the package_info() method.
  3. Also with a targets based approach, generators like CMakeToolchain still allow you to link with any other components, potentially allowing for desync between the build system and package_info(), and also if it prints the available components it can clutter the output (for example, pulling one component from Boost).
  4. Users of the package can still use the other components.

Desired functionality: I would like to be able to replace the following:

def requirements(self):
    self.requires("boost/1.76.0")

def package_info(self):
    self.cpp_info.requires = ['boost::iostreams']

with something like:

def requirements(self):
    self.requires("boost::iostreams/1.76.0")

For multiple components, perhaps something like:

def requirements(self):
    self.requires("boost::{iostreams, system}/1.76.0")

This would do a few things, addressing the points above directly:

  1. Any catch-all linking will only pull the specified component(s).
  2. Automatically specify that only the requested component(s) will be propagated to consumers as if done the current way in package_info().
  3. Only the component(s) requested (and any components they depend on) should be forwarded to the generators.
  4. Users of the package would have to specify additional components (perhaps in the same way) if they wanted to use non-propagated components.

I would be okay with this being split up, even just point 2 would be a nice QOL increase to start.

I would love feedback/input, maybe there’s something I missed that would make this unnecessary, but if not I think this would be a nice way of more directly expressing intent.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
czoidocommented, Jul 12, 2022

Hi @Ahajha , I agree that having to specify components for all requirements just because you want just one component from one of the requires is a bit inconvenient, we will have this in mind for 2.0 and if we can think of a better solution we will try to improve it, but probably this will not change in the near future.

1reaction
czoidocommented, Jun 30, 2022

Hi @Ahajha, Thanks a lot for your question. I think it makes sense to be able to just select the components you want to depend on and not propagate everything. But yes, this could be made in two steps, one for simplifying the syntax and not having to specify it twice in the package_info and the second to restrict the information passed downstream. We already discussed this recently in the past and are discussing which solution could we give to address this problem. In fact, we made some proposals that may at least address the second point you listed. Similar to your proposal one of the syntax proposed there is:

   def requirements(self):
       self.requires("boost/1.79.0", components=["boost::random"])

I’m marking this as a look into so we can think of the better solution to address this problem at least in Conan 2.0 and later consider if we can port it to 1.X. I’ll provide some updated info soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Direct Dependency - an overview | ScienceDirect Topics
A series structure represents a direct dependency between the components where the entire system fails if one of its components fails. A parallel...
Read more >
Introduction to the Dependency Mechanism - Apache Maven
Dependency management is a core feature of Maven. Managing dependencies for a single project is easy. Managing dependencies for multi-module ...
Read more >
Distinguish between direct and transitive dependencies ...
Some components will be declared in the manifest i.e. the package.json, pom.xml etc. These are known as direct dependencies.
Read more >
NuGet Package Dependency Resolution - Microsoft Learn
The Direct dependency wins rule can result in a downgrade of the package version, thus potentially breaking other dependencies in the graph.
Read more >
Dealing with Dependencies Inside Design Systems - Medium
You release icon first, and then other components that depend on it later. Then, icon adds minor features or suffers a breaking change....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found