Skip to content

Commit

Permalink
Project only the required environment variables on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 31, 2024
1 parent 9c0df31 commit 18a353f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import ast
import functools
import os
import pathlib
import subprocess
import sys

from typing import Generator

import jaraco.context
from jaraco.collections import Projection


def rel_prefix(node):
Expand Down Expand Up @@ -68,8 +70,10 @@ def builtin(self):
@functools.lru_cache
@CPE.passes
def _check_builtin(top_level_name):
# Windows can choke without these vars (python/cpython#120836)
safe_isolation = Projection(['SYSTEMDRIVE', 'SYSTEMROOT'], os.environ)
cmd = [sys.executable, '-S', '-c', f'import {top_level_name}']
subprocess.check_call(cmd, env={}, stderr=subprocess.DEVNULL)
subprocess.check_call(cmd, env=safe_isolation, stderr=subprocess.DEVNULL)


@functools.singledispatch
Expand Down

0 comments on commit 18a353f

Please sign in to comment.