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 <bernhard.kaindl@ait.ac.at>
This commit is contained in:
bernhardkaindl 2021-09-09 09:25:55 +02:00 committed by GitHub
parent 1a5891754a
commit ed9b38c8e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -717,10 +717,12 @@ def config_vars(self):
config['python_lib'] = {} config['python_lib'] = {}
for plat_specific in [True, False]: for plat_specific in [True, False]:
config['python_inc'][plat_specific] = get_python_inc(plat_specific, prefix='') plat_key = str(plat_specific).lower()
config['python_lib'][plat_specific] = {} config['python_inc'][plat_key] = get_python_inc(plat_specific, prefix='')
config['python_lib'][plat_key] = {}
for standard_lib in [True, False]: 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='' plat_specific, standard_lib, prefix=''
) )
@ -841,9 +843,9 @@ def python_include_dir(self):
Returns: Returns:
str: include files directory str: include files directory
""" """
if 'python_inc' in self.config_vars: try:
return self.config_vars['python_inc']['false'] return self.config_vars['python_inc']['false']
else: except KeyError:
return os.path.join('include', 'python{0}'.format(self.version.up_to(2))) return os.path.join('include', 'python{0}'.format(self.version.up_to(2)))
@property @property
@ -865,9 +867,9 @@ def python_lib_dir(self):
Returns: Returns:
str: standard library directory str: standard library directory
""" """
if 'python_lib' in self.config_vars: try:
return self.config_vars['python_lib']['false']['true'] return self.config_vars['python_lib']['false']['true']
else: except KeyError:
return os.path.join('lib', 'python{0}'.format(self.version.up_to(2))) return os.path.join('lib', 'python{0}'.format(self.version.up_to(2)))
@property @property
@ -889,9 +891,9 @@ def site_packages_dir(self):
Returns: Returns:
str: site-packages directory str: site-packages directory
""" """
if 'python_lib' in self.config_vars: try:
return self.config_vars['python_lib']['false']['false'] return self.config_vars['python_lib']['false']['false']
else: except KeyError:
return self.default_site_packages_dir return self.default_site_packages_dir
@property @property