Closed madebr closed 1 year ago
I have created a small POC in the configinstall branch at my fork.
When doing conan config install /path/to/configinstall.py
, it is able to transform settings.yml
.
It should also be possible to transform other key conan files (such as conan.conf
)
When using the following file:
configinstall.py
def settings_transform(settings):
settings["os"]["playstation2"] = None
settings["compiler"]["gcc"]["version"].append("3.2")
settings["compiler"]["gcc"]["version"] = sorted(set(settings["compiler"]["gcc"]["version"]))
return settings
And use it with conan config install configinstall.py
, os=playstation2
and self.settings.compiler.version=3.2
become available.
Yep, I have tried to do something similar (round trip yaml) a couple of times, and failed. The problem I have with the current pyyaml implementation is that it doesn't allow round trip, so it will not preserve format, comments, etc. This is unfortunate, because we are using the file contents to know if it has been user modified or not, in order to upgrade to the latest one. being sure we are not overwriting user one. So applying the above transform will make changes, so the next Conan version will not know to automatically upgrade the settings.yml anymore, and then you will have the playstation2 and gcc 3.2 settings, but not the new one. Exactly the same as if you capture today the settings.yml, add the values manually and put it in a gist forever.
So we would need a full round-trip yaml functionality, and that means changing the pyyaml dependency, and has some risk, maybe something to check for Conan 2.0.
Indeed, the built-in settings.yml
contains references, which are not preserved by this.
I was thinking about adding a hook that inserts itself after the settings.yml
file is read by conan.
Does such a hook already exist? Would you allow one to be added?
I think a combination of conan config install
and conan hook
could be useful.
conan config
to:
Settings
python object.I think there is no available extension point for such a hook, it would need to be developed, not sure if it is worth, because this still reads like a workaround and the proper solution is still the ability to programmatically modify the settings.yml
, we should focus on that, IMHO.
I've switched the use of PyYAML
with ruamel.yaml
(https://github.com/madebr/conan/tree/configinstall)
The only diffs after using the following configinstall.py
:
def settings_transform(settings):
from conans import tools
settings["os"]["playstation2"] = None
settings["compiler"]["gcc"]["version"].append("3.2")
settings["compiler"]["gcc"]["version"].sort(key=tools.Version)
return settings
is whitespace:
This is fantastic, and very promising. Thanks for the investigation, I had a look to that fork of pyyaml and looked great, but never had the time to test it. From now on (Conan 1.33) we are trying not to add any new feature to Conan 1.X that are not exclusively oriented towards Conan 2.0, so I would like to suggest the following plan:
develop2
branch is there (in 1-2 weeks)conan config install
)I am proposing in https://github.com/conan-io/conan/pull/12980 to do an update, but not script based. Running scripts at config install
seems a bit unsafe. I suggest trying with a settings_user.yml
file that updates on the fly the main settings.yml
(without doing the round trip, which is one of the major complexities), and lets see how far it goes, it could be enough.
Implemented https://github.com/conan-io/conan/pull/12980 for beta.9, closing this as this would solve the main issue with merging user settings.yml
Hello!
For supporting some retro computing folks, I have created a ps2toolchain conan recipe at https://github.com/madebr/conan-ps2dev. This effectively packages the ps2toolchain at https://github.com/ps2dev/ps2toolchain/. This ps2toolchain is currently using gcc 3.2. This (old) gcc version is not added to the stock settings.yml of conan. The playstation2 os is also not available. I currently add it as follows: https://github.com/madebr/conan-ps2dev/blob/abed78f4fc9afdbc4315d0d5ce6809fb96c764fe/.github/workflows/build-cmake-conan.yml#L34-L39 Is there a better way to do this?
On #conan at cpplang.slack, I have received the suggestion to use
conan config install
. When modifyingsettings.yml
and installing it this way, the targetsettings.yml
is overwritten. This means that all user customizations are lost.It was also suggested to open a pr here to add
playstation2
and3.2
compiler version to the defaultsettings.yml
in this repo. I don't think this is desired as this will open floodgates for pr's wanting to add their favourite operating system.