From ed9b38c8e3b22edb2413031bc8af4004b9e1ea3e Mon Sep 17 00:00:00 2001 From: bernhardkaindl <43588962+bernhardkaindl@users.noreply.github.com> Date: Thu, 9 Sep 2021 09:25:55 +0200 Subject: [PATCH] Fix python/packages.py's config_vars for python2 packages (#25839) Analysis mostly by me, fix updated after suggestion by Adam J. Steward Co-authored-by: Bernhard Kaindl --- .../repos/builtin/packages/python/package.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 470b05f6ac..994578cffb 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -717,10 +717,12 @@ def config_vars(self): config['python_lib'] = {} for plat_specific in [True, False]: - config['python_inc'][plat_specific] = get_python_inc(plat_specific, prefix='') - config['python_lib'][plat_specific] = {} + plat_key = str(plat_specific).lower() + config['python_inc'][plat_key] = get_python_inc(plat_specific, prefix='') + config['python_lib'][plat_key] = {} for standard_lib in [True, False]: - config['python_lib'][plat_specific][standard_lib] = get_python_lib( + lib_key = str(standard_lib).lower() + config['python_lib'][plat_key][lib_key] = get_python_lib( plat_specific, standard_lib, prefix='' ) @@ -841,9 +843,9 @@ def python_include_dir(self): Returns: str: include files directory """ - if 'python_inc' in self.config_vars: + try: return self.config_vars['python_inc']['false'] - else: + except KeyError: return os.path.join('include', 'python{0}'.format(self.version.up_to(2))) @property @@ -865,9 +867,9 @@ def python_lib_dir(self): Returns: str: standard library directory """ - if 'python_lib' in self.config_vars: + try: return self.config_vars['python_lib']['false']['true'] - else: + except KeyError: return os.path.join('lib', 'python{0}'.format(self.version.up_to(2))) @property @@ -889,9 +891,9 @@ def site_packages_dir(self): Returns: str: site-packages directory """ - if 'python_lib' in self.config_vars: + try: return self.config_vars['python_lib']['false']['false'] - else: + except KeyError: return self.default_site_packages_dir @property