AcademySoftwareFoundation / AcademySoftwareFoundation/rez

add get_config_value util func in config.py

Open
#784 0 comments 0 reactions 0 assignees View on GitHub
api enhancement
Dominant language
Python
Stars
1.1k
Forks
374
Avg merge
9d 12h
Merged PRs (30d)
5

Description

From https://github.com/nerdvegas/rez/pull/739:

(snip)

While Os/ArchDependent does respect platform_map, it only does so if platform_map is defined in the same config. The problem with this is, it would not be at all unreasonable for a studio to define platform_map in some root rezconfig.py, and then have various overrides in a second rezconfig.py (you can specify multiple, and they get merged together). In that scenario, any OsDependent used in the second rezconfig would not work as expected.

I think I can see a reasonable fix though - it isn't perfect, but good enough I reckon. What we need to do is, in _load_config_from_filepaths, make the config data read so far, available in some reserved variable - the same way that's done in _load_config_py. Then, InspectedDependent would have access to both platform_map if defined in the current config, but also if defined in an earlier config.

I think this should be a fairly trivial fix. It's not perfect in the sense that OsDependent won't be aware of platform_map being redefined in a config later in the searchpath - but I think the chances of that being done are low, and it's not that unreasonable for OsDependent to only know about platform_map as it's been defined up to that point in the config searchpath.

ps - We could also provide a reserved get_config_value function, which does the inspecting of current config and/or previous merged configs, to get the value you're after. I think this would make sense because we could see this pattern again in a different case, and it'd keep all the messy details (frame introspection etc) in the one place.

Contributor guide

Open the contributing guide

Research direction

Start in config.py by reading _load_config_from_filepaths and _load_config_py, then inspect how InspectedDependent and Os/ArchDependent use platform_map. Add the reserved get_config_value utility so current and previously merged configuration values can be inspected. Done means dependent configuration in later files can access platform_map defined earlier in the searchpath.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.