[question] check_min_cppstd context
See original GitHub issueThe documentation is clear about header-only packages here, but it’s not helpful when a recipe may be header-only or not (e.g. fmt, spdlog). So, based on the real case https://github.com/conan-io/conan-center-index/pull/12021, I have the follow statement:
def package_id(self):
if self.info.options.header_only:
self.info.clear()
def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, 11)
if self.info.settings.os != "Windows" and (self.info.options.wchar_support or self.info.options.wchar_filenames):
raise ConanInvalidConfiguration("wchar is only supported under windows")
if not self.info.options.header_only and self.info.options.shared and is_msvc_static_runtime(self):
raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported")
When the option header_only=True
is defined, the package ID is cleared, then self.info.settings
and self.info.options
are sanitized, resulting on the follow error:
ERROR: Traceback (most recent call last):
File ".../conans/errors.py", line 34, in conanfile_exception_formatter
yield
File ".../conans/client/graph/graph_binaries.py", line 411, in _compute_package_id
conanfile.validate()
File "${HOME}/.conan/data/spdlog/1.10.0/_/_/export/conanfile.py", line 73, in validate
if self.info.settings.compiler.cppstd:
AttributeError: 'NoneType' object has no attribute 'cppstd'
This error only occurs with Conan 1.x (I’m running 1.51.0), but with Conan 2.0-beta2 it works fine.
I see few options:
- Update Conan 1.x to have same behavior as 2.0 for
self.info
- Add
get_safe
toself.info.settings
andself.info.options
- Need to mix
self.options.get_safe('header_only')
withself.info.
I personally prefer the first option, so we don’t need to update the recipe again.
Environment
Conan Version: 1.51.0 OS: Linux Ubuntu 16.04 Architecture: x86_64 Docker image: conanio/gcc10-ubuntu16.04:1.51.0
Steps to reproduce
pip install conan==1.51.0
git clone https://github.com/uilianries/conan-center-index.git
cd conan-center-index/recipes/spdlog/all
git checkout 72df1ad8336c00ed427f864523b7037a08e7ff13
conan create . 1.10.0@ -pr:b=default -pr:h=default -tf test_v1_package -o spdlog:header_only=True
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Context-Free Questions for Testing - DevelopSense
In Jerry Weinberg and Don Gause's Exploring Requirements, there's a set of context-free questions to ask about a product or service.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
About the
check_min_cppstd(self, 11)
, this is a bit tricky. We could protect it (once it works) with aget_safe
in theself.info.settings
or using the suggestednot self.info.options.get_safe("header_only")
but we can not cover the case of checking the min cppstd when the package is header_only.This is actually an old question/missing feature, what we would need to declare is “hey, consumers, I can exist for any cppstd but I need a minimum of cppstd=11 to work”.
I’m opening a new issue to implement the
get_safe
, and let’s explore again thecppstd
issue.@lasote Good point, but
self.info.xxx.get_safe
is not available for Conan 1.x. It would be great backporting that feature, otherwise, it will be impossible to useself.info
.Some log to clarify that behavior: