-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Add named dependencies #15119
Comments
Hi @lo1ol Thanks for your feedback. There are some reasons why Conan doesn't allow to depend by default on the same package, with different versions or binary variants. For example, if you have one application executable that is linking the zlib library in the For other way more exceptional scenarios, it might be possible to depend on more than one version or binary of the same package, that is already doable in Conan 2.0, no need for a new feature: If you define
So again, this would be a very exceptional scenario that should be avoided in the vast majority of cases, and for those cases that is desired, Conan 2.0 allows using the requirement traits to address it. |
Thank you for answer! It works, but I can't retrieve the package_folder from json output for this kind of dependencies: {
"graph": {
"nodes": {
"0": {
"ref": "pkg_a/0.0.1",
...
},
"conf_info": {},
"label": "conanfileA.py (pkg_a/0.0.1)",
"dependencies": {
"1": {
"ref": "pkg_b/0.0.1",
"run": false,
"libs": false,
"skip": true,
"test": false,
"force": false,
"direct": true,
"build": false,
"transitive_headers": null,
"transitive_libs": null,
"headers": false,
"package_id_mode": null,
"visible": false
}
},
"context": "host",
"test": false
},
"1": {
"ref": "pkg_b/0.0.1#e2a6afab1c5ed8a832feb55cd9c3a3f5",
"id": "1",
"recipe": "Cache",
"package_id": "85c999356992c5713d308db1a4d7bab6bf572f27",
...
"recipe_folder": "/Users/lo1ol/.conan2/p/pkg_b52f44d89d64fa/e",
"source_folder": null,
"build_folder": null,
"generators_folder": null,
"package_folder": null,
...
}
},
...
}
} BTW, if conan 2 support this "workaround", maybe it would be better to add some option, which set this args to False and also add some alias for this deps. For example: self.requires("pkg_a/1.0", options={"option": "value"}, local_dep=True, alias="pkg_a_modified") |
Maybe you are using
You can use the |
no, I'm using conan install: # conanfileA.py
from conan import ConanFile
class RtPkcs11EcpConanfile(ConanFile):
settings = "os", "arch", "build_type"
name="pkg_a"
version="0.0.1"
def build_requirements(self):
self.requires("pkg_b/0.0.1", visible=False, headers=False, libs=False, run=False) from conan import ConanFile
class RtPkcs11EcpConanfile(ConanFile):
settings = "os", "arch", "build_type"
name="pkg_b"
version="0.0.1" conan export-pkg --profile glibc-arm64-gcc11 conanfileB.py
conan install --profile glibc-arm64-gcc11 --format json conanfileA.py conan --version
Conan version 2.0.14 |
Guess, I can. But I just wanted to say that assigning an alias in conanfile makes the search of desired package easer, than searching of desired package by his version or options at generator or somewhere else. |
Ok, I have checked this. What you are seeing is that the dependency is being "Skipped", because as it doesn't contain headers, nor libraries, nothing for runtime and not necessary for building, the dependency resolution computes it is not necessary and avoids downloading the binary. So the above rules apply: it is not possible to require the same dependency in the "host" context multiple times, neither different versions nor different binaries, because it is impossible to link with them. We will consider in the future a possible "re-packaging" feature (see #13171), that would be the possible scenario that this could make some sense for "host" dependencies. |
The repackage feature, that has been renamed to "vendor" (vendoring dependencies) has been merged in #16073, for next Conan 2.4 (hopefully released today). |
What is your suggestion?
Hello!
I noticed that there is some requirements by users to be able have several dependencies with the same name but with differences in versions, options or settings:
#660
#4407
I faced with both of this problem: one of my package depends on openssl 3.0 and openssl 1.0 at the same time (in tests). And one of my package depends on some package with different options. There is one workaround for this: include name version or option in name of package. But it still workaround...
I think that this problem can be resolved by adding custom names to dependencies.
So, generators can search this packages by alias names instead of real names, hash of the requirements should contains alias names conaninfo.txt should contain aliases names instead of original package names.
May be there are some restrictions in implementations of this. But I just want to show you a possible concept.
What do you think about this?
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: