Windows: fix MSVC version handling (#37711)
MSVC compiler logic was using string parsing to extract version from compiler spec, which was fragile. This broke in #37572, so has been fixed and made more robust by using attribute access.
This commit is contained in:
		@@ -30,7 +30,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_valid_fortran_pth(comp_ver):
 | 
					def get_valid_fortran_pth(comp_ver):
 | 
				
			||||||
    cl_ver = str(comp_ver).split("@")[1]
 | 
					    cl_ver = str(comp_ver)
 | 
				
			||||||
    sort_fn = lambda fc_ver: StrictVersion(fc_ver)
 | 
					    sort_fn = lambda fc_ver: StrictVersion(fc_ver)
 | 
				
			||||||
    sort_fc_ver = sorted(list(avail_fc_version), key=sort_fn)
 | 
					    sort_fc_ver = sorted(list(avail_fc_version), key=sort_fn)
 | 
				
			||||||
    for ver in sort_fc_ver:
 | 
					    for ver in sort_fc_ver:
 | 
				
			||||||
@@ -75,7 +75,7 @@ class Msvc(Compiler):
 | 
				
			|||||||
    # file based on compiler executable path.
 | 
					    # file based on compiler executable path.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        new_pth = [pth if pth else get_valid_fortran_pth(args[0]) for pth in args[3]]
 | 
					        new_pth = [pth if pth else get_valid_fortran_pth(args[0].version) for pth in args[3]]
 | 
				
			||||||
        args[3][:] = new_pth
 | 
					        args[3][:] = new_pth
 | 
				
			||||||
        super(Msvc, self).__init__(*args, **kwargs)
 | 
					        super(Msvc, self).__init__(*args, **kwargs)
 | 
				
			||||||
        if os.getenv("ONEAPI_ROOT"):
 | 
					        if os.getenv("ONEAPI_ROOT"):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user