[question] Fall back dependencies
See original GitHub issueShort: I am looking for a proper way to have a primary and a secondary dependency. In the way that if primary is not there, then use secondary.
Long: Our product consists of tree parts: Foo, Zum and Baz. Each with sources in its own git repo. Zum and Baz, are libraries used by Foo.
When a either Zum, Baz and Foo is build from main branch, they are uploaded to stable channel. When build from some feature branch, they are uploaded to the experimental channel. ( we do have other branches and channels, but let’s keep it simple here)
So far a pretty common setup i think.
When I do development. I branch out on an feature branch, let’s say feature/greatThing, So far no issue. But often the work on a feature includes more than just the library or the main program.
So let’s say that my greatThing involves changes to Foo and Baz, but not Zum I created feature branches of same name in both Foo and Baz repos.
When I build Foo it must require the latest Baz build from my feature branch and latest Zum build from stable
I could take the tedious job of changing the conan file for Foo on the feature branch, and pray that I never forget to change it back when merging into stable.
But I would like to automate this, And was considering using the channels for this, thus making a channel for each feature, (easily done I would just reuse the branch name)
So now my Foo should require Baz/[>0]@user/greatThing and Zum[>0]@user/stable
To do this automatically Foo somehow needs to know if Baz or Zum is available on the greatThing channel and if not require latest from stable.
I created this ugly hack.
def requirements(self):
mybuf = StringIO()
self.run('conan search baz/*@user/greatThing --raw -r all', output=mybuf)
if 'baz' in mybuf.getvalue() :
self.requires( "baz/[>0, include_prerelease=True]@user/greatThing")
else :
self.requires( "baz/[>0, include_prerelease=True]@User/stable")
*In this example greatThing is hardcoded, in real code it is a variable, but I like to KISS. 😉
So now my question: Is this a missing feature in Conan, or is there another/better way to achieve the same?
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)

Top Related StackOverflow Question
@memsharded regarding the
run("conan...I agree and Is exactly why I am looking for other solution. 😉I will dive into your link and get back.
Is then in essence explained by https://docs.conan.io/en/latest/versioning/lockfiles/build_order.html example?