@@ -4242,15 +4242,16 @@ def test_toy_python(self):
42424242 """
42434243 Test whether $PYTHONPATH or $EBPYTHONPREFIXES are set correctly.
42444244 """
4245- # generate fake Python module that we can use as runtime dependency for toy
4245+ # generate fake Python modules that we can use as runtime dependency for toy
42464246 # (required condition for use of $EBPYTHONPREFIXES)
42474247 fake_mods_path = os .path .join (self .test_prefix , 'modules' )
4248- fake_python_mod = os .path .join (fake_mods_path , 'Python' , '3.6' )
4249- if get_module_syntax () == 'Lua' :
4250- fake_python_mod += '.lua'
4251- write_file (fake_python_mod , '' )
4252- else :
4253- write_file (fake_python_mod , '#%Module' )
4248+ for pyver in ('2.7' , '3.6' ):
4249+ fake_python_mod = os .path .join (fake_mods_path , 'Python' , pyver )
4250+ if get_module_syntax () == 'Lua' :
4251+ fake_python_mod += '.lua'
4252+ write_file (fake_python_mod , '' )
4253+ else :
4254+ write_file (fake_python_mod , '#%Module' )
42544255 self .modtool .use (fake_mods_path )
42554256
42564257 test_ecs = os .path .join (os .path .dirname (__file__ ), 'easyconfigs' , 'test_ecs' )
@@ -4284,20 +4285,27 @@ def test_toy_python(self):
42844285 self .assertTrue (pythonpath_regex .search (toy_mod_txt ),
42854286 f"Pattern '{ pythonpath_regex .pattern } ' found in: { toy_mod_txt } " )
42864287
4287- test_ec_txt += " \n dependencies = [('Python', '3.6', '', SYSTEM)]"
4288- write_file (test_ec , test_ec_txt )
4288+ # if Python is listed as runtime dependency, then $EBPYTHONPREFIXES is used if it's preferred
4289+ write_file (test_ec , test_ec_txt + " \n dependencies = [('Python', '3.6', '', SYSTEM)]" )
42894290 self .run_test_toy_build_with_output (ec_file = test_ec , extra_args = args )
42904291 toy_mod_txt = read_file (toy_mod )
42914292
42924293 ebpythonprefixes_regex = re .compile ('^prepend.path.*EBPYTHONPREFIXES.*root' , re .M )
42934294 self .assertTrue (ebpythonprefixes_regex .search (toy_mod_txt ),
42944295 f"Pattern '{ ebpythonprefixes_regex .pattern } ' found in: { toy_mod_txt } " )
42954296
4296- test_ec_txt += " \n force_pythonpath = True"
4297- write_file (test_ec , test_ec_txt )
4297+ # if Python is listed in multi_deps, then $EBPYTHONPREFIXES is used, even if it's not explicitely preferred
4298+ write_file (test_ec , test_ec_txt + " \n multi_deps = {'Python': ['2.7', '3.6']}" )
42984299 self .run_test_toy_build_with_output (ec_file = test_ec )
42994300 toy_mod_txt = read_file (toy_mod )
43004301
4302+ self .assertTrue (ebpythonprefixes_regex .search (toy_mod_txt ),
4303+ f"Pattern '{ ebpythonprefixes_regex .pattern } ' found in: { toy_mod_txt } " )
4304+
4305+ write_file (test_ec , test_ec_txt + "\n dependencies = [('Python', '3.6', '', SYSTEM)]\n force_pythonpath = True" )
4306+ self .run_test_toy_build_with_output (ec_file = test_ec , extra_args = args )
4307+ toy_mod_txt = read_file (toy_mod )
4308+
43014309 self .assertTrue (pythonpath_regex .search (toy_mod_txt ),
43024310 f"Pattern '{ pythonpath_regex .pattern } ' found in: { toy_mod_txt } " )
43034311
0 commit comments