[question] Extending settings and options with new `python_requires` syntax
See original GitHub issueI am trying to migrate my recipes to use the new python_requires
syntax as described in the documentation.
However, I cannot find a way to correctly extend or override options and settings from the base conanfile.
In the old python_requires
, I used to do this:
from conans import python_requires, tools
base = python_requires('MyBaseConanFile/1.0.0@company/stable')
class MyPackage(base.MyBaseConanFile):
settings = ("os_build", "arch_build") + base.MyBaseConanFile.settings
options = dict(base.MyBaseConanFile.options, **{
'another_option': [True, False]
})
default_options = dict(base.MyBaseConanFile.default_options, **{
'another_option': True
})
How to achieve the same with the new syntax?
The following does not work:
class MyPackage(ConanFile):
python_requires = 'MyBaseConanFile/1.0.0@company/stable'
python_requires_extend = "MyBaseConanFile.MyBaseConanFile"
options = dict(self.python_requires_extend['MyBaseConanFile.MyBaseConanFile'].options, **{
'another_option': [True, False]
})
The self
is not available in class attribute context. The documentation says nothing about that case. Is this even possible with the new syntax?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
2. Writing the Setup Script — Python 3.11.1 documentation
The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. The main purpose of the...
Read more >What's New In Python 3.10 — Python 3.11.1 documentation
For full details, see the changelog. Summary – Release highlights¶. New syntax features: PEP 634, Structural Pattern Matching: Specification.
Read more >typing — Support for type hints — Python 3.11.1 documentation
New features are frequently added to the typing module. ... Introducing syntax for annotating variables outside of function definitions, and ClassVar.
Read more >What's New In Python 3.8 — Python 3.11.1 documentation
There is a new function parameter syntax / to indicate that some function parameters must be specified positionally and cannot be used as...
Read more >7. Simple statements — Python 3.11.1 documentation
(See section Primaries for the syntax definitions for attributeref, subscription, and slicing.) An assignment statement evaluates the expression list (remember ...
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 Free
Top 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
init()
method for this will be released in Conan 1.24Just a side note: Until this gets resolved, I managed to create a forward-compatible base conanfile which works with both the current version of
python_requires
and should work with the new syntax:Base conanfile:
and the usage in current models is as follows (notice the multiple inheritance):
and the (expected) future usage would be something like: