@@ -656,6 +656,38 @@ def test_paths_depend_on_site_initialization(self):
656656
657657 self .assertNotEqual (site_paths , no_site_paths )
658658
659+ @unittest .skipIf (sys .platform == 'wasi' , 'venv is unsupported on WASI' )
660+ def test_makefile_overwrites_config_vars (self ):
661+ script = textwrap .dedent ("""
662+ import sys, sysconfig
663+
664+ data = {
665+ 'prefix': sys.prefix,
666+ 'exec_prefix': sys.exec_prefix,
667+ 'base_prefix': sys.base_prefix,
668+ 'base_exec_prefix': sys.base_exec_prefix,
669+ 'config_vars': sysconfig.get_config_vars(),
670+ }
671+
672+ import json
673+ print(json.dumps(data, indent=2))
674+ """ )
675+
676+ # We need to run the test inside a virtual environment so that
677+ # sys.prefix/sys.exec_prefix have a different value from the
678+ # prefix/exec_prefix Makefile variables.
679+ with self .venv () as venv :
680+ data = json .loads (venv .run ('-c' , script ).stdout )
681+
682+ # We expect sysconfig.get_config_vars to correctly reflect sys.prefix/sys.exec_prefix
683+ self .assertEqual (data ['prefix' ], data ['config_vars' ]['prefix' ])
684+ self .assertEqual (data ['exec_prefix' ], data ['config_vars' ]['exec_prefix' ])
685+ # As a sanity check, just make sure sys.prefix/sys.exec_prefix really
686+ # are different from the Makefile values.
687+ # sys.base_prefix/sys.base_exec_prefix should reflect the value of the
688+ # prefix/exec_prefix Makefile variables, so we use them in the comparison.
689+ self .assertNotEqual (data ['prefix' ], data ['base_prefix' ])
690+ self .assertNotEqual (data ['exec_prefix' ], data ['base_exec_prefix' ])
659691
660692class MakefileTests (unittest .TestCase ):
661693
0 commit comments