Skip to content

Commit 60d2d56

Browse files
authored
Merge pull request pypa#4628 from pypa/bugfix/1902-msvc-vcruntimeredist
Fix TypeError in VCRuntimeRedist
2 parents 1a9d873 + 13bd961 commit 60d2d56

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

newsfragments/1902.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed TypeError in ``msvc.EnvironmentInfo.return_env`` when no runtime redistributables are installed.

setuptools/msvc.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,14 +1375,11 @@ def FSharp(self):
13751375
return [self.si.FSharpInstallDir]
13761376

13771377
@property
1378-
def VCRuntimeRedist(self):
1378+
def VCRuntimeRedist(self) -> str | None:
13791379
"""
13801380
Microsoft Visual C++ runtime redistributable dll.
13811381
1382-
Return
1383-
------
1384-
str
1385-
path
1382+
Returns the first suitable path found or None.
13861383
"""
13871384
vcruntime = 'vcruntime%d0.dll' % self.vc_ver
13881385
arch_subdir = self.pi.target_dir(x64=True).strip('\\')
@@ -1406,11 +1403,11 @@ def VCRuntimeRedist(self):
14061403
)
14071404

14081405
# vcruntime path
1409-
for prefix, crt_dir in itertools.product(prefixes, crt_dirs):
1410-
path = join(prefix, arch_subdir, crt_dir, vcruntime)
1411-
if isfile(path):
1412-
return path
1413-
return None
1406+
candidate_paths = (
1407+
join(prefix, arch_subdir, crt_dir, vcruntime)
1408+
for (prefix, crt_dir) in itertools.product(prefixes, crt_dirs)
1409+
)
1410+
return next(filter(isfile, candidate_paths), None)
14141411

14151412
def return_env(self, exists=True):
14161413
"""
@@ -1469,7 +1466,7 @@ def return_env(self, exists=True):
14691466
exists,
14701467
),
14711468
)
1472-
if self.vs_ver >= 14 and isfile(self.VCRuntimeRedist):
1469+
if self.vs_ver >= 14 and self.VCRuntimeRedist:
14731470
env['py_vcruntime_redist'] = self.VCRuntimeRedist
14741471
return env
14751472

0 commit comments

Comments
 (0)