-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[question] How to proparate transitive build dependencies (Conan v2)? #13407
Comments
We have the same problem as @db4 reported above as "problem 2)". Here is our advanced scenario:
All the tools have a dependency to an interpreter tool (available as conan package).
When building myPrj the tools have to be called via the interpreter like:
Note that is important that each tool is executed with the correct version of the interpreter. Because of the above mentioned problem, the environment variables specified in the package_info() method of the interpreter, which points to the interpreter executeable in the conan cache after intall, are not visible in myPrj (not generated into runenv or buildenv scripts). Any suggestions how to tackle this with conan? At the moment I assume conan has a bug (tested with 2.016 and 2.12.1) here not providing the runenv and buildenv information of transitive dependencies on requires with trait "build=True". Our workaround at the moment is to set the trait "build=False" on the requires from myPrj to the tools. |
Hi @SzBosch Sorry @db4 for not responding this back then. There is an issue in the definition of the graph. If Conan propagates the I don't know about the tools or exact requirements, but the rules of That means that if some package like This is aligned with the default There is now an example in the docs about the scenario for wanting to use different versions of the same tool-requires in the same package, if you haven't, please check it https://docs.conan.io/2/examples/graph/tool_requires/different_versions.html. Still, it is not expected that they can be added automatically to the environments, but the consumer needs to differentiate explicitly between the different versions (unless they are called I have also added a explicit test in #17714 for this scenario, and to show how the dependencies package folders paths can be used to call the executable, instead of relying on different executable name.
|
Hi @memsharded, thank you very much for your answer. I think it will take some more time to dig into it but let me provide some more details to you what we are trying to achieve: Yes, myPrj needs to call technically "interpreter.exe" directly, but logically, we would like to encapsulate/hide the interpreter e.g. behind toolA in a way, that myPrj does not need not know about this. myPrj shall just call an abstracted e.g. "toolA". There are (at least) 2 ways of doing this:
This approach would solve both issues at the same time: Encapsulating the interpreter from downstream myPry and having multiple versions of the same interpreter used. But unfortunately these interpreters are very huge in size to that if multiple tools, like toolA and toolB in the example above are using the same interpreter version, the disk space consumption and traffic (esp. in CI/CD environments) is unnecessarily high. Therefore we need an alternative.
During the build and conan package creation of e.g. toolA a toolA.cmd/.sh script is generated and packaged to "bin" folder" containing the invocation like:
This is should possible, because conan knows about the dependency and it's version.
(Alternative: Instead of a cmd/sh script, the whole invocation command might be able to encode on an environment variable completely; have not tried this) Now in myPrj with a build_ or tool_requires() (here independent of tait "run") to toolA/1.0.0 there should be a conanbuildenv.sh generated on "conan install" command containing the definition of the environment variables TOOL_A and also INTERPRETER_1_0_0.
This approached failes if the requires() to toolA/1.0.0 has trail "build=True" (like tool_requries has) because the runenv_info of the transitive dependency to interpreter/1.0.0 lead not to the generation of the environment variable INTERPRETER_1_0_0 in the context of myPrj. But when I change the trait to "build=False" then the environment variable INTERPRETER_1_0_0 appear in the generated conanrunenv.sh script, so an invocation is then possible with:
With this the goal is achieved that myPrj does not to know anything about the interpreter. I still do not understand why the propagation of transitive dependencies is different between a requires() with trait "build=True" and "build=False", but as I said maybe I need to dig more into your answer first. |
I had a look into your test: 366070f
Here "project" has to know about "mygcc". Exactly this I try to avoid. To come closer to my scenario can you please make a further test with something like:
The difficulty here is that wrappera/b need to know after "conan install" the location of "gcc" in the local cache. Note that we do not use build() funciton in "project", we just use "conan install" and the generated env scripts to call the build tools. |
I have added a new test in #17714 The most important part is that this is not a C++ package management thing. The problem at and is:
There are different possible strategies that could be used to address this system problem:
In summary, propagating transitive dependencies for executable applications with different versions is mostly an unresolved problem on the OS level, this cannot be solved automatically for relocatable executables, this cannot be implemented by any tooling. Conan can implement different strategies to address this problem by isolating the transitive executable, via vendoring, finalize() or by custom activation/activation of different environments for the different executations of wrappers. |
What is your question?
Suppose I have tools
tool_a
andtool_b
where the latter depends on the former with some specific set of options.So I have
tool_a
recipe withand
tool_b
recipe withNow
lib_c
requirestool_b
for its build:and I have two problems while building
lib_c
. 1)self.options["tool_a"].an_option = True
is just ignored andtool_a
gets the default set of options. 2)TOOL_A_ENV
does not appear in the generatedconanbuildenv-release-x86_64.bat
. Can you explain what I'm doing wrong?Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: