From f5c9a4ed5f9ebc579250c1a35aca77b0afb47e2d Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Thu, 28 May 2020 16:10:21 +0900 Subject: _context.py: Support parallel installations of BuildStream Allow users to keep separate buildstream.conf files in their XDG_CONFIG_HOME for separate BuildStream versions, in case they have BuildStream 1 and 2 installed. Like other major version safeguards and warnings, this new addition also supports future major versions if they should appear. --- src/buildstream/_context.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 090b3e0bc..19e0781c1 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -219,9 +219,17 @@ class Context: # a $XDG_CONFIG_HOME/buildstream.conf file # if not config: - default_config = os.path.join(os.environ["XDG_CONFIG_HOME"], "buildstream.conf") - if os.path.exists(default_config): - config = default_config + # + # Support parallel installations of BuildStream by first + # trying a (major point) version specific configuration file + # and then falling back to buildstream.conf. + # + major_version, _ = utils._get_bst_api_version() + for config_filename in ("buildstream{}.conf".format(major_version), "buildstream.conf"): + default_config = os.path.join(os.environ["XDG_CONFIG_HOME"], config_filename) + if os.path.exists(default_config): + config = default_config + break # Load default config # -- cgit v1.2.1