Comments (5)
Thanks for your question.
if self.settings.os == "Linux":
Yes, this will return True
for all Linux OSs, because this is the os=Linux
that is defined in the profile file or in command line argument. This is irrespective of the current OS Conan is running, the Conan recipes must be as independent of the current system as possible. If in some case the current "build" settings are necessary, coming from the "build" profile (--profile:build or --settings:build), then recipes might access it too, but this is rarely needed and typically only for some packages like packages wrapping a compiler or a build tool.
Note also that no conditionals can be used in the source()
method, as it should be independent of the inputs.
from conan.
Thanks for the answer. In the ideal world, I totally agree that a recipe should be OS-invariant
Not a recipe. Recipes have lots of things that are not invariant. It is only the source()
method of the recipe that should be invariant.
if self.settings.distro in ("debian", "ubuntu"):
yes, definitely, a recipe can use this, as long as it defines the distro
custom setting as first level setting. But this will typically not be the most recommended approach. The most correct approach in most cases is to add distro
as a subsetting of os
Linux
setting, so the above would be more like:
if self.settings.os == "Linux" and str(self.settings.os.distro) in ("ubuntu", ...)
Note the str()
to be able to do the in
operator.
This can be perfectly use in many methods of the recipe, just not in the source()
one.
from conan.
Happy to help!
from conan.
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 distro=debian
(or ubuntu
) in the profile file set in the --profile:<profile_name>
option?
thanks again,
PC
from conan.
Thank you for the informative answers. That helped me a lot.
from conan.
Related Issues (20)
- [question] How to declutter the test package's source repository after building it? HOT 12
- [feature] Cuda flags HOT 3
- [feature] Consider having `cppstd_flag` tool split to also be able to pass the compiler.cppstd value directly HOT 1
- [bug] Conan create fails in test package step when run against a lockfile
- [question] Env var values from package_info() taken over system env vars HOT 2
- [question] Please help how to use NuGet Libraries with Conan and CMake for Builds. HOT 1
- Error uploading file: conanmanifest.txt, '404 Client Error: Not Found for url: https://artifactory.com/artifactory/api/conan/conan-test/v2/conans/xxx/revisions/b9c4826ad9445ea5257f6432b5a019dd/files/conanmanifest.txt[bug] HOT 3
- [question] Confusion around python_requires using minor_mode HOT 6
- [bug] incorrect paths generated by pkgconfigdeps.py when using --deployer option HOT 1
- [question] Filtering options for package to get path to local cache HOT 4
- [bug] `conan list` filtering option asks users to use scope patterns when those don't work in that context HOT 2
- [question] Set cmake_find_mode for all deps in CMakeDeps [conan 2] HOT 2
- [feature] Option to suppress generation of script files HOT 2
- [bug] Initial setup for Conan test suite is not automated or documented HOT 1
- [question] disable package revisions HOT 3
- [bug] Pulseaudio issue while installing SDL2 HOT 7
- [bug] `conan source` does not actually get `global.conf`'s `core.` confs
- [question] Install a binary package without matching the compiler version HOT 1
- [question] preset name != profile name HOT 4
- [question] Include jinja profile template into another
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conan.