Windows: Fix external detection for service accounts (#37293)

Prior to this PR, the HOMEDRIVE environment variable was used to
detect what drive we are operating in. This variable is not available
for service account logins (like what is used for CI), so switch to
extracting the drive from PROGRAMFILES (which is more-widely defined).
This commit is contained in:
John W. Parent 2023-05-10 18:12:58 -04:00 committed by GitHub
parent 85cc9097cb
commit ec800cccbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,8 +218,10 @@ def update_configuration(detected_packages, scope=None, buildable=True):
def _windows_drive():
"""Return Windows drive string"""
return os.environ["HOMEDRIVE"]
"""Return Windows drive string extracted from PROGRAMFILES
env var, which is garunteed to be defined for all logins"""
drive = re.match(r"([a-zA-Z]:)", os.environ["PROGRAMFILES"]).group(1)
return drive
class WindowsCompilerExternalPaths(object):