-
Notifications
You must be signed in to change notification settings - Fork 951
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 do I test for operating system with Conan 2 API? #16445
Comments
Thanks for your question.
Yes, this will return Note also that no conditionals can be used in the |
Hello, @memsharded , Thanks for the answer. In the ideal world, I totally agree that a recipe should be OS-invariant. However, unfortunately, this is often not the case, especially when you are tasked with building legacy software which are even sensitive to Linux distro. By the way, following your rationale, can recipe code like from conans.tools import OSInfo
...
info = OSInfo()
if info.is_linux and info.linux_distro in ("debian", "ubuntu"):
... be replaced with if self.settings.distro in ("debian", "ubuntu"):
... , provided I have thanks again, PC |
Not a recipe. Recipes have lots of things that are not invariant. It is only the
yes, definitely, a recipe can use this, as long as it defines the if self.settings.os == "Linux" and str(self.settings.os.distro) in ("ubuntu", ...) Note the This can be perfectly use in many methods of the recipe, just not in the |
Thank you for the informative answers. That helped me a lot. |
Happy to help! |
How do I test for operating system with Conan 2 API?
Hello,
So, I'm migrating lots of Conan 1.x recipes to Conan 2 and I have lots of code like this:
I couldn't find a replacement in Conan 2 documentation here: https://docs.conan.io/2/reference nor the migration guide mentions anything directly like it: https://docs.conan.io/1/conan_v2.html . So, how do I query the operating system with Conan 2 API? I, however, found, by chance, a similar test here: https://docs.conan.io/1/migrating_to_2.0/recipes.html#settings . So, will something like this
be exactly the same as:
? I ask this because I need
self.settings.os
to return"Linux"
for all Linux distros and not "CentOS", "Fedora", "RedHat", "Debian", ... .thank you,
PC
The text was updated successfully, but these errors were encountered: