[feature] Direct dependencies on components
See original GitHub issueMotivation: 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:
- 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) - 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. - 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). - 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:
- Any catch-all linking will only pull the specified component(s).
- Automatically specify that only the requested component(s) will be propagated to consumers as if done the current way in
package_info()
. - Only the component(s) requested (and any components they depend on) should be forwarded to the generators.
- 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.
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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: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.